diff --git a/main.py b/main.py index b7eda2f..002e1ee 100644 --- a/main.py +++ b/main.py @@ -14,7 +14,7 @@ from utils import get_last_user_message, stream_message_template from schemas import OpenAIChatCompletionForm from config import MODEL_ID, MODEL_NAME -from pipelines.examples.llamaindex_ollama_github_pipeline import ( +from pipelines.pipeline import ( get_response, on_startup, on_shutdown, diff --git a/pipelines/examples/llamaindex_ollama_pipeline.py b/pipelines/examples/llamaindex_ollama_pipeline.py index c20f41c..43eb09d 100644 --- a/pipelines/examples/llamaindex_ollama_pipeline.py +++ b/pipelines/examples/llamaindex_ollama_pipeline.py @@ -3,7 +3,8 @@ from schemas import OpenAIChatMessage from llama_index.embeddings.ollama import OllamaEmbedding from llama_index.llms.ollama import Ollama -from llama_index.core import Settings +from llama_index.core import Settings, VectorStoreIndex, SimpleDirectoryReader + Settings.embed_model = OllamaEmbedding( model_name="nomic-embed-text", @@ -11,10 +12,9 @@ Settings.embed_model = OllamaEmbedding( ) Settings.llm = Ollama(model="llama3") -from llama_index.core import VectorStoreIndex, SimpleDirectoryReader -documents = SimpleDirectoryReader("./data").load_data() -index = VectorStoreIndex.from_documents(documents) +documents = None +index = None def get_response( @@ -34,6 +34,11 @@ def get_response( async def on_startup(): # This function is called when the server is started. + global documents, index + + documents = SimpleDirectoryReader("./data").load_data() + index = VectorStoreIndex.from_documents(documents) + pass