|
import gradio as gr |
|
from gaia_agent import GAIAExpertAgent |
|
from evaluation_runner import EvaluationRunner |
|
|
|
|
|
agent = GAIAExpertAgent(model_name="google/flan-t5-large") |
|
runner = EvaluationRunner() |
|
|
|
def run_evaluation(username: str, agent_code: str): |
|
"""Основная функция для запуска оценки""" |
|
try: |
|
result, correct, total, df = runner.run_evaluation( |
|
agent=agent, |
|
username=username, |
|
agent_code=agent_code |
|
) |
|
return result, correct, total, df |
|
except Exception as e: |
|
return f"Error: {str(e)}", 0, 0, None |
|
|
|
|
|
with gr.Blocks(title="GAIA Agent Evaluation") as demo: |
|
gr.Markdown("# 🏆 GAIA Agent Certification") |
|
|
|
with gr.Row(): |
|
with gr.Column(): |
|
gr.Markdown("### Configuration") |
|
username = gr.Textbox( |
|
label="Hugging Face Username", |
|
value="yoshizen" |
|
) |
|
agent_code = gr.Textbox( |
|
label="Agent Code", |
|
value="https://huggingface.co/spaces/yoshizen/FinalTest" |
|
) |
|
run_btn = gr.Button("Run Evaluation", variant="primary") |
|
|
|
with gr.Column(): |
|
gr.Markdown("### Results") |
|
result_output = gr.Textbox(label="Status") |
|
correct_output = gr.Number(label="Correct Answers") |
|
total_output = gr.Number(label="Total Questions") |
|
results_table = gr.Dataframe(label="Details") |
|
|
|
run_btn.click( |
|
fn=run_evaluation, |
|
inputs=[username, agent_code], |
|
outputs=[result_output, correct_output, total_output, results_table] |
|
) |
|
|
|
if __name__ == "__main__": |
|
demo.launch( |
|
server_name="0.0.0.0", |
|
server_port=7860, |
|
share=False |
|
) |