superbsaeed commited on
Commit
6440595
Β·
verified Β·
1 Parent(s): bf36420

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -29,7 +29,6 @@ def format_docs(docs):
29
  )
30
 
31
  def build_chain(groq_api_key: str):
32
- """Build the LCEL RAG chain with the provided Groq key."""
33
  llm = ChatGroq(
34
  api_key=groq_api_key,
35
  model="llama-3.3-70b-versatile",
@@ -139,8 +138,8 @@ def clear_all():
139
  retrieved_docs = {}
140
  return [], "", "πŸ—‘οΈ Cleared. Upload a new PDF to start again."
141
 
142
- # ── Gradio UI ─────────────────────────────────────────────────
143
- with gr.Blocks(title="PDF RAG Chatbot", theme=gr.themes.Soft()) as demo:
144
 
145
  gr.Markdown("""
146
  # πŸ“š PDF RAG Chatbot
@@ -153,7 +152,8 @@ with gr.Blocks(title="PDF RAG Chatbot", theme=gr.themes.Soft()) as demo:
153
  groq_key_box = gr.Textbox(
154
  label="Groq API Key",
155
  placeholder="gsk_...",
156
- type="password"
 
157
  )
158
  pdf_upload = gr.File(
159
  label="Upload PDF",
@@ -164,7 +164,7 @@ with gr.Blocks(title="PDF RAG Chatbot", theme=gr.themes.Soft()) as demo:
164
 
165
  with gr.Column(scale=2):
166
  gr.Markdown("### πŸ’¬ Chat")
167
- chatbot = gr.Chatbot(height=480, bubble_full_width=False)
168
  with gr.Row():
169
  question_box = gr.Textbox(
170
  placeholder="Ask a question about your PDF...",
@@ -195,4 +195,4 @@ with gr.Blocks(title="PDF RAG Chatbot", theme=gr.themes.Soft()) as demo:
195
  outputs=[chatbot, question_box, status_box]
196
  )
197
 
198
- demo.launch()
 
29
  )
30
 
31
  def build_chain(groq_api_key: str):
 
32
  llm = ChatGroq(
33
  api_key=groq_api_key,
34
  model="llama-3.3-70b-versatile",
 
138
  retrieved_docs = {}
139
  return [], "", "πŸ—‘οΈ Cleared. Upload a new PDF to start again."
140
 
141
+ # ── Gradio UI (Gradio 6 compatible) ──────────────────────────
142
+ with gr.Blocks(title="PDF RAG Chatbot") as demo: # ← theme removed from here
143
 
144
  gr.Markdown("""
145
  # πŸ“š PDF RAG Chatbot
 
152
  groq_key_box = gr.Textbox(
153
  label="Groq API Key",
154
  placeholder="gsk_...",
155
+ type="password",
156
+ value=os.environ.get("GROQ_API_KEY", "")
157
  )
158
  pdf_upload = gr.File(
159
  label="Upload PDF",
 
164
 
165
  with gr.Column(scale=2):
166
  gr.Markdown("### πŸ’¬ Chat")
167
+ chatbot = gr.Chatbot(height=480) # ← bubble_full_width removed
168
  with gr.Row():
169
  question_box = gr.Textbox(
170
  placeholder="Ask a question about your PDF...",
 
195
  outputs=[chatbot, question_box, status_box]
196
  )
197
 
198
+ demo.launch(theme=gr.themes.Soft()) # ← theme moved here