Closed shhlife closed 2 weeks ago
can you try updating your output_fn
to:
from griptape.structures import Agent
from griptape.utils import Chat
def output_fn(text: str, stream: bool):
print(text, end="", flush=True)
agent = Agent(stream=True)
Chat(agent, handle_output=output_fn).start()
the error is happening because it is expecting your provided handle_output
function to have a stream
parameter, which is in the docstring
Yeah, that's the first thing I tired but it still gave an error:
TypeError: output_fn() missing 1 required positional argument: 'stream'
doing **kwargs
was the only thing that stopped the error.
Also, it wasn't mentioned in the changelog.md file - would it be possible to add that since it's a breaking change for existing code?
ah i see. can you try:
from griptape.structures import Agent
from griptape.utils import Chat
def output_fn(text: str, *, stream: bool = False):
print(text, end="", flush=True)
agent = Agent(stream=True)
Chat(agent, handle_output=output_fn).start()
for now? the default function has the expected method signature:
default_handle_output(self, text: str, *, stream: bool = False)
but the docstring should probably be more specific I also dont think this was intended to be breaking based on the changelog, so it needs to be updated
sadly, that didn't work either - same error :(
sorry just updated, add the default value there. basically just copy the method signature from default_handle_output
exactly. PR coming in for this too
Describe the bug In griptape v0.33 the Chat utility used to have an
output_fn
parameter that could handle agents that had astream
parameter set to true. For example:With the latest update to v0.34,
output_fn
has been renamed tohandle_output
, and it no longer acceptsstream
.gives this result:
this can be resolved by adding a
**kwarsg
to the output_fn, but we should make sure to document this.