Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,8 @@ from langchain_core.documents import Document
|
|
| 10 |
from langchain_text_splitters import CharacterTextSplitter
|
| 11 |
from pypdf import PdfReader
|
| 12 |
import random
|
| 13 |
-
|
|
|
|
| 14 |
token=""
|
| 15 |
#repo_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
| 16 |
repo_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
|
@@ -25,7 +26,7 @@ def embed_fn(inp):
|
|
| 25 |
documents = text_splitter.split_text(inp)
|
| 26 |
out_emb= hf.embed_documents(documents)
|
| 27 |
string_representation = dumps(out_emb, pretty=True)
|
| 28 |
-
db.from_texts(documents,persist_directory="
|
| 29 |
|
| 30 |
def proc_doc(doc_in):
|
| 31 |
for doc in doc_in:
|
|
@@ -60,7 +61,7 @@ def run_llm(input_text,history):
|
|
| 60 |
MAX_TOKENS=20000
|
| 61 |
try:
|
| 62 |
qur= hf.embed_query(input_text)
|
| 63 |
-
docs = db.similarity_search_by_vector(qur, k=3,persist_directory="
|
| 64 |
|
| 65 |
print(docs)
|
| 66 |
except Exception as e:
|
|
|
|
| 10 |
from langchain_text_splitters import CharacterTextSplitter
|
| 11 |
from pypdf import PdfReader
|
| 12 |
import random
|
| 13 |
+
cwd = os.getcwd()
|
| 14 |
+
print(cwd)
|
| 15 |
token=""
|
| 16 |
#repo_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
| 17 |
repo_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
|
|
|
| 26 |
documents = text_splitter.split_text(inp)
|
| 27 |
out_emb= hf.embed_documents(documents)
|
| 28 |
string_representation = dumps(out_emb, pretty=True)
|
| 29 |
+
db.from_texts(documents,persist_directory=f"{cwd}/chroma_langchain_db",embedding_function=HuggingFaceEmbeddings(model_name=emb))
|
| 30 |
|
| 31 |
def proc_doc(doc_in):
|
| 32 |
for doc in doc_in:
|
|
|
|
| 61 |
MAX_TOKENS=20000
|
| 62 |
try:
|
| 63 |
qur= hf.embed_query(input_text)
|
| 64 |
+
docs = db.similarity_search_by_vector(qur, k=3,persist_directory=f"{cwd}/chroma_langchain_db",embedding_function=HuggingFaceEmbeddings(model_name=emb))
|
| 65 |
|
| 66 |
print(docs)
|
| 67 |
except Exception as e:
|