Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,7 @@ token=""
|
|
| 16 |
repo_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 17 |
emb = "sentence-transformers/all-mpnet-base-v2"
|
| 18 |
hf = HuggingFaceEmbeddings(model_name=emb)
|
| 19 |
-
db = Chroma(
|
| 20 |
#db.persist()
|
| 21 |
# Load the document, split it into chunks, embed each chunk and load it into the vector store.
|
| 22 |
#raw_documents = TextLoader('state_of_the_union.txt').load()
|
|
@@ -25,7 +25,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)
|
| 29 |
|
| 30 |
def proc_doc(doc_in):
|
| 31 |
for doc in doc_in:
|
|
@@ -60,7 +60,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)
|
| 64 |
|
| 65 |
print(docs)
|
| 66 |
except Exception as e:
|
|
|
|
| 16 |
repo_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 17 |
emb = "sentence-transformers/all-mpnet-base-v2"
|
| 18 |
hf = HuggingFaceEmbeddings(model_name=emb)
|
| 19 |
+
db = Chroma()
|
| 20 |
#db.persist()
|
| 21 |
# Load the document, split it into chunks, embed each chunk and load it into the vector store.
|
| 22 |
#raw_documents = TextLoader('state_of_the_union.txt').load()
|
|
|
|
| 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="./chroma_langchain_db",embedding_function=HuggingFaceEmbeddings(model_name=emb))
|
| 29 |
|
| 30 |
def proc_doc(doc_in):
|
| 31 |
for doc in doc_in:
|
|
|
|
| 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="./chroma_langchain_db",embedding_function=HuggingFaceEmbeddings(model_name=emb))
|
| 64 |
|
| 65 |
print(docs)
|
| 66 |
except Exception as e:
|