Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import datetime
|
| 2 |
import pytz
|
|
|
|
| 3 |
|
| 4 |
# Define tools
|
| 5 |
def combine_string_and_number(text: str, number: int) -> str:
|
|
@@ -42,16 +43,21 @@ class MyFirstAgent:
|
|
| 42 |
else:
|
| 43 |
return "Sorry, I only understand 'combine <text> and <number>' or 'time in <timezone>'"
|
| 44 |
|
| 45 |
-
# Create
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
if __name__ == "__main__":
|
| 47 |
-
|
| 48 |
-
print("Welcome to My First Agent!")
|
| 49 |
-
print("Try commands like 'combine hello and 42' or 'time in America/New_York'")
|
| 50 |
-
print("Type 'quit' to exit")
|
| 51 |
-
while True:
|
| 52 |
-
query = input("Enter your command: ")
|
| 53 |
-
if query.lower() == "quit":
|
| 54 |
-
print("Goodbye!")
|
| 55 |
-
break
|
| 56 |
-
response = agent.run(query)
|
| 57 |
-
print("Response:", response)
|
|
|
|
| 1 |
import datetime
|
| 2 |
import pytz
|
| 3 |
+
import gradio as gr
|
| 4 |
|
| 5 |
# Define tools
|
| 6 |
def combine_string_and_number(text: str, number: int) -> str:
|
|
|
|
| 43 |
else:
|
| 44 |
return "Sorry, I only understand 'combine <text> and <number>' or 'time in <timezone>'"
|
| 45 |
|
| 46 |
+
# Create agent
|
| 47 |
+
agent = MyFirstAgent()
|
| 48 |
+
|
| 49 |
+
# Define Gradio interface function
|
| 50 |
+
def run_agent(query: str) -> str:
|
| 51 |
+
return agent.run(query)
|
| 52 |
+
|
| 53 |
+
# Create and launch Gradio interface
|
| 54 |
+
interface = gr.Interface(
|
| 55 |
+
fn=run_agent,
|
| 56 |
+
inputs=gr.Textbox(label="Enter your command", placeholder="e.g., combine hello and 42 or time in America/New_York"),
|
| 57 |
+
outputs=gr.Textbox(label="Agent Response"),
|
| 58 |
+
title="My First Agent",
|
| 59 |
+
description="Try commands like 'combine hello and 42' or 'time in America/New_York'"
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
if __name__ == "__main__":
|
| 63 |
+
interface.launch(server_port=7860, share=False, quiet=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|