You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When streaming output from a structure that's using structured output, it would be helpful to ensure the output data is valid.
For example:
fromgriptape.structuresimportAgentfromgriptape.utilsimportStreamimportschemaagent=Agent(stream=True,
output_schema=schema.Schema({"item": str, "description": str})
)
full_result=""forartifactinStream(agent).run("give me a cookie name and its description"):
full_result+=artifact.valueprint(full_result)
will print out partial strings as the chunks come back
it's cool seeing this, but unfortunately the results aren't clean json.
If we integrate the library json-repair, we can make it output cleaner results..
fromgriptape.structuresimportAgentfromgriptape.utilsimportStreamfromjson_repairimportrepair_json# json_repairimportschemaagent=Agent(stream=True,
output_schema=schema.Schema({"item": str, "description": str})
)
full_result=""forartifactinStream(agent).run("give me a cookie name and a short description"):
full_result+=artifact.valueprint(repair_json(full_result)) # repair it
When streaming output from a structure that's using structured output, it would be helpful to ensure the output data is valid.
For example:
will print out partial strings as the chunks come back
it's cool seeing this, but unfortunately the results aren't clean json.
If we integrate the library
json-repair
, we can make it output cleaner results..and we get these results:
can we add this as part of Stream?
The text was updated successfully, but these errors were encountered: