Handle the Error Messages

#5
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -2,14 +2,13 @@ import gradio as gr
2
  import os
3
  import tempfile
4
  from typing import List
5
-
6
  import PyPDF2
7
  from sentence_transformers import SentenceTransformer
8
  import numpy as np
9
  from sklearn.metrics.pairwise import cosine_similarity
10
 
11
  from groq import Groq
12
-
13
  # -----------------------------
14
  # Configuration
15
  # -----------------------------
@@ -141,14 +140,13 @@ with gr.Blocks(title="Enhanced RAG Chatbot") as demo:
141
  gr.Markdown("## 📚 Enhanced RAG-Based Chatbot (PDF QA)")
142
  gr.Markdown("Upload multiple PDFs and ask questions based on their content.")
143
 
144
- with gr.Row():
145
- pdf_files = gr.File(
146
- label="Upload PDF Files",
147
- file_types=[".pdf"],
148
- file_count="multiple"
149
- )
150
 
151
- chatbot = gr.Chatbot()
152
  question = gr.Textbox(label="Ask a question")
153
  state = gr.State([])
154
 
@@ -160,4 +158,5 @@ with gr.Blocks(title="Enhanced RAG Chatbot") as demo:
160
  outputs=[chatbot, chatbot]
161
  )
162
 
 
163
  demo.launch()
 
2
  import os
3
  import tempfile
4
  from typing import List
 
5
  import PyPDF2
6
  from sentence_transformers import SentenceTransformer
7
  import numpy as np
8
  from sklearn.metrics.pairwise import cosine_similarity
9
 
10
  from groq import Groq
11
+ embedder = SentenceTransformer("all-MiniLM-L6-v2")
12
  # -----------------------------
13
  # Configuration
14
  # -----------------------------
 
140
  gr.Markdown("## 📚 Enhanced RAG-Based Chatbot (PDF QA)")
141
  gr.Markdown("Upload multiple PDFs and ask questions based on their content.")
142
 
143
+ pdf_files = gr.File(
144
+ label="Upload PDF Files",
145
+ file_types=[".pdf"],
146
+ file_count="multiple"
147
+ )
 
148
 
149
+ chatbot = gr.Chatbot(type="messages")
150
  question = gr.Textbox(label="Ask a question")
151
  state = gr.State([])
152
 
 
158
  outputs=[chatbot, chatbot]
159
  )
160
 
161
+
162
  demo.launch()