mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
feat: Support both output_schema and tools at the same time in LlmAgent
1. Allow developers to specify output schema and tools together. 2. If both are specified, do the following: 2.1 Do not set output schema on the model config 2.2 Add a special tool called set_model_response(result) 2.3 `result` has the same schema as the requested output_schema 2.4 Instruct the model to use set_model_response() to output its final result, rather than output text directly. 2.5 When the set_model_response() is called, ADK will extract its content and put it in a text part, so the client would treat it as the model response. PiperOrigin-RevId: 792686011
This commit is contained in:
committed by
Copybara-Service
parent
b4ce3b12d1
commit
af635674b5
@@ -201,19 +201,18 @@ def test_output_schema_with_sub_agents_will_throw():
|
||||
)
|
||||
|
||||
|
||||
def test_output_schema_with_tools_will_throw():
|
||||
def test_output_schema_with_tools_will_not_throw():
|
||||
class Schema(BaseModel):
|
||||
pass
|
||||
|
||||
def _a_tool():
|
||||
pass
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
_ = LlmAgent(
|
||||
name='test_agent',
|
||||
output_schema=Schema,
|
||||
tools=[_a_tool],
|
||||
)
|
||||
LlmAgent(
|
||||
name='test_agent',
|
||||
output_schema=Schema,
|
||||
tools=[_a_tool],
|
||||
)
|
||||
|
||||
|
||||
def test_before_model_callback():
|
||||
|
||||
Reference in New Issue
Block a user