Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,6 @@ import io
|
|
| 10 |
from huggingface_hub import HfApi, login
|
| 11 |
from PyPDF2 import PdfReader
|
| 12 |
from langchain_huggingface import HuggingFaceEmbeddings
|
| 13 |
-
from langchain_community.vectorstores import Chroma
|
| 14 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 15 |
from langchain_groq import ChatGroq
|
| 16 |
from dotenv import load_dotenv
|
|
@@ -246,7 +245,7 @@ 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, persist_directory)
|
| 249 |
-
|
| 250 |
return vectorstore
|
| 251 |
|
| 252 |
# Setup LLM
|
|
@@ -334,8 +333,8 @@ def rag_workflow(query):
|
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
-
kadi_apy_docs = retrieve_within_kadiApy_docs (
|
| 338 |
-
kadi_apy_library_docs = retrieve_within_kadiApy_library (
|
| 339 |
|
| 340 |
doc_context = format_kadi_api_doc_context(kadi_apy_docs)
|
| 341 |
code_context = format_kadi_apy_library_context(kadi_apy_library_docs)
|
|
@@ -391,7 +390,7 @@ def rag_workflow(query):
|
|
| 391 |
|
| 392 |
|
| 393 |
def initialize():
|
| 394 |
-
global
|
| 395 |
|
| 396 |
download_gitlab_project_by_version()
|
| 397 |
#download_gitlab_repo()
|
|
@@ -417,11 +416,11 @@ def initialize():
|
|
| 417 |
#docstore = embed_documents_into_vectorstore(kadiAPY_code_chunks, EMBEDDING_MODEL_NAME, PERSIST_DOC_DIRECTORY)
|
| 418 |
#codestore = embed_documents_into_vectorstore(kadiAPY_doc_chunks, EMBEDDING_MODEL_NAME, PERSIST_CODE_DIRECTORY)
|
| 419 |
|
| 420 |
-
embed_documents_into_vectorstore(
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
|
| 426 |
llm = setup_llm(LLM_MODEL_NAME, LLM_TEMPERATURE, GROQ_API_KEY)
|
| 427 |
|
|
|
|
| 10 |
from huggingface_hub import HfApi, login
|
| 11 |
from PyPDF2 import PdfReader
|
| 12 |
from langchain_huggingface import HuggingFaceEmbeddings
|
|
|
|
| 13 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 14 |
from langchain_groq import ChatGroq
|
| 15 |
from dotenv import load_dotenv
|
|
|
|
| 245 |
print("Start setup_vectorstore_function")
|
| 246 |
embedding_model = HuggingFaceEmbeddings(model_name=model_name)
|
| 247 |
vectorstore = get_chroma_vectorstore(embedding_model, persist_directory)
|
| 248 |
+
vector_store.add_documents(chunks)
|
| 249 |
return vectorstore
|
| 250 |
|
| 251 |
# Setup LLM
|
|
|
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
+
kadi_apy_docs = retrieve_within_kadiApy_docs (vectorstore, query, k = 5)
|
| 337 |
+
kadi_apy_library_docs = retrieve_within_kadiApy_library (vectorstore, query, k = 10)
|
| 338 |
|
| 339 |
doc_context = format_kadi_api_doc_context(kadi_apy_docs)
|
| 340 |
code_context = format_kadi_apy_library_context(kadi_apy_library_docs)
|
|
|
|
| 390 |
|
| 391 |
|
| 392 |
def initialize():
|
| 393 |
+
global vectore_store, chunks, llm
|
| 394 |
|
| 395 |
download_gitlab_project_by_version()
|
| 396 |
#download_gitlab_repo()
|
|
|
|
| 416 |
#docstore = embed_documents_into_vectorstore(kadiAPY_code_chunks, EMBEDDING_MODEL_NAME, PERSIST_DOC_DIRECTORY)
|
| 417 |
#codestore = embed_documents_into_vectorstore(kadiAPY_doc_chunks, EMBEDDING_MODEL_NAME, PERSIST_CODE_DIRECTORY)
|
| 418 |
|
| 419 |
+
vectorstore = embed_documents_into_vectorstore(
|
| 420 |
+
chunks=kadiAPY_code_chunks + kadiAPY_doc_chunks,
|
| 421 |
+
model_name= EMBEDDING_MODEL_NAME,
|
| 422 |
+
persist_directory= PERSIST_DOC_DIRECTORY
|
| 423 |
+
)
|
| 424 |
|
| 425 |
llm = setup_llm(LLM_MODEL_NAME, LLM_TEMPERATURE, GROQ_API_KEY)
|
| 426 |
|