Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from agent import Agent
|
| 3 |
+
|
| 4 |
+
# Initialize the agent
|
| 5 |
+
agent = Agent("Problem Solver")
|
| 6 |
+
|
| 7 |
+
# Set the persona
|
| 8 |
+
agent.persona = """You are an analytical problem-solving assistant.
|
| 9 |
+
You excel at breaking down complex problems and explaining your thought process.
|
| 10 |
+
You are thorough, logical, and clear in your explanations."""
|
| 11 |
+
|
| 12 |
+
# Set a global instruction
|
| 13 |
+
agent.instruction = "Ensure your responses are clear, detailed, and well-structured."
|
| 14 |
+
|
| 15 |
+
def execute_task(task, strategy):
|
| 16 |
+
"""Execute the given task using the selected strategy."""
|
| 17 |
+
agent.strategy = strategy
|
| 18 |
+
agent.task = task
|
| 19 |
+
response = agent.execute()
|
| 20 |
+
return response
|
| 21 |
+
|
| 22 |
+
# Define available strategies
|
| 23 |
+
strategies = agent.available_strategies()
|
| 24 |
+
|
| 25 |
+
# Create the Gradio interface
|
| 26 |
+
iface = gr.Interface(
|
| 27 |
+
fn=execute_task,
|
| 28 |
+
inputs=[
|
| 29 |
+
gr.inputs.Textbox(lines=5, label="Task"),
|
| 30 |
+
gr.inputs.Dropdown(choices=strategies, label="Strategy")
|
| 31 |
+
],
|
| 32 |
+
outputs=gr.outputs.Textbox(label="Response"),
|
| 33 |
+
title="Problem Solver Agent",
|
| 34 |
+
description="Provide a task and select a strategy to see how the agent responds."
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
if __name__ == "__main__":
|
| 38 |
+
iface.launch()
|