Spaces:
Build error
Build error
File size: 1,017 Bytes
0e4080b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import pytest
from fastapi.testclient import TestClient
from app import app
client = TestClient(app)
def test_chat_endpoint():
test_messages = [
{"role": "user", "content": "What is 2+2?"}
]
response = client.post(
"/api/chat",
json={
"messages": test_messages,
"use_gemini": False, # Test local LLM
"temperature": 0.7
}
)
assert response.status_code == 200
assert "response" in response.json()
assert isinstance(response.json()["response"], str)
def test_gemini_chat():
test_messages = [
{"role": "user", "content": "Tell me a short joke."}
]
response = client.post(
"/api/chat",
json={
"messages": test_messages,
"use_gemini": True, # Test Gemini API
"temperature": 0.7
}
)
assert response.status_code == 200
assert "response" in response.json()
assert isinstance(response.json()["response"], str)
|