Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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"
|
| 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
|
| 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
|