Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,16 +4,16 @@ import gradio as gr
|
|
| 4 |
|
| 5 |
@function_tool
|
| 6 |
def get_weather(city: str) -> str:
|
| 7 |
-
return f"
|
| 8 |
|
| 9 |
agent = Agent(
|
| 10 |
-
name="
|
| 11 |
-
instructions="
|
| 12 |
-
model="
|
| 13 |
tools=[get_weather],
|
| 14 |
)
|
| 15 |
|
| 16 |
-
#
|
| 17 |
async def chat_fn(user_message, history):
|
| 18 |
context = {"history": history}
|
| 19 |
result = await Runner.run(agent, user_message, context=context)
|
|
@@ -21,7 +21,6 @@ async def chat_fn(user_message, history):
|
|
| 21 |
|
| 22 |
demo = gr.ChatInterface(
|
| 23 |
fn=chat_fn,
|
| 24 |
-
title="Agente Simple con OpenAI Agents SDK",
|
| 25 |
description="Pregunta el clima.",
|
| 26 |
)
|
| 27 |
|
|
|
|
| 4 |
|
| 5 |
@function_tool
|
| 6 |
def get_weather(city: str) -> str:
|
| 7 |
+
return f"El clima en {city} es diferente!"
|
| 8 |
|
| 9 |
agent = Agent(
|
| 10 |
+
name="Agente de ciberseguridad",
|
| 11 |
+
instructions="Siempre responde pensando de forma critica y en tono profesinal, eres un agente de ciberseguridad.",
|
| 12 |
+
model="gpt-4.1-mini",
|
| 13 |
tools=[get_weather],
|
| 14 |
)
|
| 15 |
|
| 16 |
+
# Funci贸n as铆ncrona
|
| 17 |
async def chat_fn(user_message, history):
|
| 18 |
context = {"history": history}
|
| 19 |
result = await Runner.run(agent, user_message, context=context)
|
|
|
|
| 21 |
|
| 22 |
demo = gr.ChatInterface(
|
| 23 |
fn=chat_fn,
|
|
|
|
| 24 |
description="Pregunta el clima.",
|
| 25 |
)
|
| 26 |
|