Spaces:
Runtime error
Runtime error
Gokulnath2003
commited on
Commit
•
85a72e5
1
Parent(s):
e28718b
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
|
|
|
|
3 |
|
4 |
from langchain_community.document_loaders import PyPDFLoader
|
5 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
6 |
from langchain_community.vectorstores import Chroma
|
7 |
from langchain.chains import ConversationalRetrievalChain
|
8 |
-
from langchain_community.embeddings import HuggingFaceEmbeddings
|
9 |
from langchain_community.llms import HuggingFaceEndpoint
|
10 |
-
|
11 |
-
from pathlib import Path
|
12 |
import chromadb
|
13 |
from unidecode import unidecode
|
14 |
|
@@ -120,7 +120,7 @@ def conversation(qa_chain, message, history):
|
|
120 |
response_sources = response["source_documents"]
|
121 |
new_history = history + [(message, response_answer)]
|
122 |
response_details = [(src.page_content.strip(), src.metadata["page"] + 1) for src in response_sources[:3]]
|
123 |
-
return
|
124 |
|
125 |
# Gradio Interface
|
126 |
def demo():
|
@@ -164,7 +164,7 @@ def demo():
|
|
164 |
# Define Interactions
|
165 |
db_btn.click(initialize_database, inputs=[document, slider_chunk_size, slider_chunk_overlap], outputs=[vector_db, collection_name, db_progress])
|
166 |
qachain_btn.click(initialize_LLM, inputs=[llm_btn, slider_temperature, slider_maxtokens, slider_topk, vector_db], outputs=[qa_chain, llm_progress])
|
167 |
-
msg.submit(conversation, inputs=[qa_chain, msg, chatbot], outputs=[
|
168 |
|
169 |
demo.launch(debug=True)
|
170 |
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
import re
|
4 |
+
from pathlib import Path
|
5 |
|
6 |
from langchain_community.document_loaders import PyPDFLoader
|
7 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
8 |
from langchain_community.vectorstores import Chroma
|
9 |
from langchain.chains import ConversationalRetrievalChain
|
10 |
+
from langchain_community.embeddings import HuggingFaceEmbeddings
|
11 |
from langchain_community.llms import HuggingFaceEndpoint
|
|
|
|
|
12 |
import chromadb
|
13 |
from unidecode import unidecode
|
14 |
|
|
|
120 |
response_sources = response["source_documents"]
|
121 |
new_history = history + [(message, response_answer)]
|
122 |
response_details = [(src.page_content.strip(), src.metadata["page"] + 1) for src in response_sources[:3]]
|
123 |
+
return gr.update(value=""), new_history, *sum(response_details, ())
|
124 |
|
125 |
# Gradio Interface
|
126 |
def demo():
|
|
|
164 |
# Define Interactions
|
165 |
db_btn.click(initialize_database, inputs=[document, slider_chunk_size, slider_chunk_overlap], outputs=[vector_db, collection_name, db_progress])
|
166 |
qachain_btn.click(initialize_LLM, inputs=[llm_btn, slider_temperature, slider_maxtokens, slider_topk, vector_db], outputs=[qa_chain, llm_progress])
|
167 |
+
msg.submit(conversation, inputs=[qa_chain, msg, chatbot], outputs=[msg, chatbot] + [None] * 6)
|
168 |
|
169 |
demo.launch(debug=True)
|
170 |
|