This is a LlamaIndex multi-agents project using Workflows.
This example is using three agents to generate a blog post:
- a researcher that retrieves content via a RAG pipeline,
- a writer that specializes in writing blog posts and
- a reviewer that is reviewing the blog post.
There are three different methods how the agents can interact to reach their goal:
- Choreography - the agents decide themselves to delegate a task to another agent
- Orchestrator - a central orchestrator decides which agent should execute a task
- Explicit Workflow - a pre-defined workflow specific for the task is used to execute the tasks
First, setup the environment with poetry:
Note: This step is not needed if you are using the dev-container.
poetry installThen check the parameters that have been pre-configured in the .env file in this directory. (E.g. you might need to configure an OPENAI_API_KEY if you're using OpenAI as model provider).
Second, generate the embeddings of the documents in the ./data directory:
poetry run generateThird, run the development server:
poetry run python main.pyPer default, the example is using the explicit workflow. You can change the example by setting the EXAMPLE_TYPE environment variable to choreography or orchestrator.
The example provides one streaming API endpoint /api/chat.
You can test the endpoint with the following curl request:
curl --location 'localhost:8000/api/chat' \
--header 'Content-Type: application/json' \
--data '{ "messages": [{ "role": "user", "content": "Write a blog post about physical standards for letters" }] }'
You can start editing the API by modifying app/api/routers/chat.py or app/examples/workflow.py. The API auto-updates as you save the files.
Open http://localhost:8000/docs with your browser to see the Swagger UI of the API.
The API allows CORS for all origins to simplify development. You can change this behavior by setting the ENVIRONMENT environment variable to prod:
ENVIRONMENT=prod poetry run python main.py
To learn more about LlamaIndex, take a look at the following resources:
- LlamaIndex Documentation - learn about LlamaIndex.
- Workflows Introduction - learn about LlamaIndex workflows.
You can check out the LlamaIndex GitHub repository - your feedback and contributions are welcome!