mirror of
https://github.com/run-llama/multi-agents-workflow.git
synced 2026-06-30 21:27:55 -04:00
fix: added missing query tool, updated readme
This commit is contained in:
@@ -17,7 +17,7 @@ EMBEDDING_DIM=1024
|
||||
# CONVERSATION_STARTERS=
|
||||
|
||||
# The OpenAI API key to use.
|
||||
OPENAI_API_KEY=sk-proj-7qNCi2Btib0Y7AADy3tgT3BlbkFJ9d7IFV2lk2IfRnvDQbxp
|
||||
# OPENAI_API_KEY=
|
||||
|
||||
# Temperature for sampling from the model.
|
||||
# LLM_TEMPERATURE=
|
||||
@@ -40,18 +40,5 @@ APP_HOST=0.0.0.0
|
||||
# The port to start the backend app.
|
||||
APP_PORT=8000
|
||||
|
||||
# MESSAGE_QUEUE_PORT=
|
||||
|
||||
# CONTROL_PLANE_PORT=
|
||||
|
||||
# HUMAN_CONSUMER_PORT=
|
||||
|
||||
AGENT_QUERY_ENGINE_PORT=8003
|
||||
|
||||
AGENT_QUERY_ENGINE_DESCRIPTION=Query information from the provided data
|
||||
|
||||
AGENT_DUMMY_PORT=8004
|
||||
|
||||
# The system prompt for the AI model.
|
||||
SYSTEM_PROMPT=You are a helpful assistant who helps users with their questions.
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ First, setup the environment with poetry:
|
||||
|
||||
```shell
|
||||
poetry install
|
||||
poetry shell
|
||||
```
|
||||
|
||||
Then 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).
|
||||
@@ -19,28 +18,12 @@ Second, generate the embeddings of the documents in the `./data` directory (if t
|
||||
poetry run generate
|
||||
```
|
||||
|
||||
Third, run all the services in one command:
|
||||
Third, run all the agents in one command:
|
||||
|
||||
```shell
|
||||
poetry run python main.py
|
||||
```
|
||||
|
||||
You can monitor and test the agent services with `llama-agents` monitor TUI:
|
||||
|
||||
```shell
|
||||
poetry run llama-agents monitor --control-plane-url http://127.0.0.1:8001
|
||||
```
|
||||
|
||||
## Services:
|
||||
|
||||
- Message queue (port 8000): To exchange the message between services
|
||||
- Control plane (port 8001): A gateway to manage the tasks and services.
|
||||
- Human consumer (port 8002): To handle result when the task is completed.
|
||||
- Agent service `query_engine` (port 8003): Agent that can query information from the configured LlamaIndex index.
|
||||
- Agent service `dummy_agent` (port 8004): A dummy agent that does nothing. Good starting point to add more agents.
|
||||
|
||||
The ports listed above are set by default, but you can change them in the `.env` file.
|
||||
|
||||
## Learn More
|
||||
|
||||
To learn more about LlamaIndex, take a look at the following resources:
|
||||
|
||||
@@ -31,7 +31,7 @@ class FunctionCallingAgent(Workflow):
|
||||
tools: List[BaseTool] | None = None,
|
||||
system_prompt: str | None = None,
|
||||
verbose: bool = True,
|
||||
timeout: float = 120.0,
|
||||
timeout: float = 360.0,
|
||||
name: str,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,16 +1,39 @@
|
||||
# flake8: noqa: E402
|
||||
import asyncio
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
from app.agents.researcher.agent import get_query_engine_tool
|
||||
from app.core.agent_call import AgentCallingAgent
|
||||
from app.core.function_call import FunctionCallingAgent
|
||||
from app.engine.index import get_index
|
||||
from app.settings import init_settings
|
||||
|
||||
from llama_index.core.tools import QueryEngineTool, ToolMetadata
|
||||
|
||||
load_dotenv()
|
||||
init_settings()
|
||||
|
||||
|
||||
def get_query_engine_tool() -> QueryEngineTool:
|
||||
"""
|
||||
Provide an agent worker that can be used to query the index.
|
||||
"""
|
||||
index = get_index()
|
||||
if index is None:
|
||||
raise ValueError("Index not found. Please create an index first.")
|
||||
top_k = int(os.getenv("TOP_K", 0))
|
||||
query_engine = index.as_query_engine(
|
||||
**({"similarity_top_k": top_k} if top_k != 0 else {})
|
||||
)
|
||||
return QueryEngineTool(
|
||||
query_engine=query_engine,
|
||||
metadata=ToolMetadata(
|
||||
name="query_index",
|
||||
description="""
|
||||
Use this tool to retrieve information about the text corpus from the index.
|
||||
""",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def main():
|
||||
researcher = FunctionCallingAgent(
|
||||
name="researcher",
|
||||
@@ -24,6 +47,7 @@ async def main():
|
||||
writer = AgentCallingAgent(
|
||||
name="writer",
|
||||
agents=[researcher, reviewer],
|
||||
verbose=False,
|
||||
system_prompt="""You are an expert in writing blog posts. You are given a task to write a blog post. Before starting to write the post, consult the researcher agent to get the information you need. Don't make up any information yourself.
|
||||
After creating a draft for the post, send it to the reviewer agent to receive some feedback and make sure to incorporate the feedback from the reviewer.
|
||||
You can consult the reviewer and researcher multiple times. Only finish the task once the reviewer is satisfied.""",
|
||||
|
||||
Reference in New Issue
Block a user