How to take user uploaded files and manipulate them downstream? #703
-
|
I am using 'adk web' command to ask questions to the agent and upload files. I want the agent to take this user uploaded file, remember it and use it in another basic python function. I am getting an error when I try to run my code. Error: Failed to parse the parameter context: google.adk.agents.callback_context.CallbackContext of function save_artifacts for automatic function calling. Automatic function calling works best with simpler function signature schema,consider manually parse your function declaration for function save_artifacts. This is the code: def get_agent_response(artifact_name: str, query: str, tool_context: ToolContext) -> dict: def save_artifacts(context: CallbackContext, root_agent = Agent( artifact_service = InMemoryArtifactService() runner = Runner( |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
|
when using functions as tools you must use exactly "tool_context: ToolContext" as the context parameter, with that exact name and type. |
Beta Was this translation helpful? Give feedback.
-
|
@col30 , did you get it running. Were you able to upload your csv file and able to interact with it with the adk web. Please let me know. |
Beta Was this translation helpful? Give feedback.
-
|
From what I have seen, there is an issue with saving user-uploaded files while using the ADK web command. If I understand correctly how it works: the ADK web command creates a default runner with default parameters for your agent. Therefore, all your runner definitions are likely to be ignored by the command. You can't change the parameter save_input_blobs_as_artifacts to True and thus save user-uploaded docs as artifacts. I tried creating a custom class or monkey-patching the runner class, but they are just ignored by the ADK web command. The only way I found to make it work is to manually remove this condition (save_input_blobs_as_artifacts) at line 306 for the method _append_new_message_to_session of the Runner class (google.adk) in google.adk. After that, it works with the ADK web command. I opened an issue for this : #2176 (comment) |
Beta Was this translation helpful? Give feedback.
-
|
Has anyone found the solution for this?? - i am also trying but nothing is working |
Beta Was this translation helpful? Give feedback.
From what I have seen, there is an issue with saving user-uploaded files while using the ADK web command. If I understand correctly how it works: the ADK web command creates a default runner with default parameters for your agent. Therefore, all your runner definitions are likely to be ignored by the command. You can't change the parameter save_input_blobs_as_artifacts to True and thus save user-uploaded docs as artifacts.
I tried creating a custom class or monkey-patching the runner class, but they are just ignored by the ADK web command. The only way I found to make it work is to manually remove this condition (save_input_blobs_as_artifacts) at line 306 for the method _append_new_messag…