测试用例和结果

This commit is contained in:
zhaoawd
2025-10-29 23:43:06 +08:00
parent 59c9efa5d8
commit a78c8b9446
4 changed files with 137 additions and 1 deletions

View File

@ -0,0 +1,44 @@
"""Quick demo call against the unified chat endpoint using the OpenRouter provider."""
from __future__ import annotations
import asyncio
import httpx
from dotenv import load_dotenv
load_dotenv()
API_URL = "http://localhost:8000/v1/chat/completions"
async def main() -> None:
payload = {
"provider": "openrouter",
"model": "anthropic/claude-3.5-sonnet",
"messages": [
{
"role": "system",
"content": "You are an API assistant that writes concise JSON only.",
},
{
"role": "user",
"content": "Return a JSON object describing this test invocation.",
},
],
"temperature": 0.1,
"max_tokens": 300,
}
async with httpx.AsyncClient(timeout=httpx.Timeout(15.0)) as client:
response = await client.post(API_URL, json=payload)
print("Status:", response.status_code)
try:
print("Body:", response.json())
except ValueError:
print("Raw Body:", response.text)
if __name__ == "__main__":
asyncio.run(main())