Skip to content

Commit 5c6001d

Browse files
ystorycopybara-github
authored andcommitted
fix(sample): Correct text artifact saving in artifact_save_text sample
Copybara import of the project: -- 9529247 by Yongsul Kim <ystory84@gmail.com>: COPYBARA_INTEGRATE_REVIEW=#936 from ystory:fix/artifact-sample-save 7b0babc PiperOrigin-RevId: 766220649
1 parent 2409c3e commit 5c6001d

File tree

1 file changed

+9
-2
lines changed
  • contributing/samples/artifact_save_text

1 file changed

+9
-2
lines changed

contributing/samples/artifact_save_text/agent.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@
1919

2020

2121
async def log_query(tool_context: ToolContext, query: str):
22-
"""Roll a die with the specified number of sides."""
23-
await tool_context.save_artifact('query', types.Part(text=query))
22+
"""Saves the provided query string as a 'text/plain' artifact named 'query'."""
23+
query_bytes = query.encode('utf-8')
24+
artifact_part = types.Part(
25+
inline_data=types.Blob(
26+
mime_type='text/plain',
27+
data=query_bytes
28+
)
29+
)
30+
await tool_context.save_artifact('query', artifact_part)
2431

2532

2633
root_agent = Agent(

0 commit comments

Comments
 (0)