Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -420,27 +420,6 @@ def clear_cache():
|
|
420 |
processing_status = {"is_processing": False, "progress": 0, "total": 0}
|
421 |
return "Cache cleared successfully.", None
|
422 |
|
423 |
-
def test_single_question(question: str, model_choice: str):
|
424 |
-
"""Test the agent with a single question."""
|
425 |
-
if not question.strip():
|
426 |
-
return "Please enter a question to test."
|
427 |
-
|
428 |
-
# Map model choice to actual model name
|
429 |
-
model_map = {
|
430 |
-
"Llama 3.1 8B": "meta-llama/Llama-3.1-8B-Instruct",
|
431 |
-
"Llama 3.1 70B": "meta-llama/Llama-3.1-70B-Instruct",
|
432 |
-
"Mistral 7B": "mistralai/Mistral-7B-Instruct-v0.3",
|
433 |
-
"CodeLlama 7B": "codellama/CodeLlama-7b-Instruct-hf"
|
434 |
-
}
|
435 |
-
|
436 |
-
selected_model = model_map.get(model_choice, "meta-llama/Llama-3.1-8B-Instruct")
|
437 |
-
|
438 |
-
try:
|
439 |
-
agent = IntelligentAgent(debug=True, model_name=selected_model)
|
440 |
-
answer = agent(question)
|
441 |
-
return f"**Answer using {model_choice}:**\n\n{answer}"
|
442 |
-
except Exception as e:
|
443 |
-
return f"Error testing question: {e}"
|
444 |
|
445 |
# --- Enhanced Gradio Interface ---
|
446 |
with gr.Blocks(title="Intelligent Agent with Conditional Search") as demo:
|
@@ -451,29 +430,6 @@ with gr.Blocks(title="Intelligent Agent with Conditional Search") as demo:
|
|
451 |
gr.LoginButton()
|
452 |
clear_btn = gr.Button("Clear Cache", variant="secondary")
|
453 |
|
454 |
-
with gr.Tab("Test Single Question"):
|
455 |
-
gr.Markdown("### Test the Agent with a Single Question")
|
456 |
-
with gr.Row():
|
457 |
-
test_question = gr.Textbox(
|
458 |
-
label="Enter your question",
|
459 |
-
placeholder="e.g., What is the current weather in Paris? or What is machine learning?",
|
460 |
-
lines=2
|
461 |
-
)
|
462 |
-
test_model = gr.Dropdown(
|
463 |
-
choices=["Llama 3.1 8B", "Llama 3.1 70B", "Mistral 7B", "CodeLlama 7B"],
|
464 |
-
value="Llama 3.1 8B",
|
465 |
-
label="Select Model"
|
466 |
-
)
|
467 |
-
|
468 |
-
test_btn = gr.Button("Test Question", variant="primary")
|
469 |
-
test_result = gr.Textbox(label="Agent Response", lines=10, interactive=False)
|
470 |
-
|
471 |
-
test_btn.click(
|
472 |
-
fn=test_single_question,
|
473 |
-
inputs=[test_question, test_model],
|
474 |
-
outputs=[test_result]
|
475 |
-
)
|
476 |
-
|
477 |
with gr.Tab("Step 1: Fetch Questions"):
|
478 |
gr.Markdown("### Fetch Questions from API")
|
479 |
fetch_btn = gr.Button("Fetch Questions", variant="primary")
|
|
|
420 |
processing_status = {"is_processing": False, "progress": 0, "total": 0}
|
421 |
return "Cache cleared successfully.", None
|
422 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
423 |
|
424 |
# --- Enhanced Gradio Interface ---
|
425 |
with gr.Blocks(title="Intelligent Agent with Conditional Search") as demo:
|
|
|
430 |
gr.LoginButton()
|
431 |
clear_btn = gr.Button("Clear Cache", variant="secondary")
|
432 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
with gr.Tab("Step 1: Fetch Questions"):
|
434 |
gr.Markdown("### Fetch Questions from API")
|
435 |
fetch_btn = gr.Button("Fetch Questions", variant="primary")
|