Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,6 +17,7 @@ from dotenv import load_dotenv
|
|
| 17 |
from langchain.docstore.document import Document
|
| 18 |
from langchain.schema import Document
|
| 19 |
from chunk_python_code import chunk_python_code_with_metadata
|
|
|
|
| 20 |
|
| 21 |
# Load environment variables from .env file
|
| 22 |
load_dotenv()
|
|
@@ -241,16 +242,13 @@ def split_into_chunks(texts, references, chunk_size, chunk_overlap):
|
|
| 241 |
return chunks
|
| 242 |
|
| 243 |
# Setup Vectorstore
|
| 244 |
-
def
|
| 245 |
print("Start setup_vectorstore_function")
|
| 246 |
embedding_model = HuggingFaceEmbeddings(model_name=model_name)
|
| 247 |
-
vectorstore =
|
|
|
|
| 248 |
return vectorstore
|
| 249 |
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
# Setup LLM
|
| 255 |
def setup_llm(model_name, temperature, api_key):
|
| 256 |
llm = ChatGroq(model=model_name, temperature=temperature, api_key=api_key)
|
|
@@ -365,8 +363,8 @@ def initialize():
|
|
| 365 |
print(f"Total number of code_chunks: {len(kadiAPY_code_chunks)}")
|
| 366 |
print(f"Total number of doc_chunks: {len(kadiAPY_doc_chunks)}")
|
| 367 |
|
| 368 |
-
docstore =
|
| 369 |
-
codestore =
|
| 370 |
|
| 371 |
llm = setup_llm(LLM_MODEL_NAME, LLM_TEMPERATURE, GROQ_API_KEY)
|
| 372 |
|
|
|
|
| 17 |
from langchain.docstore.document import Document
|
| 18 |
from langchain.schema import Document
|
| 19 |
from chunk_python_code import chunk_python_code_with_metadata
|
| 20 |
+
from vectorstore.py import get_chroma_vectorstore
|
| 21 |
|
| 22 |
# Load environment variables from .env file
|
| 23 |
load_dotenv()
|
|
|
|
| 242 |
return chunks
|
| 243 |
|
| 244 |
# Setup Vectorstore
|
| 245 |
+
def embed_documents_into_vectorstore(chunks, model_name, persist_directory):
|
| 246 |
print("Start setup_vectorstore_function")
|
| 247 |
embedding_model = HuggingFaceEmbeddings(model_name=model_name)
|
| 248 |
+
vectorstore = get_chroma_vectorstore(embedding_model)
|
| 249 |
+
vectorstore.add_documents(chunks)
|
| 250 |
return vectorstore
|
| 251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
# Setup LLM
|
| 253 |
def setup_llm(model_name, temperature, api_key):
|
| 254 |
llm = ChatGroq(model=model_name, temperature=temperature, api_key=api_key)
|
|
|
|
| 363 |
print(f"Total number of code_chunks: {len(kadiAPY_code_chunks)}")
|
| 364 |
print(f"Total number of doc_chunks: {len(kadiAPY_doc_chunks)}")
|
| 365 |
|
| 366 |
+
docstore = embed_documents_into_vectorstore(kadiAPY_code_chunks, EMBEDDING_MODEL_NAME, PERSIST_DOC_DIRECTORY)
|
| 367 |
+
codestore = embed_documents_into_vectorstore(kadiAPY_doc_chunks, EMBEDDING_MODEL_NAME, PERSIST_CODE_DIRECTORY)
|
| 368 |
|
| 369 |
llm = setup_llm(LLM_MODEL_NAME, LLM_TEMPERATURE, GROQ_API_KEY)
|
| 370 |
|