Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,8 +3,10 @@
|
|
| 3 |
# =========================
|
| 4 |
from langchain_community.document_loaders import PyPDFLoader
|
| 5 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
from groq import Groq
|
| 9 |
from duckduckgo_search import DDGS
|
| 10 |
import gradio as gr
|
|
@@ -120,9 +122,7 @@ def ask_rag(query):
|
|
| 120 |
def chat(user_message, history):
|
| 121 |
|
| 122 |
response = ask_rag(user_message)
|
| 123 |
-
|
| 124 |
-
history.append({"role": "user", "content": user_message})
|
| 125 |
-
history.append({"role": "assistant", "content": response})
|
| 126 |
|
| 127 |
return history, history
|
| 128 |
|
|
@@ -136,8 +136,7 @@ with gr.Blocks() as app:
|
|
| 136 |
|
| 137 |
file = gr.File(label="Upload PDF")
|
| 138 |
status = gr.Textbox(label="Status")
|
| 139 |
-
|
| 140 |
-
chatbot = gr.Chatbot(type="messages", allow_tags=False)
|
| 141 |
msg = gr.Textbox(placeholder="Ask your question...")
|
| 142 |
state = gr.State([])
|
| 143 |
|
|
|
|
| 3 |
# =========================
|
| 4 |
from langchain_community.document_loaders import PyPDFLoader
|
| 5 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 9 |
+
from langchain_community.vectorstores import Chroma
|
| 10 |
from groq import Groq
|
| 11 |
from duckduckgo_search import DDGS
|
| 12 |
import gradio as gr
|
|
|
|
| 122 |
def chat(user_message, history):
|
| 123 |
|
| 124 |
response = ask_rag(user_message)
|
| 125 |
+
history.append((user_message, response))
|
|
|
|
|
|
|
| 126 |
|
| 127 |
return history, history
|
| 128 |
|
|
|
|
| 136 |
|
| 137 |
file = gr.File(label="Upload PDF")
|
| 138 |
status = gr.Textbox(label="Status")
|
| 139 |
+
chatbot = gr.Chatbot()
|
|
|
|
| 140 |
msg = gr.Textbox(placeholder="Ask your question...")
|
| 141 |
state = gr.State([])
|
| 142 |
|