From e17a5fc0fb1d306865d4c3e80e6336fbad212ced Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Sat, 19 Oct 2024 10:31:39 +0200 Subject: [PATCH] fix workflow deployment --- examples/python_fullstack/docker-compose.yml | 7 ++++--- examples/python_fullstack/python_fullstack.yaml | 10 ++++++++-- examples/python_fullstack/workflows/rag_workflow.py | 12 ++++++------ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/examples/python_fullstack/docker-compose.yml b/examples/python_fullstack/docker-compose.yml index 0e55f824..3b3942bc 100644 --- a/examples/python_fullstack/docker-compose.yml +++ b/examples/python_fullstack/docker-compose.yml @@ -38,17 +38,18 @@ services: retries: 5 volumes: - ./:/opt/app + working_dir: /opt/app deploy_workflows: # Init container, it deploys python_fullstack.yaml and exits image: llamaindex/llama-deploy:main volumes: - - ./:/opt/app + - ./python_fullstack.yaml:/opt/python_fullstack.yaml + working_dir: /opt/ depends_on: apiserver: condition: service_healthy - working_dir: /opt/app - entrypoint: llamactl -s http://apiserver:4501 -t 20 deploy python_fullstack.yaml + entrypoint: llamactl -s http://apiserver:4501 -t 30 deploy python_fullstack.yaml frontend: # UI for this deployment, running at http://localhost:3000 diff --git a/examples/python_fullstack/python_fullstack.yaml b/examples/python_fullstack/python_fullstack.yaml index c9d5100d..fafbd440 100644 --- a/examples/python_fullstack/python_fullstack.yaml +++ b/examples/python_fullstack/python_fullstack.yaml @@ -10,12 +10,18 @@ services: name: Agentic Workflow source: type: local - name: . + name: ./workflows path: workflows:agentic_w + python-dependencies: + - llama-index-postprocessor-rankgpt-rerank>=0.2.0 + - llama-index-vector-stores-qdrant>=0.3.0 + - llama-index-llms-openai>=0.2.2 + - llama-index-embeddings-openai>=0.2.4 + - llama-index-readers-file>=0.2.0 rag_workflow: name: RAG Workflow source: type: local - name: . + name: ./workflows path: workflows:rag_w diff --git a/examples/python_fullstack/workflows/rag_workflow.py b/examples/python_fullstack/workflows/rag_workflow.py index 3bae38db..db4d111a 100644 --- a/examples/python_fullstack/workflows/rag_workflow.py +++ b/examples/python_fullstack/workflows/rag_workflow.py @@ -1,25 +1,24 @@ import os from logging import getLogger - -from qdrant_client import QdrantClient, AsyncQdrantClient +from pathlib import Path from llama_index.core import SimpleDirectoryReader, VectorStoreIndex from llama_index.core.node_parser import SemanticSplitterNodeParser, SentenceSplitter from llama_index.core.response_synthesizers import CompactAndRefine +from llama_index.core.schema import NodeWithScore from llama_index.core.workflow import ( Context, Event, - Workflow, StartEvent, StopEvent, + Workflow, step, ) -from llama_index.core.schema import NodeWithScore from llama_index.embeddings.openai import OpenAIEmbedding from llama_index.llms.openai import OpenAI from llama_index.postprocessor.rankgpt_rerank import RankGPTRerank from llama_index.vector_stores.qdrant import QdrantVectorStore - +from qdrant_client import AsyncQdrantClient, QdrantClient logger = getLogger(__name__) @@ -105,8 +104,9 @@ def build_rag_workflow() -> RAGWorkflow: ) # ensure the index exists + here = Path(__file__).parent if not client.collection_exists("papers"): - documents = SimpleDirectoryReader("data").load_data() + documents = SimpleDirectoryReader(here / "data").load_data() # Double pass chunking first_node_parser = SemanticSplitterNodeParser(