From 7d27291f9f2ae2c5da2fd438f99d0fb1e1948f60 Mon Sep 17 00:00:00 2001 From: Andrei Fajardo Date: Sat, 3 Aug 2024 15:20:32 -0400 Subject: [PATCH] cr --- docker-compose.yml | 11 +++++++ poetry.lock | 30 +++++++++++-------- pyproject.toml | 2 +- .../agent_services/funny_agent.py | 2 +- .../core_services/control_plane.py | 22 ++++++-------- 5 files changed, 39 insertions(+), 28 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 72ba97e..caa94b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,6 +32,8 @@ services: build: context: . dockerfile: ./Dockerfile + secrets: + - id_ed25519 healthcheck: test: wget --no-verbose --tries=1 http://0.0.0.0:8001/ || exit 1 interval: 30s @@ -58,6 +60,8 @@ services: build: context: . dockerfile: ./Dockerfile + secrets: + - id_ed25519 healthcheck: test: wget --no-verbose --tries=1 http://0.0.0.0:8002/is_worker_running || exit 1 interval: 30s @@ -84,6 +88,8 @@ services: build: context: . dockerfile: ./Dockerfile + secrets: + - id_ed25519 healthcheck: test: wget --no-verbose --tries=1 http://0.0.0.0:8003/is_worker_running || exit 1 interval: 30s @@ -110,6 +116,8 @@ services: build: context: . dockerfile: ./Dockerfile + secrets: + - id_ed25519 healthcheck: test: wget --no-verbose --tries=1 http://0.0.0.0:8004/is_worker_running || exit 1 interval: 30s @@ -118,3 +126,6 @@ services: timeout: 10s volumes: rabbitmq: +secrets: + id_ed25519: + file: ~/.ssh/id_ed25519 diff --git a/poetry.lock b/poetry.lock index 64f59b4..c6f293b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1377,26 +1377,30 @@ name = "llama-agents" version = "0.0.12" description = "" optional = false -python-versions = "<4.0,>=3.8.1" -files = [ - {file = "llama_agents-0.0.12-py3-none-any.whl", hash = "sha256:821710ff21833e24ad4c4354a6c0544ff66d7379fd691609c1585f076e183cea"}, - {file = "llama_agents-0.0.12.tar.gz", hash = "sha256:136ee5fae26b0e61e44c80731bc89e8e8d47c1afc6af716818f7ad2d9a662a00"}, -] +python-versions = ">=3.8.1,<4.0" +files = [] +develop = false [package.dependencies] -aio-pika = {version = ">=9.4.2,<10.0.0", optional = true, markers = "extra == \"rabbitmq\""} -fastapi = ">=0.109.1,<0.110.0" -llama-index-core = ">=0.10.50,<0.11.0" -pytest-asyncio = ">=0.23.7,<0.24.0" -pytest-mock = ">=3.14.0,<4.0.0" -textual = ">=0.70.0,<0.71.0" -uvicorn = ">=0.30.1,<0.31.0" +aio-pika = {version = "^9.4.2", optional = true} +fastapi = "^0.109.1" +llama-index-core = "^0.10.50" +pytest-asyncio = "^0.23.7" +pytest-mock = "^3.14.0" +textual = "^0.70.0" +uvicorn = "^0.30.1" [package.extras] kafka = ["aiokafka (>=0.11.0,<0.12.0)", "kafka-python-ng (>=2.2.2,<3.0.0)"] rabbitmq = ["aio-pika (>=9.4.2,<10.0.0)"] redis = ["redis (>=5.0.7,<6.0.0)"] +[package.source] +type = "git" +url = "git@github.com:run-llama/llama-agents.git" +reference = "nerdai-fix-pipeline-orchestrator" +resolved_reference = "5d87da4c9d386391d09be6ba81d3a321b35e124f" + [[package]] name = "llama-index-agent-openai" version = "0.2.9" @@ -3984,4 +3988,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "22e17f257918ccc1a584897229dc97943c834562f4beb6dc8278da8595f1227d" +content-hash = "d6e34c7f56ea79cff3a4749e1c68d6959a4715ee07b39a49ecbac3fc7f89e348" diff --git a/pyproject.toml b/pyproject.toml index 4a64e09..0de013b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ streamlit = "^1.36.0" llama-index-readers-file = "^0.1.30" llama-index-embeddings-openai = "^0.1.11" llama-index-program-openai = "^0.1.7" -llama-agents = {version = "^0.0.12", extras = ["rabbitmq"]} +llama-agents = {git = "git@github.com:run-llama/llama-agents.git", rev = "nerdai-fix-pipeline-orchestrator", extras = ["rabbitmq"]} snowflake-sqlalchemy = "^1.6.1" [tool.poetry.group.dev.dependencies] diff --git a/snowflake_cybersyn_demo/agent_services/funny_agent.py b/snowflake_cybersyn_demo/agent_services/funny_agent.py index be84b1e..bf5be9a 100644 --- a/snowflake_cybersyn_demo/agent_services/funny_agent.py +++ b/snowflake_cybersyn_demo/agent_services/funny_agent.py @@ -43,7 +43,7 @@ def get_the_secret_fact() -> str: agent_server = AgentService( agent=agent, message_queue=message_queue, - description="Cannot get timeseries data of specified good, but can handle all other queries.", + description="Do not select for any queries regarding timeseries data. Can be used for everything but that.", service_name="funny_agent", host=funny_agent_host, port=int(funny_agent_port) if funny_agent_port else None, diff --git a/snowflake_cybersyn_demo/core_services/control_plane.py b/snowflake_cybersyn_demo/core_services/control_plane.py index 97674ef..4ddcc9a 100644 --- a/snowflake_cybersyn_demo/core_services/control_plane.py +++ b/snowflake_cybersyn_demo/core_services/control_plane.py @@ -2,6 +2,7 @@ import uvicorn from llama_agents import ControlPlaneServer, PipelineOrchestrator +from llama_agents.orchestrators.router import RouterOrchestrator from llama_agents.message_queues.rabbitmq import RabbitMQMessageQueue from llama_index.core.query_pipeline import QueryPipeline, RouterComponent from llama_index.core.selectors import PydanticSingleSelector @@ -40,24 +41,19 @@ time_series_getter_agent_component, ], ) +timeseries_pipeline_orchestrator = PipelineOrchestrator(timeseries_task_pipeline) timeseries_task_pipeline_desc = ( "Only used for getting timeseries data from the database." ) -pipeline = QueryPipeline( - chain=[ - RouterComponent( - selector=PydanticSingleSelector.from_defaults(llm=OpenAI()), - choices=[ - funny_agent_server.description, - timeseries_task_pipeline_desc, - ], - components=[funny_agent_component, timeseries_task_pipeline], - ) - ] -) +general_pipeline = QueryPipeline(chain=[funny_agent_component]) +general_pipeline_orchestrator = PipelineOrchestrator(general_pipeline) -pipeline_orchestrator = PipelineOrchestrator(pipeline) +pipeline_orchestrator = RouterOrchestrator( + selector=PydanticSingleSelector.from_defaults(llm=OpenAI()), + orchestrators=[timeseries_pipeline_orchestrator, general_pipeline_orchestrator], + choices=[timeseries_task_pipeline_desc, funny_agent_server.description], +) # setup control plane control_plane = ControlPlaneServer(