MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / test_basic_call_async

Function test_basic_call_async

tests/lib/tools/test_runners.py:535–553  ·  view source on GitHub ↗
(async_snapshot_client: AsyncAnthropic)

Source from the content-addressed store, hash-verified

533 ],
534)
535async 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
556def _refusal_with_tool_use() -> httpx2.Response:

Callers

nothing calls this directly

Calls 2

until_doneMethod · 0.45
tool_runnerMethod · 0.45

Tested by

no test coverage detected