Repository navigation
Replies: 1 comment
|
With current Python ADK, you can keep the normal For a small named text artifact, add tools like these to your existing agent: from google.adk.tools.tool_context import ToolContext
from google.genai import types
async def save_note(text: str, tool_context: ToolContext) -> str:
part = types.Part.from_bytes(data=text.encode("utf-8"), mime_type="text/plain")
version = await tool_context.save_artifact(filename="user:note.txt", artifact=part)
return f"Saved version {version}"
async def load_note(tool_context: ToolContext) -> str:
part = await tool_context.load_artifact(filename="user:note.txt")
if part is None or part.inline_data is None:
return "No note has been saved."
return part.inline_data.data.decode("utf-8")Include For a large searchable information store, artifacts alone are not an index: |
Uh oh!
There was an error while loading. Please reload this page.
I'm a bit confused as to the implementation requirements of artifacts. If I want to implement them is it required that I set up my own custom runner, artifact service, memory service, etc. or can I integrate within the default structure in which we are only required to define our agent and tools?
If it is possible to implement without requiring the creation of a main.py to run everything and can be utilized through adk web, how do we add this feature correctly? I want my agent to be able to access a large store of information whenever a user query necessitates that the agent reference it but do so without flooding its context.
Any shared code on the most simple method of saving and loading artifacts correctly so that the agent can interact with them would be much appreciated, thanks!
All reactions