Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration Issue: Async Functions and Thread Handling in Chainlit with AutoGen #6

Open
luv-singh-ai opened this issue Sep 22, 2024 · 0 comments

Comments

@luv-singh-ai
Copy link
Collaborator

I'm experiencing issues while integrating Chainlit with OpenAI's AutoGen framework for a multi-agent chatbot. The main problems revolve around asynchronous function handling and thread management.

Environment:

Python Version: Python 3.10
Operating System: macOS Monterey

Steps to Reproduce:

Run the following code using chainlit run app_frontend.py.
Input a message like "Hi, I am having exam stress" in the chatbot.
Observe the errors and behavior.

See the app_frontend.py code

Error Messages:

First Error:
RuntimeWarning: coroutine 'ChainlitAssistantAgent.send' was never awaited

Occurs when the send method in ChainlitAssistantAgent is asynchronous but expected to be synchronous by the autogen library.

Second Error:
TypeError: object dict can't be used in 'await' expression in line 195:
await cl.make_async(initiate_chat)()

Indicates that a non-awaitable object is being awaited.

Third Error:
KeyError: 'run_in_thread'

Occurs when trying to use cl.run_in_thread, which doesn't exist in Chainlit.

Attempts to Resolve:

Changed the send methods in custom agent classes to be synchronous and used cl.run_sync to handle asynchronous Chainlit functions.
Replaced cl.make_async with asyncio.to_thread in the on_message function to run the synchronous user_proxy.initiate_chat method without blocking the event loop.

Issues Remaining:

Even after making these changes, I'm still experiencing errors related to the asynchronous handling of functions and thread management.
The chatbot works for the first conversation but fails or produces errors in subsequent interactions.

#Request:

I'm seeking assistance to:

Identify the root cause of these issues.
Provide guidance on properly integrating Chainlit with the AutoGen framework, especially regarding asynchronous function handling and thread management.
Ensure compatibility between Chainlit and AutoGen for multi-agent chatbots.

Additional Information:

The prompts.yaml file contains the necessary prompts for each agent.
The OAI_CONFIG_LIST environment variable is correctly set and accessible.
I'm using Python 3.10 and have the latest versions of Chainlit and AutoGen installed.

Thankks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant