mirror of
https://github.com/katanemo/plano.git
synced 2026-06-26 15:39:40 +02:00
update fix
This commit is contained in:
parent
d9c64738c7
commit
68c2243e83
6 changed files with 43 additions and 33 deletions
|
|
@ -30,8 +30,7 @@ def get_arch_messages(response_json):
|
|||
arch_messages = []
|
||||
if response_json and "metadata" in response_json:
|
||||
# load arch_state from metadata
|
||||
arch_state_str = response_json.get("metadata") or {}
|
||||
arch_state_str = arch_state_str.get(ARCH_STATE_HEADER, "{}")
|
||||
arch_state_str = response_json.get("metadata", {}).get(ARCH_STATE_HEADER, "{}")
|
||||
# parse arch_state into json object
|
||||
arch_state = json.loads(arch_state_str)
|
||||
# load messages from arch_state
|
||||
|
|
|
|||
|
|
@ -262,8 +262,8 @@ def test_prompt_gateway_default_target(stream):
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("prefill_enabled", [True, False])
|
||||
def test_prompt_gateway_arch_prefill(prefill_enabled):
|
||||
@pytest.mark.parametrize("stream", [True, False])
|
||||
def test_prompt_gateway_arch_prefill(stream):
|
||||
body = {
|
||||
"messages": [
|
||||
{
|
||||
|
|
@ -271,29 +271,44 @@ def test_prompt_gateway_arch_prefill(prefill_enabled):
|
|||
"content": "how is the weather",
|
||||
}
|
||||
],
|
||||
"prefill_enabled": prefill_enabled,
|
||||
"stream": stream,
|
||||
}
|
||||
response = requests.post(PROMPT_GATEWAY_ENDPOINT, json=body)
|
||||
assert response.status_code == 200
|
||||
response_json = response.json()
|
||||
assert response_json.get("model").startswith("Arch")
|
||||
choices = response_json.get("choices", [])
|
||||
assert len(choices) > 0
|
||||
if prefill_enabled:
|
||||
prefill_list = [
|
||||
"May",
|
||||
"Could",
|
||||
"Sure",
|
||||
"Definitely",
|
||||
"Certainly",
|
||||
"Of course",
|
||||
"Can",
|
||||
]
|
||||
assistant_message = choices[0]["message"]["content"]
|
||||
assert any(
|
||||
assistant_message.startswith(word) for word in prefill_list
|
||||
), f"Expected assistant message to start with one of {prefill_list}, but got '{assistant_message}'"
|
||||
|
||||
if stream:
|
||||
chunks = get_data_chunks(response, n=3)
|
||||
assert len(chunks) > 0
|
||||
response_json = json.loads(chunks[0])
|
||||
# make sure arch responded directly
|
||||
assert response_json.get("model").startswith("Arch")
|
||||
# and tool call is null
|
||||
choices = response_json.get("choices", [])
|
||||
assert len(choices) > 0
|
||||
tool_calls = choices[0].get("delta", {}).get("tool_calls", [])
|
||||
assert len(tool_calls) == 0
|
||||
response_json = json.loads(chunks[1])
|
||||
choices = response_json.get("choices", [])
|
||||
assert len(choices) > 0
|
||||
message = choices[0]["delta"]["content"]
|
||||
else:
|
||||
response_json = response.json()
|
||||
assert response_json.get("model").startswith("Arch")
|
||||
choices = response_json.get("choices", [])
|
||||
assert len(choices) > 0
|
||||
message = choices[0]["message"]["content"]
|
||||
assert "Could you provide the following details days" not in message
|
||||
|
||||
prefill_list = [
|
||||
"May",
|
||||
"Could",
|
||||
"Sure",
|
||||
"Definitely",
|
||||
"Certainly",
|
||||
"Of course",
|
||||
"Can",
|
||||
]
|
||||
|
||||
assert any(
|
||||
message.startswith(word) for word in prefill_list
|
||||
), f"Expected assistant message to start with one of {prefill_list}, but got '{assistant_message}'"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue