💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Update test
davidmezzetti19a4b7571f10
diff --git a/test/python/testpipeline/testllm/testlitellm.py b/test/python/testpipeline/testllm/testlitellm.pyindex ee52e60c..688f6ab5 100644--- a/test/python/testpipeline/testllm/testlitellm.py+++ b/test/python/testpipeline/testllm/testlitellm.py@@ -3,7 +3,12 @@ LiteLLM module tests"""import json+import os+import timeimport unittest+import uuid++from unittest.mock import patchfrom http.server import HTTPServer, BaseHTTPRequestHandlerfrom threading import Thread@@ -28,12 +33,34 @@ class RequestHandler(BaseHTTPRequestHandler):if data.get("stream"):# Mock streaming responsecontent = "application/octet-stream"- response = """data: {"token": {"text": "blue"}}""".encode("utf-8")+ response = (+ "data: "+ + json.dumps(+ {+ "id": str(uuid.uuid4()),+ "object": "chat.completion.chunk",+ "created": int(time.time() * 1000),+ "model": "test",+ "choices": [{"id": 0, "delta": {"content": "blue"}}],+ }+ )+ + "\n\ndata: [DONE]\n\n"+ )else:# Mock standard responsecontent = "application/json"- response = [{"generated_text": "blue"}]- response = json.dumps(response).encode("utf-8")+ response = json.dumps(+ {+ "id": str(uuid.uuid4()),+ "object": "chat.completion",+ "created": int(time.time() * 1000),+ "model": "test",+ "choices": [{"id": 0, "message": {"role": "assistant", "content": "blue"}, "finish_reason": "stop"}],+ }+ )++ # Encode response as bytes+ response = response.encode("utf-8")self.send_response(200)self.send_header("content-type", content)@@ -68,13 +95,14 @@ class TestLiteLLM(unittest.TestCase):cls.httpd.shutdown()+ @patch.dict(os.environ, {"OPENAI_API_KEY": "test"})def testGeneration(self):"""Test generation with LiteLLM"""- # Test model generation with llama.cpp- model = LLM("huggingface/t5-small", api_base="http://127.0.0.1:8000")+ # Test model generation with LiteLLM+ model = LLM("gpt-4o", api_base="http://127.0.0.1:8000")self.assertEqual(model("The sky is"), "blue")# Test default role