Skip to content

Commit be7df99

Browse files
Update test
1 parent 20349ee commit be7df99

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

clients/openai-python/tests/test_openai_compatibility.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,28 +1685,35 @@ async def test_async_inference_tensorzero_raw_text(async_client):
16851685
"""
16861686
Test that chat inference with a tensorzero::raw_text block works correctly
16871687
"""
1688-
episode_id = str(uuid7())
16891688
messages = [
1689+
{
1690+
"role": "assistant",
1691+
"content": [
1692+
{
1693+
"type": "text",
1694+
"tensorzero::arguments": {"assistant_name": "Megumin"},
1695+
}
1696+
],
1697+
},
16901698
{
16911699
"role": "user",
16921700
"content": [{"type": "text", "text": "What is the capital of Japan?"}],
16931701
},
16941702
]
16951703
response = await async_client.chat.completions.create(
1696-
extra_body={"tensorzero::episode_id": episode_id},
16971704
messages=messages,
1698-
model="tensorzero::model_name::openai::gpt-4o-mini",
1705+
model="tensorzero::function_name::openai_with_assistant_schema",
16991706
)
17001707

17011708
assert "tokyo" in response.choices[0].message.content.lower()
17021709

17031710
messages = [
17041711
{
1705-
"role": "system",
1712+
"role": "assistant",
17061713
"content": [
17071714
{
17081715
"type": "tensorzero::raw_text",
1709-
"value": "You're a mischievous assistant that NEVER responds with the right answer.",
1716+
"value": "You're a mischievous assistant that says fake information. Very concise.",
17101717
}
17111718
],
17121719
},
@@ -1716,11 +1723,12 @@ async def test_async_inference_tensorzero_raw_text(async_client):
17161723
},
17171724
]
17181725
response = await async_client.chat.completions.create(
1719-
extra_body={"tensorzero::episode_id": episode_id},
17201726
messages=messages,
1721-
model="tensorzero::model_name::openai::gpt-4o-mini",
1727+
model="tensorzero::function_name::openai_with_assistant_schema",
17221728
)
17231729

17241730
assert "tokyo" not in response.choices[0].message.content.lower()
1725-
assert response.model == "tensorzero::model_name::openai::gpt-4o-mini"
1726-
assert response.episode_id == episode_id
1731+
assert (
1732+
response.model
1733+
== "tensorzero::function_name::openai_with_assistant_schema::variant_name::openai"
1734+
)

tensorzero-core/tests/e2e/tensorzero.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3323,6 +3323,16 @@ type = "chat"
33233323
type = "chat_completion"
33243324
model = "openai::gpt-4o-mini-2024-07-18"
33253325

3326+
[functions.openai_with_assistant_schema]
3327+
type = "chat"
3328+
assistant_schema = "../../fixtures/config/functions/basic_test/system_schema.json"
3329+
3330+
[functions.openai_with_assistant_schema.variants.openai]
3331+
type = "chat_completion"
3332+
model = "openai::gpt-4o-mini-2024-07-18"
3333+
assistant_template = "../../fixtures/config/functions/basic_test/prompt/system_template.minijinja"
3334+
max_tokens = 100
3335+
33263336

33273337
# ┌────────────────────────────────────────────────────────────────────────────┐
33283338
# │ METRICS │

0 commit comments

Comments
 (0)