(async_snapshot_client: AsyncAnthropic)
| 533 | ], |
| 534 | ) |
| 535 | async def test_basic_call_async(async_snapshot_client: AsyncAnthropic) -> None: |
| 536 | @beta_async_tool |
| 537 | async def get_weather(location: str, units: Literal["c", "f"]) -> BetaFunctionToolResultType: |
| 538 | """Lookup the weather for a given city in either celsius or fahrenheit |
| 539 | |
| 540 | Args: |
| 541 | location: The city and state, e.g. San Francisco, CA |
| 542 | units: Unit for the output, either 'c' for celsius or 'f' for fahrenheit |
| 543 | Returns: |
| 544 | A dictionary containing the location, temperature, and weather condition. |
| 545 | """ |
| 546 | return json.dumps(_get_weather(location, units)) |
| 547 | |
| 548 | await async_snapshot_client.beta.messages.tool_runner( |
| 549 | max_tokens=1024, |
| 550 | model="claude-haiku-4-5", |
| 551 | tools=[get_weather], |
| 552 | messages=[{"role": "user", "content": "What is the weather in SF?"}], |
| 553 | ).until_done() |
| 554 | |
| 555 | |
| 556 | def _refusal_with_tool_use() -> httpx2.Response: |
nothing calls this directly
no test coverage detected