diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c1f409..a721158 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,8 @@ jobs: run: | cd backend pip install -r requirements.txt + touch .env + echo "DATABASE_PATH=chroma_db \n COLLECTION_NAME=langchain" >> .env - name: Start FastAPI app run: | diff --git a/frontend/.vscode/extensions.json b/.vscode/extensions.json similarity index 100% rename from frontend/.vscode/extensions.json rename to .vscode/extensions.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..2cc09ff --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,15 @@ +{ + "editor.bracketPairColorization.enabled": true, + "editor.guides.bracketPairs": true, + "eslint.validate": ["javascript", "vue", "typescript", "vue"], + + "[python]": { + "editor.defaultFormatter": "ms-python.autopep8", + "editor.formatOnSave": true + }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": ["source.fixAll.eslint"] + } +} diff --git a/backend/embeddings/ingest.py b/backend/embeddings/ingest.py index e80d449..ed4ec2a 100644 --- a/backend/embeddings/ingest.py +++ b/backend/embeddings/ingest.py @@ -5,18 +5,22 @@ # from langchain_core.runnables import RunnablePassthrough # from langchain_core.documents import Document +import os from langchain_community.document_loaders import PyPDFLoader +from langchain_community.embeddings import OllamaEmbeddings from langchain_text_splitters import RecursiveCharacterTextSplitter - from langchain_chroma import Chroma -from langchain_community.embeddings import OllamaEmbeddings -import os -import argparse - import chromadb +from dotenv import load_dotenv + +load_dotenv() -parser = argparse.ArgumentParser(description="Averroes - Chatbot") -parser.add_argument("indexing", type=int, help="indexing") +# Get the path value from .env file +relative_path = os.getenv("DATABASE_PATH") +# Get directory of script +script_dir = os.path.dirname(os.path.abspath(__file__)) +# Append the relative path to the script directory +persist_directory = os.path.join(script_dir, relative_path) def create_vectorstore(): @@ -37,23 +41,25 @@ def create_vectorstore(): documents.extend(document_split) Chroma.from_documents( - collection_name="kardex", + collection_name=os.environ.get("COLLECTION_NAME"), documents=documents, embedding=OllamaEmbeddings(model="mxbai-embed-large"), - persist_directory="./vectorstore/chroma_db", + persist_directory=persist_directory, ) print("vectorstore created...") def get_vectorstore(): - persistent_client = chromadb.PersistentClient(path="./vectorstore/chroma_db") + persistent_client = chromadb.PersistentClient(path=persist_directory) + langchain_chroma = Chroma( client=persistent_client, - collection_name="kardex", + collection_name=os.environ.get("COLLECTION_NAME"), embedding_function=OllamaEmbeddings(model="mxbai-embed-large"), ) - # print("There are", langchain_chroma._collection.count(), "in the collection") + print("There are", langchain_chroma._collection.count(), "in the collection") + # print("There are", langchain_chroma.similarity_search("bmw?")) return langchain_chroma.as_retriever( search_type="mmr", search_kwargs={"k": 3, "lambda_mult": 0.25} diff --git a/frontend/.vscode/settings.json b/frontend/.vscode/settings.json deleted file mode 100644 index b3bb1e4..0000000 --- a/frontend/.vscode/settings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "editor.bracketPairColorization.enabled": true, - "editor.guides.bracketPairs": true, - "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.codeActionsOnSave": [ - "source.fixAll.eslint" - ], - "eslint.validate": [ - "javascript", - "javascriptreact", - "typescript", - "vue" - ] -} \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json index 9d64101..5506cb3 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -2,7 +2,7 @@ "name": "raggi", "version": "0.0.1", "description": "rag app for small business", - "productName": "rag app for small business", + "productName": "Aora Ask, Discover, Decide", "author": "tmeftah ", "private": true, "scripts": { diff --git a/frontend/src/components/EssentialLink.vue b/frontend/src/components/EssentialLink.vue index b02b059..500b101 100644 --- a/frontend/src/components/EssentialLink.vue +++ b/frontend/src/components/EssentialLink.vue @@ -1,6 +1,5 @@