File tree Expand file tree Collapse file tree 10 files changed +59
-19
lines changed
Expand file tree Collapse file tree 10 files changed +59
-19
lines changed Original file line number Diff line number Diff line change 2626 uv pip install -r ./genai/requirements.txt --system
2727
2828 - name : GenAI tests
29+ env :
30+ OPEN_WEB_UI_API_KEY : ${{ secrets.OPEN_WEB_UI_API_KEY }}
31+ API_URL : ${{ vars.API_URL }}
2932 run : |
3033 cd genai
3134 pytest
Original file line number Diff line number Diff line change @@ -120,6 +120,11 @@ services:
120120 DB_HOST : ${DB_HOST:-weaviate}
121121 DB_PORT : ${DB_PORT:-9090}
122122 DB_GRPC_PORT : ${DB_GRPC_PORT:-50051}
123+ OPEN_WEB_UI_API_KEY : ${OPEN_WEB_UI_API_KEY}
124+ SERVER_URL : ${SERVER_URL:-http://localhost:9091}
125+ CLIENT_URL : ${CLIENT_URL:-http://localhost:3000}
126+ GENAI_URL : ${GENAI_URL:-http://localhost:8000}
127+ API_URL : ${API_URL:-https://gpu.aet.cit.tum.de/api/chat/completions}
123128 depends_on :
124129 - weaviate
125130 volumes :
Original file line number Diff line number Diff line change 1- CHAIR_API_KEY = your-api-key-here
1+ OPEN_WEB_UI_API_KEY = your-api-key-here
2+ API_URL = " https://your-api-url-here"
Original file line number Diff line number Diff line change 2020router = APIRouter ()
2121
2222# Environment configuration
23- CHAIR_API_KEY = os .getenv ("CHAIR_API_KEY" )
24- API_URL = "https://gpu.aet.cit.tum.de/api/chat/completions"
25-
23+ OPEN_WEB_UI_API_KEY = os .getenv ("OPEN_WEB_UI_API_KEY" )
24+ API_URL = os .getenv ("API_URL" )
25+ SERVER_URL = os .getenv ("SERVER_URL" )
26+ CLIENT_URL = os .getenv ("CLIENT_URL" )
27+ GENAI_URL = os .getenv ("GENAI_URL" )
2628
2729class OpenWebUILLM (LLM ):
2830 api_url : str = API_URL
29- api_key : str = CHAIR_API_KEY
31+ api_key : str = OPEN_WEB_UI_API_KEY
3032 model_name : str = "llama3.3:latest"
3133
3234 @property
@@ -41,7 +43,7 @@ def _call(
4143 ** kwargs : Any ,
4244 ) -> str :
4345 if not self .api_key :
44- raise ValueError ("CHAIR_API_KEY environment variable is required" )
46+ raise ValueError ("API_KEY environment variable is required" )
4547
4648 headers = {
4749 "Authorization" : f"Bearer { self .api_key } " ,
@@ -97,14 +99,14 @@ def custom_openapi():
9799 title = app .title ,
98100 version = app .version ,
99101 routes = app .routes ,
100- servers = [{"url" : "http://localhost:8000" }],
102+ servers = [{"url" : GENAI_URL }],
101103 )
102104 )
103105
104106
105107app .add_middleware (
106108 CORSMiddleware ,
107- allow_origins = ["http://localhost:3000" , "http://localhost:9091" ],
109+ allow_origins = [CLIENT_URL , SERVER_URL ],
108110 allow_credentials = True ,
109111 allow_methods = ["*" ],
110112 allow_headers = ["*" ],
Original file line number Diff line number Diff line change 1+ from fastapi .testclient import TestClient
2+ from app .main import app
3+
4+ client = TestClient (app )
5+
6+ def test_health_check ():
7+ response = client .get ("/health" )
8+ assert response .status_code == 200
9+ assert "status" in response .json ()
10+
11+
12+ def test_completion ():
13+ payload = {"user_text" : ["This is a test input." ]}
14+ response = client .post ("/completion" , json = payload )
15+ assert response .status_code == 200
16+ assert "llm_response" in response .json ()
17+
18+ def test_summarization ():
19+ payload = {"user_text" : ["This is a long sentence that needs summarizing." ]}
20+ response = client .post ("/summarization" , json = payload )
21+ assert response .status_code == 200
22+ assert "llm_response" in response .json ()
23+
24+
25+ def test_rephrase ():
26+ payload = {"user_text" : ["This is a sample sentence." ]}
27+ response = client .post ("/rephrase" , json = payload )
28+ assert response .status_code == 200
29+ assert "llm_response" in response .json ()
Original file line number Diff line number Diff line change @@ -74,4 +74,13 @@ line-ending = "auto"
7474#
7575# This only has an effect when the `docstring-code-format` setting is
7676# enabled.
77- # docstring-code-line-length = "dynamic"
77+ # docstring-code-line-length = "dynamic"
78+
79+ [tool .pytest .ini_options ]
80+ asyncio_mode = " auto"
81+ testpaths = [" app" ]
82+ python_files = [" test_*.py" , " *_test.py" , " test.py" ]
83+ addopts = " -v"
84+ markers = [
85+ " asyncio: mark test as an async test" ,
86+ ]
Original file line number Diff line number Diff line change 11annotated-types == 0.7.0
2- anyio == 4.9.0
32authlib == 1.3.1
43certifi == 2025.4.26
54cffi == 1.17.1
65click == 8.1.8
7- cryptography == 44 .0.3
6+ cryptography == 43 .0.3
87deprecation == 2.1.0
98dnspython == 2.7.0
109email-validator == 2.2.0
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments