File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
clients/openai-python/tests Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -1678,3 +1678,47 @@ async def test_async_json_function_multiple_text_blocks(async_client):
16781678 ],
16791679 )
16801680 assert result .model == "tensorzero::model_name::dummy::multiple-text-blocks"
1681+
1682+
1683+ @pytest .mark .asyncio
1684+ async def test_async_inference_tensorzero_raw_text (async_client ):
1685+ """
1686+ Test that chat inference with a tensorzero::raw_text block works correctly
1687+ """
1688+ episode_id = str (uuid7 ())
1689+ messages = [
1690+ {
1691+ "role" : "system" ,
1692+ "content" : [
1693+ {
1694+ "type" : "text" ,
1695+ "tensorzero::arguments" : {"assistant_name" : "Alfred Pennyworth" },
1696+ }
1697+ ]
1698+ },
1699+ {
1700+ "role" : "user" ,
1701+ "content" : [
1702+ {
1703+ "type" : "tensorzero::raw_text" ,
1704+ "value" : "What is the capital of Japan?"
1705+ }
1706+ ],
1707+ },
1708+ ]
1709+
1710+ response = await async_client .chat .completions .create (
1711+ extra_body = {"tensorzero::episode_id" : episode_id },
1712+ messages = messages ,
1713+ model = "tensorzero::function_name::json_success" ,
1714+ )
1715+
1716+ content = response .choices [0 ].message .content
1717+
1718+ assert isinstance (content , str )
1719+
1720+ assert content == '{"answer":"Hello"}'
1721+ assert response .model == "tensorzero::function_name::json_success::variant_name::test"
1722+ assert response .episode_id == episode_id
1723+ assert response .usage .prompt_tokens == 10
1724+ assert response .usage .completion_tokens == 1
You can’t perform that action at this time.
0 commit comments