mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2026-02-03 21:36:24 -06:00
feat: Update for anthropic models
Enable parallel tools for anthropic models, and add agent examples, and also added functional test for anthropic models. PiperOrigin-RevId: 766703018
This commit is contained in:
committed by
Copybara-Service
parent
44f507895e
commit
16f7d98acf
@@ -135,6 +135,10 @@ def content_block_to_part(
|
||||
def message_to_generate_content_response(
|
||||
message: anthropic_types.Message,
|
||||
) -> LlmResponse:
|
||||
logger.info(
|
||||
"Claude response: %s",
|
||||
message.model_dump_json(indent=2, exclude_none=True),
|
||||
)
|
||||
|
||||
return LlmResponse(
|
||||
content=types.Content(
|
||||
@@ -229,14 +233,11 @@ class Claude(BaseLlm):
|
||||
for tool in llm_request.config.tools[0].function_declarations
|
||||
]
|
||||
tool_choice = (
|
||||
anthropic_types.ToolChoiceAutoParam(
|
||||
type="auto",
|
||||
# TODO: allow parallel tool use.
|
||||
disable_parallel_tool_use=True,
|
||||
)
|
||||
anthropic_types.ToolChoiceAutoParam(type="auto")
|
||||
if llm_request.tools_dict
|
||||
else NOT_GIVEN
|
||||
)
|
||||
# TODO(b/421255973): Enable streaming for anthropic models.
|
||||
message = self._anthropic_client.messages.create(
|
||||
model=llm_request.model,
|
||||
system=llm_request.config.system_instruction,
|
||||
@@ -245,10 +246,6 @@ class Claude(BaseLlm):
|
||||
tool_choice=tool_choice,
|
||||
max_tokens=MAX_TOKEN,
|
||||
)
|
||||
logger.info(
|
||||
"Claude response: %s",
|
||||
message.model_dump_json(indent=2, exclude_none=True),
|
||||
)
|
||||
yield message_to_generate_content_response(message)
|
||||
|
||||
@cached_property
|
||||
|
||||
Reference in New Issue
Block a user