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

Function run

tests/lib/tools/test_open_telemetry.py:180–195  ·  view source on GitHub ↗
(
    client: Anthropic, *, conversation_id: str | None = None, **kwargs: Any
)

Source from the content-addressed store, hash-verified

178
179
180def run(
181 client: Anthropic, *, conversation_id: str | None = None, **kwargs: Any
182) -> "BetaToolRunner[Any] | BetaStreamingToolRunner[Any]":
183 if conversation_id is not None:
184 client = client.with_options(open_telemetry={**client.open_telemetry, "conversation_id": conversation_id})
185 return cast(
186 "BetaToolRunner[Any] | BetaStreamingToolRunner[Any]",
187 client.beta.messages.tool_runner(
188 max_tokens=1024,
189 model="claude-test",
190 # Made here, because tool functions need pydantic v2 and this module is collected under v1 too.
191 tools=[beta_tool(get_weather)],
192 messages=[{"role": "user", "content": "What is the weather in SF?"}],
193 **kwargs,
194 ),
195 )
196
197
198def async_run(client: AsyncAnthropic, **kwargs: Any) -> Any:

Calls 3

beta_toolFunction · 0.90
with_optionsMethod · 0.80
tool_runnerMethod · 0.45

Tested by

no test coverage detected