From 59b290daf3ef0b765cf3dcd208deb6e38d3da561 Mon Sep 17 00:00:00 2001 From: zhiao-G Date: Fri, 8 May 2026 15:56:16 +0800 Subject: [PATCH] fix(agent_tools): Fix code session parameter passing and update entry function parameters Change the api_key parameter in the code_session call to keyword argument passingAdd the payload parameter to the agent_chat function to support request data --- examples/agent_tools/README.md | 2 +- examples/agent_tools/integrate_tools.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/agent_tools/README.md b/examples/agent_tools/README.md index 378d886..f22e6da 100644 --- a/examples/agent_tools/README.md +++ b/examples/agent_tools/README.md @@ -92,7 +92,7 @@ def execute_python_tool(code: str, description: str) -> str | None: api_key = os.environ.get( "HUAWEICLOUD_SDK_CODE_INTERPRETER_API_KEY", "" ) # 配置环境变量后,api_key无需在代码中传递亦可正常工作 - with code_session("your_region", "your_code_interpreter_name", api_key) as code_client: + with code_session("your_region", "your_code_interpreter_name", api_key=api_key) as code_client: response = code_client.invoke( operate_type="execute_code", api_key=api_key, diff --git a/examples/agent_tools/integrate_tools.py b/examples/agent_tools/integrate_tools.py index ba2f666..12f82fb 100644 --- a/examples/agent_tools/integrate_tools.py +++ b/examples/agent_tools/integrate_tools.py @@ -59,7 +59,7 @@ def execute_python_tool(code: str, description: str) -> str | None: api_key = os.environ.get( "HUAWEICLOUD_SDK_CODE_INTERPRETER_API_KEY", "" ) # 配置环境变量后,api_key无需在代码中传递亦可正常工作 - with code_session("your_region", "your_code_interpreter_name", api_key) as code_client: + with code_session("your_region", "your_code_interpreter_name", api_key=api_key) as code_client: response = code_client.invoke( operate_type="execute_code", api_key=api_key, @@ -134,7 +134,7 @@ def should_continue(state): @app.entrypoint -def agent_chat(): +def agent_chat(payload: dict): query = "告诉我1到100之间最大的质数" # 运行Agent