diff --git a/application/api/answer/routes.py b/application/api/answer/routes.py index 3f48d33..b694c4a 100644 --- a/application/api/answer/routes.py +++ b/application/api/answer/routes.py @@ -118,6 +118,8 @@ def complete_stream(question, docsearch, chat_history, api_key, conversation_id) docs = docsearch.search(question, k=2) + if settings.LLM_NAME == "llama.cpp": + docs = [docs[0]] # join all page_content together with a newline docs_together = "\n".join([doc.page_content for doc in docs]) p_chat_combine = chat_combine_template.replace("{summaries}", docs_together) diff --git a/application/core/settings.py b/application/core/settings.py index 57a9f1c..a05fd00 100644 --- a/application/core/settings.py +++ b/application/core/settings.py @@ -2,7 +2,7 @@ from pathlib import Path import os from pydantic import BaseSettings -current_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +current_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) class Settings(BaseSettings): diff --git a/application/llm/llama_cpp.py b/application/llm/llama_cpp.py index ebd713c..f18d437 100644 --- a/application/llm/llama_cpp.py +++ b/application/llm/llama_cpp.py @@ -1,15 +1,16 @@ from application.llm.base import BaseLLM +from application.core.settings import settings class LlamaCpp(BaseLLM): - def __init__(self, api_key, llm_name='/Users/pavel/Desktop/docsgpt/application/models/orca-test.bin'): + def __init__(self, api_key, llm_name=settings.MODEL_PATH, **kwargs): global llama try: from llama_cpp import Llama except ImportError: raise ImportError("Please install llama_cpp using pip install llama-cpp-python") - llama = Llama(model_path=llm_name) + llama = Llama(model_path=llm_name, n_ctx=2048) def gen(self, model, engine, messages, stream=False, **kwargs): context = messages[0]['content'] diff --git a/docker-compose-local.yaml b/docker-compose-local.yaml index b24ed48..3aebe8b 100644 --- a/docker-compose-local.yaml +++ b/docker-compose-local.yaml @@ -6,42 +6,10 @@ services: environment: - VITE_API_HOST=http://localhost:7091 - VITE_API_STREAMING=$VITE_API_STREAMING + - VITE_EMBEDDINGS_NAME=$EMBEDDINGS_NAME ports: - "5173:5173" - # backend: - # build: ./application - # environment: - # - LLM_NAME=$LLM_NAME - # - EMBEDDINGS_NAME=$EMBEDDINGS_NAME - # - CELERY_BROKER_URL=redis://redis:6379/0 - # - CELERY_RESULT_BACKEND=redis://redis:6379/1 - # - MONGO_URI=mongodb://mongo:27017/docsgpt - # ports: - # - "7091:7091" - # volumes: - # - ./application/indexes:/app/application/indexes - # - ./application/inputs:/app/application/inputs - # - ./application/vectors:/app/application/vectors - # - ./application/models:/app/application/models - # depends_on: - # - redis - # - mongo - - worker: - build: ./application - command: celery -A application.app.celery worker -l INFO - environment: - - LLM_NAME=$LLM_NAME - - EMBEDDINGS_NAME=$EMBEDDINGS_NAME - - CELERY_BROKER_URL=redis://redis:6379/0 - - CELERY_RESULT_BACKEND=redis://redis:6379/1 - - MONGO_URI=mongodb://mongo:27017/docsgpt - - API_URL=http://backend:7091 - depends_on: - - redis - - mongo - redis: image: redis:6-alpine ports: diff --git a/frontend/src/Navigation.tsx b/frontend/src/Navigation.tsx index c5488a5..9f84b97 100644 --- a/frontend/src/Navigation.tsx +++ b/frontend/src/Navigation.tsx @@ -59,6 +59,7 @@ export default function Navigation({ const navRef = useRef(null); const apiHost = import.meta.env.VITE_API_HOST || 'https://docsapi.arc53.com'; + const embeddingsName = import.meta.env.VITE_EMBEDDINGS_NAME || 'openai_text-embedding-ada-002'; useEffect(() => { if (!conversations) { @@ -253,7 +254,7 @@ export default function Navigation({
{docs ? ( docs.map((doc, index) => { - if (doc.model === 'openai_text-embedding-ada-002') { + if (doc.model === embeddingsName) { return (