Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -549,49 +549,52 @@ with gr.Blocks(title="Archaeological Query Engine") as app:
|
|
| 549 |
)
|
| 550 |
|
| 551 |
# Add new tab for AI-generated answers using Groq API
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
|
|
|
|
|
|
|
|
|
| 595 |
# Function to handle the Generate Answer button click
|
| 596 |
def on_generate_answer(city, question, max_sources, temperature):
|
| 597 |
if not question or not question.strip():
|
|
|
|
| 549 |
)
|
| 550 |
|
| 551 |
# Add new tab for AI-generated answers using Groq API
|
| 552 |
+
with gr.TabItem("AI Answers (Groq API)"):
|
| 553 |
+
gr.Markdown("Ask questions about the dataset and get AI-generated answers using the Groq API with the deepseek-r1-distill-llama-70b model.")
|
| 554 |
+
|
| 555 |
+
with gr.Row():
|
| 556 |
+
with gr.Column():
|
| 557 |
+
# API key is now hardcoded in the code
|
| 558 |
+
|
| 559 |
+
ai_city_dropdown = gr.Dropdown(
|
| 560 |
+
choices=city_names,
|
| 561 |
+
value=city_names[0] if city_names else None,
|
| 562 |
+
label="Select City"
|
| 563 |
+
)
|
| 564 |
+
|
| 565 |
+
question_input = gr.Textbox(
|
| 566 |
+
label="Ask a Question",
|
| 567 |
+
placeholder="E.g., What was the historical significance of this ancient city?",
|
| 568 |
+
lines=3
|
| 569 |
+
)
|
| 570 |
+
|
| 571 |
+
max_sources_slider = gr.Slider(
|
| 572 |
+
minimum=1,
|
| 573 |
+
maximum=10,
|
| 574 |
+
value=3,
|
| 575 |
+
step=1,
|
| 576 |
+
label="Maximum Number of Sources to Consider",
|
| 577 |
+
info="Higher values may provide more comprehensive answers but will take longer"
|
| 578 |
+
)
|
| 579 |
+
|
| 580 |
+
temperature_slider = gr.Slider(
|
| 581 |
+
minimum=0.0,
|
| 582 |
+
maximum=1.0,
|
| 583 |
+
value=0.3,
|
| 584 |
+
step=0.1,
|
| 585 |
+
label="Temperature",
|
| 586 |
+
info="Lower values create more focused answers, higher values create more creative ones"
|
| 587 |
+
)
|
| 588 |
+
|
| 589 |
+
generate_button = gr.Button("Generate Answer")
|
| 590 |
+
|
| 591 |
+
with gr.Column():
|
| 592 |
+
answer_output = gr.HTML(
|
| 593 |
+
label="AI-Generated Answer",
|
| 594 |
+
value="",
|
| 595 |
+
elem_classes=["results-output"]
|
| 596 |
+
)
|
| 597 |
+
|
| 598 |
# Function to handle the Generate Answer button click
|
| 599 |
def on_generate_answer(city, question, max_sources, temperature):
|
| 600 |
if not question or not question.strip():
|