autogen/python/samples/agentchat_chainlit
Eric Zhu 88c895fd48
sample: Update chainlit sample with streaming (#5304)
* Separate agent and team examples
* Add streaming output
* Refactor to better use the chainlit API
* Removed the user proxy example -- this needs a bit more work to
improve the presentation on the ChainLit interface.

---------

Co-authored-by: Victor Dibia <victordibia@microsoft.com>
2025-01-31 22:20:11 +00:00
..
2024-12-18 14:49:07 -08:00
2024-12-18 14:49:07 -08:00

Building a Multi-Agent Application with AutoGen and Chainlit

In this sample, we will demonstrate how to build simple chat interface that interacts with an AgentChat agent or a team, using Chainlit, and support streaming messages.

AgentChat.

Installation

To run this sample, you will need to install the following packages:

pip install -U chainlit autogen-agentchat autogen-ext[openai] pyyaml

To use other model providers, you will need to install a different extra for the autogen-ext package. See the Models documentation for more information.

Model Configuration

Create a configuration file named model_config.yaml to configure the model you want to use. Use model_config_template.yaml as a template.

Running the Agent Sample

The first sample demonstrate how to interact with a single AssistantAgent from the chat interface.

chainlit run app_agent.py -h

You can use one of the starters. For example, ask "What the weather in Seattle?".

The agent will respond by first using the tools provided and then reflecting on the result of the tool execution.

Running the Team Sample

The second sample demonstrate how to interact with a team of agents from the chat interface.

chainlit run app_team.py -h

You can use one of the starters. For example, ask "Write a poem about winter.".

The team is a RoundRobinGroupChat, so each agent will respond in turn. There are two agents in the team: one is instructed to be generally helpful and the other one is instructed to be a critic and provide feedback. The two agents will respond in round-robin fashion until the 'APPROVE' is mentioned by the critic agent.

Next Steps

There are a few ways you can extend this example:

  • Try other agents.
  • Try other team types beyond the RoundRobinGroupChat.
  • Explore custom agents that sent multimodal messages.