|
| 1 | +# Copyright 2025 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +from google.adk import Agent |
| 16 | +from google.genai import types |
| 17 | + |
| 18 | + |
| 19 | +def concat_number_and_string(num: int, s: str) -> str: |
| 20 | + """Concatenate a number and a string. |
| 21 | +
|
| 22 | + Args: |
| 23 | + num: The number to concatenate. |
| 24 | + s: The string to concatenate. |
| 25 | +
|
| 26 | + Returns: |
| 27 | + The concatenated string. |
| 28 | + """ |
| 29 | + return str(num) + ': ' + s |
| 30 | + |
| 31 | + |
| 32 | +root_agent = Agent( |
| 33 | + model='gemini-3-pro-preview', |
| 34 | + name='hello_world_stream_fc_args', |
| 35 | + description='Demo agent showcasing streaming function call arguments.', |
| 36 | + instruction=""" |
| 37 | + You are a helpful assistant. |
| 38 | + You can use the `concat_number_and_string` tool to concatenate a number and a string. |
| 39 | + You should always call the concat_number_and_string tool to concatenate a number and a string. |
| 40 | + You should never concatenate on your own. |
| 41 | + """, |
| 42 | + tools=[ |
| 43 | + concat_number_and_string, |
| 44 | + ], |
| 45 | + generate_content_config=types.GenerateContentConfig( |
| 46 | + automatic_function_calling=types.AutomaticFunctionCallingConfig( |
| 47 | + disable=True, |
| 48 | + ), |
| 49 | + tool_config=types.ToolConfig( |
| 50 | + function_calling_config=types.FunctionCallingConfig( |
| 51 | + stream_function_call_arguments=True, |
| 52 | + ), |
| 53 | + ), |
| 54 | + ), |
| 55 | +) |
0 commit comments