Chainlit / cookbook

Chainlit's cookbook repo
https://github.com/Chainlit/chainlit
662 stars 245 forks source link

Autogen Async Example raise error #115

Open andriyadi opened 1 month ago

andriyadi commented 1 month ago

I've tried this example and got this error (and the stacktrace):

--------------------------------------------------------------------------------
user_proxy (to assistant):

2024-05-19 18:33:54 - content must be None, str, or list, but got <class 'coroutine'>
Traceback (most recent call last):
  File "/Users/andri/Projects/Python/virtualenvs/agentic/lib/python3.12/site-packages/chainlit/utils.py", line 40, in wrapper
    return await user_function(**params_values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andri/Projects/LLM/Projects/AutoGenExplore/exp-webapp-async.py", line 102, in on_chat_start
    await user_proxy.a_initiate_chat(
  File "/Users/andri/Projects/Python/virtualenvs/agentic/lib/python3.12/site-packages/autogen/agentchat/conversable_agent.py", line 1073, in a_initiate_chat
    await self.a_send(msg2send, recipient, silent=silent)
  File "/Users/andri/Projects/LLM/Projects/AutoGenExplore/exp-webapp-async.py", line 80, in a_send
    await super(ChainlitUserProxyAgent, self).a_send(
  File "/Users/andri/Projects/Python/virtualenvs/agentic/lib/python3.12/site-packages/autogen/agentchat/conversable_agent.py", line 695, in a_send
    await recipient.a_receive(message, self, request_reply, silent)
  File "/Users/andri/Projects/Python/virtualenvs/agentic/lib/python3.12/site-packages/autogen/agentchat/conversable_agent.py", line 847, in a_receive
    await self.a_send(reply, sender, silent=silent)
  File "/Users/andri/Projects/LLM/Projects/AutoGenExplore/exp-webapp-async.py", line 27, in a_send
    await super(ChainlitAssistantAgent, self).a_send(
  File "/Users/andri/Projects/Python/virtualenvs/agentic/lib/python3.12/site-packages/autogen/agentchat/conversable_agent.py", line 695, in a_send
    await recipient.a_receive(message, self, request_reply, silent)
  File "/Users/andri/Projects/Python/virtualenvs/agentic/lib/python3.12/site-packages/autogen/agentchat/conversable_agent.py", line 847, in a_receive
    await self.a_send(reply, sender, silent=silent)
  File "/Users/andri/Projects/LLM/Projects/AutoGenExplore/exp-webapp-async.py", line 80, in a_send
    await super(ChainlitUserProxyAgent, self).a_send(
  File "/Users/andri/Projects/Python/virtualenvs/agentic/lib/python3.12/site-packages/autogen/agentchat/conversable_agent.py", line 695, in a_send
    await recipient.a_receive(message, self, request_reply, silent)
  File "/Users/andri/Projects/Python/virtualenvs/agentic/lib/python3.12/site-packages/autogen/agentchat/conversable_agent.py", line 842, in a_receive
    self._process_received_message(message, sender, silent)
  File "/Users/andri/Projects/Python/virtualenvs/agentic/lib/python3.12/site-packages/autogen/agentchat/conversable_agent.py", line 773, in _process_received_message
    self._print_received_message(message, sender)
  File "/Users/andri/Projects/Python/virtualenvs/agentic/lib/python3.12/site-packages/autogen/agentchat/conversable_agent.py", line 732, in _print_received_message
    iostream.print(content_str(content), flush=True)
                   ^^^^^^^^^^^^^^^^^^^^
  File "/Users/andri/Projects/Python/virtualenvs/agentic/lib/python3.12/site-packages/autogen/code_utils.py", line 68, in content_str
    raise TypeError(f"content must be None, str, or list, but got {type(content)}")
TypeError: content must be None, str, or list, but got <class 'coroutine'>

Apparently it should wait for human input, but instead I got that. Here's the screen capture of the UI: Screenshot 2024-05-19 at 18 41 32

I can confirm that running non-async version is working well. Please advice. Thank you.