()
| 135 | |
| 136 | |
| 137 | async def test_async_tool_calls(): |
| 138 | completion = await client.chat.completions.create( |
| 139 | model="gpt-3.5-turbo-1106", |
| 140 | messages=[ |
| 141 | {"role": "system", "content": "tell me the weather in SF and Orlando"} |
| 142 | ], |
| 143 | tools=[ |
| 144 | { |
| 145 | "type": "function", |
| 146 | "function": function, |
| 147 | }, |
| 148 | ], |
| 149 | openpipe={"tags": {"prompt_id": "test_async_tool_calls"}}, |
| 150 | ) |
| 151 | |
| 152 | if not TEST_LAST_LOGGED: |
| 153 | return |
| 154 | |
| 155 | await asyncio.sleep(0.1) |
| 156 | last_logged = ( |
| 157 | await client.openpipe_reporting_client.base_client.local_testing_only_get_latest_logged_call() |
| 158 | ) |
| 159 | assert ( |
| 160 | last_logged.req_payload["messages"][0]["content"] |
| 161 | == "tell me the weather in SF and Orlando" |
| 162 | ) |
| 163 | assert ( |
| 164 | last_logged.resp_payload["choices"][0]["message"]["content"] |
| 165 | == completion.choices[0].message.content |
| 166 | ) |
| 167 | assert ( |
| 168 | last_logged.resp_payload["choices"][0]["message"]["tool_calls"][0]["function"][ |
| 169 | "name" |
| 170 | ] |
| 171 | == "get_current_weather" |
| 172 | ) |
| 173 | |
| 174 | |
| 175 | async def test_async_tool_calls_mistral(): |
nothing calls this directly
no test coverage detected