mirror of
https://github.com/katanemo/plano.git
synced 2026-07-02 15:51:02 +02:00
fix e2e tests
This commit is contained in:
parent
4e89084fa7
commit
02efe6d095
3 changed files with 10 additions and 10 deletions
|
|
@ -22,12 +22,12 @@ llm_providers:
|
||||||
provider_interface: openai
|
provider_interface: openai
|
||||||
model: llama-3.2-3b-preview
|
model: llama-3.2-3b-preview
|
||||||
base_url: https://api.groq.com
|
base_url: https://api.groq.com
|
||||||
default: true
|
|
||||||
|
|
||||||
- name: gpt-4o
|
- name: gpt-4o
|
||||||
access_key: $OPENAI_API_KEY
|
access_key: $OPENAI_API_KEY
|
||||||
provider_interface: openai
|
provider_interface: openai
|
||||||
model: gpt-4o
|
model: gpt-4o
|
||||||
|
default: true
|
||||||
|
|
||||||
system_prompt: |
|
system_prompt: |
|
||||||
You are a helpful assistant.
|
You are a helpful assistant.
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ async def weather(req: WeatherRequest, res: Response):
|
||||||
|
|
||||||
|
|
||||||
class DefaultTargetRequest(BaseModel):
|
class DefaultTargetRequest(BaseModel):
|
||||||
messages: list
|
messages: list = []
|
||||||
|
|
||||||
|
|
||||||
@app.post("/default_target")
|
@app.post("/default_target")
|
||||||
|
|
@ -86,12 +86,9 @@ async def default_target(req: DefaultTargetRequest, res: Response):
|
||||||
"role": "assistant",
|
"role": "assistant",
|
||||||
"content": "I can help you with weather forecast",
|
"content": "I can help you with weather forecast",
|
||||||
},
|
},
|
||||||
"finish_reason": "completed",
|
|
||||||
"index": 0,
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"model": "api_server",
|
"model": "api_server",
|
||||||
"usage": {"completion_tokens": 0},
|
|
||||||
}
|
}
|
||||||
logger.info(f"sending response: {json.dumps(resp)}")
|
logger.info(f"sending response: {json.dumps(resp)}")
|
||||||
return resp
|
return resp
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ def test_prompt_gateway(stream):
|
||||||
|
|
||||||
# third..end chunk is summarization (role = assistant)
|
# third..end chunk is summarization (role = assistant)
|
||||||
response_json = json.loads(chunks[2])
|
response_json = json.loads(chunks[2])
|
||||||
assert response_json.get("model").startswith("llama-3.2-3b-preview")
|
assert response_json.get("model").startswith("gpt-4o")
|
||||||
choices = response_json.get("choices", [])
|
choices = response_json.get("choices", [])
|
||||||
assert len(choices) > 0
|
assert len(choices) > 0
|
||||||
assert "role" in choices[0]["delta"]
|
assert "role" in choices[0]["delta"]
|
||||||
|
|
@ -86,7 +86,7 @@ def test_prompt_gateway(stream):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
response_json = response.json()
|
response_json = response.json()
|
||||||
assert response_json.get("model").startswith("llama-3.2-3b-preview")
|
assert response_json.get("model").startswith("gpt-4o")
|
||||||
choices = response_json.get("choices", [])
|
choices = response_json.get("choices", [])
|
||||||
assert len(choices) > 0
|
assert len(choices) > 0
|
||||||
assert "role" in choices[0]["message"]
|
assert "role" in choices[0]["message"]
|
||||||
|
|
@ -252,7 +252,7 @@ def test_prompt_gateway_param_tool_call(stream):
|
||||||
|
|
||||||
# third..end chunk is summarization (role = assistant)
|
# third..end chunk is summarization (role = assistant)
|
||||||
response_json = json.loads(chunks[2])
|
response_json = json.loads(chunks[2])
|
||||||
assert response_json.get("model").startswith("llama-3.2-3b-preview")
|
assert response_json.get("model").startswith("gpt-4o")
|
||||||
choices = response_json.get("choices", [])
|
choices = response_json.get("choices", [])
|
||||||
assert len(choices) > 0
|
assert len(choices) > 0
|
||||||
assert "role" in choices[0]["delta"]
|
assert "role" in choices[0]["delta"]
|
||||||
|
|
@ -261,7 +261,7 @@ def test_prompt_gateway_param_tool_call(stream):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
response_json = response.json()
|
response_json = response.json()
|
||||||
assert response_json.get("model").startswith("llama-3.2-3b-preview")
|
assert response_json.get("model").startswith("gpt-4o")
|
||||||
choices = response_json.get("choices", [])
|
choices = response_json.get("choices", [])
|
||||||
assert len(choices) > 0
|
assert len(choices) > 0
|
||||||
assert "role" in choices[0]["message"]
|
assert "role" in choices[0]["message"]
|
||||||
|
|
@ -283,7 +283,7 @@ def test_prompt_gateway_default_target(stream):
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
"content": "hello, what can you do for me?",
|
"content": "hello",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"stream": stream,
|
"stream": stream,
|
||||||
|
|
@ -294,17 +294,20 @@ def test_prompt_gateway_default_target(stream):
|
||||||
chunks = get_data_chunks(response, n=3)
|
chunks = get_data_chunks(response, n=3)
|
||||||
assert len(chunks) > 0
|
assert len(chunks) > 0
|
||||||
response_json = json.loads(chunks[0])
|
response_json = json.loads(chunks[0])
|
||||||
|
print("response_json chunks[0]: ", response_json)
|
||||||
assert response_json.get("model").startswith("api_server")
|
assert response_json.get("model").startswith("api_server")
|
||||||
assert len(response_json.get("choices", [])) > 0
|
assert len(response_json.get("choices", [])) > 0
|
||||||
assert response_json.get("choices")[0]["delta"]["role"] == "assistant"
|
assert response_json.get("choices")[0]["delta"]["role"] == "assistant"
|
||||||
|
|
||||||
response_json = json.loads(chunks[1])
|
response_json = json.loads(chunks[1])
|
||||||
|
print("response_json chunks[1]: ", response_json)
|
||||||
choices = response_json.get("choices", [])
|
choices = response_json.get("choices", [])
|
||||||
assert len(choices) > 0
|
assert len(choices) > 0
|
||||||
content = choices[0]["delta"]["content"]
|
content = choices[0]["delta"]["content"]
|
||||||
assert content == "I can help you with weather forecast"
|
assert content == "I can help you with weather forecast"
|
||||||
else:
|
else:
|
||||||
response_json = response.json()
|
response_json = response.json()
|
||||||
|
print("response_json: ", response_json)
|
||||||
assert response_json.get("model").startswith("api_server")
|
assert response_json.get("model").startswith("api_server")
|
||||||
assert len(response_json.get("choices")) > 0
|
assert len(response_json.get("choices")) > 0
|
||||||
assert response_json.get("choices")[0]["message"]["role"] == "assistant"
|
assert response_json.get("choices")[0]["message"]["role"] == "assistant"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue