Spaces:
Sleeping
Sleeping
Commit
·
7232b90
1
Parent(s):
d2237c8
adding chatbot with advanced options
Browse files
app.py
CHANGED
@@ -65,22 +65,19 @@ def document_loader(file_path,api_key,doc_type='pdf',llm='Huggingface',temperatu
|
|
65 |
|
66 |
print("Document :",document)
|
67 |
embedding_model = SentenceTransformerEmbeddings(model_name='thenlper/gte-base',model_kwargs={"device": DEVICE})
|
|
|
|
|
|
|
68 |
global qa
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
max_tokens=max_tokens),
|
76 |
-
chain_type='stuff',
|
77 |
-
retriever=vector_db.as_retriever(),
|
78 |
# chain_type_kwargs=chain_type_kwargs,
|
79 |
return_source_documents=True
|
80 |
-
|
81 |
-
except:
|
82 |
-
return "Error in loading Documents "
|
83 |
-
|
84 |
return "Document Processing completed ..."
|
85 |
|
86 |
|
|
|
65 |
|
66 |
print("Document :",document)
|
67 |
embedding_model = SentenceTransformerEmbeddings(model_name='thenlper/gte-base',model_kwargs={"device": DEVICE})
|
68 |
+
|
69 |
+
texts = process_documents(documents=document)
|
70 |
+
vector_db = FAISS.from_documents(documents=texts, embedding= embedding_model)
|
71 |
global qa
|
72 |
+
qa = RetrievalQA.from_chain_type(llm=chat_application(llm_service=llm,key=api_key,
|
73 |
+
temperature=temperature,
|
74 |
+
max_tokens=max_tokens
|
75 |
+
),
|
76 |
+
chain_type='stuff',
|
77 |
+
retriever=vector_db.as_retriever(),
|
|
|
|
|
|
|
78 |
# chain_type_kwargs=chain_type_kwargs,
|
79 |
return_source_documents=True
|
80 |
+
)
|
|
|
|
|
|
|
81 |
return "Document Processing completed ..."
|
82 |
|
83 |
|