mirror of
https://github.com/run-llama/multi-agents-workflow.git
synced 2026-06-30 21:27:55 -04:00
fix: don't reset contexts using 0.11.4
This commit is contained in:
committed by
Marcus Schiesser
parent
71bfa304a7
commit
f6e4855273
@@ -35,8 +35,6 @@ class AgentCallTool(ContextAwareTool):
|
||||
|
||||
# overload the acall function with the ctx argument as it's needed for bubbling the events
|
||||
async def acall(self, ctx: Context, input: str) -> ToolOutput:
|
||||
# FIXME: reset contexts, not needed after https://github.com/run-llama/llama_index/pull/15776
|
||||
self.agent._contexts = set()
|
||||
task = asyncio.create_task(self.agent.run(input=input))
|
||||
# bubble all events while running the agent to the calling agent
|
||||
async for ev in self.agent.stream_events():
|
||||
|
||||
@@ -118,8 +118,6 @@ class StructuredPlannerAgent(Workflow):
|
||||
) -> SubTaskResultEvent:
|
||||
if self._verbose:
|
||||
print(f"=== Executing sub task: {ev.sub_task.name} ===")
|
||||
# FIXME: reset contexts, not needed after https://github.com/run-llama/llama_index/pull/15776
|
||||
self.executor._contexts = set()
|
||||
task = asyncio.create_task(self.executor.run(input=ev.sub_task.input))
|
||||
# bubble all events while running the executor to the planner
|
||||
async for event in self.executor.stream_events():
|
||||
|
||||
+1
-10
@@ -1,21 +1,12 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import textwrap
|
||||
from typing import List
|
||||
|
||||
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, Request, status
|
||||
from llama_index.core.chat_engine.types import BaseChatEngine, NodeWithScore
|
||||
from llama_index.core.llms import MessageRole
|
||||
from llama_index.core.llms import ChatResponse
|
||||
from fastapi import APIRouter, HTTPException, Request, status
|
||||
from llama_index.core.workflow import Workflow
|
||||
|
||||
from app.agents.single import AgentRunResult
|
||||
from app.examples.factory import create_agent
|
||||
from app.api.routers.models import (
|
||||
ChatData,
|
||||
Message,
|
||||
Result,
|
||||
SourceNodes,
|
||||
)
|
||||
from app.api.routers.vercel_response import VercelStreamResponse
|
||||
|
||||
|
||||
@@ -6,10 +6,8 @@ from typing import AsyncGenerator
|
||||
from aiostream import stream
|
||||
from fastapi import Request
|
||||
from fastapi.responses import StreamingResponse
|
||||
from llama_index.core.chat_engine.types import StreamingAgentChatResponse
|
||||
|
||||
from app.api.routers.models import ChatData, Message, SourceNodes
|
||||
from app.api.services.suggestion import NextQuestionSuggestion
|
||||
from app.api.routers.models import ChatData
|
||||
from app.agents.single import AgentRunEvent, AgentRunResult
|
||||
|
||||
logger = logging.getLogger("uvicorn")
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
from app.examples.choreography import create_choreography
|
||||
from app.examples.orchestrator import create_orchestrator
|
||||
from app.examples.workflow import create_workflow
|
||||
@@ -8,10 +9,12 @@ from llama_index.core.workflow import Workflow
|
||||
|
||||
import os
|
||||
|
||||
logger = logging.getLogger("uvicorn")
|
||||
|
||||
|
||||
def create_agent() -> Workflow:
|
||||
TYPE = os.getenv("EXAMPLE_TYPE", "").lower()
|
||||
match TYPE:
|
||||
agent_type = os.getenv("EXAMPLE_TYPE", "").lower()
|
||||
match agent_type:
|
||||
case "choreography":
|
||||
agent = create_choreography()
|
||||
case "orchestrator":
|
||||
@@ -20,7 +23,9 @@ def create_agent() -> Workflow:
|
||||
agent = create_workflow()
|
||||
case _:
|
||||
raise ValueError(
|
||||
f"Invalid EXAMPLE_TYPE env variable: {TYPE}. Choose 'choreography', 'orchestrator', or 'workflow'."
|
||||
f"Invalid EXAMPLE_TYPE env variable: {agent_type}. Choose 'choreography', 'orchestrator', or 'workflow'."
|
||||
)
|
||||
|
||||
logger.info(f"Using agent pattern: {agent_type}")
|
||||
|
||||
return agent
|
||||
|
||||
@@ -44,7 +44,6 @@ class ReviewEvent(Event):
|
||||
|
||||
|
||||
class BlogPostWorkflow(Workflow):
|
||||
|
||||
@step()
|
||||
async def start(self, ctx: Context, ev: StartEvent) -> ResearchEvent:
|
||||
# start the workflow with researching about a topic
|
||||
@@ -104,8 +103,6 @@ Review:
|
||||
async def run_agent(
|
||||
self, ctx: Context, agent: FunctionCallingAgent, input: str
|
||||
) -> AgentRunResult:
|
||||
# FIXME: reset contexts, not needed after https://github.com/run-llama/llama_index/pull/15776
|
||||
agent._contexts = set()
|
||||
task = asyncio.create_task(agent.run(input=input))
|
||||
# bubble all events while running the executor to the planner
|
||||
async for event in agent.stream_events():
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
# flake8: noqa: E402
|
||||
import asyncio
|
||||
import os
|
||||
import textwrap
|
||||
from dotenv import load_dotenv
|
||||
from app.agents.single import AgentRunResult
|
||||
|
||||
from app.config import DATA_DIR
|
||||
|
||||
@@ -21,9 +18,6 @@ from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import RedirectResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from app.examples.orchestrator import create_orchestrator
|
||||
from app.examples.choreography import create_choreography
|
||||
from app.examples.workflow import create_workflow
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@@ -70,10 +64,6 @@ app.include_router(config_router, prefix="/api/chat/config")
|
||||
app.include_router(file_upload_router, prefix="/api/chat/upload")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app_host = os.getenv("APP_HOST", "0.0.0.0")
|
||||
app_port = int(os.getenv("APP_PORT", "8000"))
|
||||
|
||||
Generated
+13
-13
@@ -787,19 +787,19 @@ pydantic = ">=1.10"
|
||||
|
||||
[[package]]
|
||||
name = "llama-index"
|
||||
version = "0.11.3"
|
||||
version = "0.11.4"
|
||||
description = "Interface between LLMs and your data"
|
||||
optional = false
|
||||
python-versions = "<4.0,>=3.8.1"
|
||||
files = [
|
||||
{file = "llama_index-0.11.3-py3-none-any.whl", hash = "sha256:f307a29b07536bca26cc39f955ec767d10c25becf167d409075bfaba9e2c654f"},
|
||||
{file = "llama_index-0.11.3.tar.gz", hash = "sha256:4133b06931b3dc15b9a66bf127a06e2dbb19fe991e10afe58b7ef44a14085d29"},
|
||||
{file = "llama_index-0.11.4-py3-none-any.whl", hash = "sha256:6a7b1177fb12396ecff336786c2a4e083703df7f1f330c19ed74ced30f865b9d"},
|
||||
{file = "llama_index-0.11.4.tar.gz", hash = "sha256:aa048ffa96eff02bd70a2de095c0465143498956493a8f93e186e6e958087832"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
llama-index-agent-openai = ">=0.3.0,<0.4.0"
|
||||
llama-index-cli = ">=0.3.0,<0.4.0"
|
||||
llama-index-core = ">=0.11.3,<0.12.0"
|
||||
llama-index-core = ">=0.11.4,<0.12.0"
|
||||
llama-index-embeddings-openai = ">=0.2.0,<0.3.0"
|
||||
llama-index-indices-managed-llama-cloud = ">=0.3.0"
|
||||
llama-index-legacy = ">=0.9.48,<0.10.0"
|
||||
@@ -808,7 +808,7 @@ llama-index-multi-modal-llms-openai = ">=0.2.0,<0.3.0"
|
||||
llama-index-program-openai = ">=0.2.0,<0.3.0"
|
||||
llama-index-question-gen-openai = ">=0.2.0,<0.3.0"
|
||||
llama-index-readers-file = ">=0.2.0,<0.3.0"
|
||||
llama-index-readers-llama-parse = ">=0.2.0"
|
||||
llama-index-readers-llama-parse = ">=0.3.0"
|
||||
nltk = ">3.8.1"
|
||||
|
||||
[[package]]
|
||||
@@ -845,13 +845,13 @@ llama-index-llms-openai = ">=0.2.0,<0.3.0"
|
||||
|
||||
[[package]]
|
||||
name = "llama-index-core"
|
||||
version = "0.11.3"
|
||||
version = "0.11.4"
|
||||
description = "Interface between LLMs and your data"
|
||||
optional = false
|
||||
python-versions = "<4.0,>=3.8.1"
|
||||
files = [
|
||||
{file = "llama_index_core-0.11.3-py3-none-any.whl", hash = "sha256:061aaf3892707bff6a34fb264ccda30b9a920890379e04c3ae9895edddde5e22"},
|
||||
{file = "llama_index_core-0.11.3.tar.gz", hash = "sha256:6b042e531797ccd755496570d563f3b1d9b42c292d3a311f8c21c8eb6aa57706"},
|
||||
{file = "llama_index_core-0.11.4-py3-none-any.whl", hash = "sha256:a76fcc7ea7af6fb4f211e20a3003d4e711f523a2a4bffba04bfb16c2a58112de"},
|
||||
{file = "llama_index_core-0.11.4.tar.gz", hash = "sha256:df19dac380c0ece1aff84ecbfcc74f686c15287c64923998582b0cb0520ed6e5"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@@ -1031,18 +1031,18 @@ pymupdf = ["pymupdf (>=1.23.21,<2.0.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "llama-index-readers-llama-parse"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
description = "llama-index readers llama-parse integration"
|
||||
optional = false
|
||||
python-versions = "<4.0,>=3.8.1"
|
||||
files = [
|
||||
{file = "llama_index_readers_llama_parse-0.2.0-py3-none-any.whl", hash = "sha256:c0cb103fac8cd0a6de62a1b71a56884bef99a2d55c3afcabb073f078e727494f"},
|
||||
{file = "llama_index_readers_llama_parse-0.2.0.tar.gz", hash = "sha256:c54e8a207d73efb9f011636a30a4c1076b43d77a34d2563d374dc67c0cddfc83"},
|
||||
{file = "llama_index_readers_llama_parse-0.3.0-py3-none-any.whl", hash = "sha256:1973cc710dbd5e110c7500c9983ecb45787ad1ff92e6b2113f94a57cf48f3038"},
|
||||
{file = "llama_index_readers_llama_parse-0.3.0.tar.gz", hash = "sha256:a5feada0895714dcc41d65dd512c1c38cf70d8ae19947cff82b80d58e6aa367e"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
llama-index-core = ">=0.11.0,<0.12.0"
|
||||
llama-parse = ">=0.4.0"
|
||||
llama-parse = ">=0.5.0"
|
||||
|
||||
[[package]]
|
||||
name = "llama-parse"
|
||||
@@ -2298,4 +2298,4 @@ multidict = ">=4.0"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "2380d5b0bfcca7b32c0d07854c9ec33f698aeae8d006e0b6f71d85ff0729746b"
|
||||
content-hash = "9f385b9d680d08626d7bf79b63b7ad649e30b87b292a2e195bf1bdebdd8033c0"
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ generate = "app.engine.generate:generate_datasource"
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
llama-index-agent-openai = ">=0.3.0,<0.4.0"
|
||||
llama-index = "^0.11.3"
|
||||
llama-index = "^0.11.4"
|
||||
fastapi = "^0.112.2"
|
||||
|
||||
[tool.poetry.dependencies.docx2txt]
|
||||
|
||||
Reference in New Issue
Block a user