Spaces:
Sleeping
Sleeping
File size: 1,439 Bytes
890d952 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import asyncio
from agents import Runner, trace, gen_trace_id
from port_recomendations import port_recommendations_agent
async def get_port_recommendation(query: str):
"""Get port recommendations using the specialized agent"""
trace_id = gen_trace_id()
with trace("Port Recommendation", trace_id=trace_id):
print(f"View trace: https://platform.openai.com/traces/trace?trace_id={trace_id}")
try:
result = await Runner.run(
port_recommendations_agent,
f"Query: {query}",
max_turns=5,
)
return result.final_output
except Exception as e:
print(f"Error during port recommendation: {e}")
return f"An error occurred: {str(e)}"
async def main():
"""Test the port recommendations agent with various queries"""
test_queries = [
"I need an unused port",
"I need an unused port without redundancy",
"I need to dual connect a server to the network, what ports should I use?",
"What ports are available on leaf01?",
"I need 4 ports for a new switch connection"
]
for query in test_queries:
print(f"\n{'='*60}")
print(f"Query: {query}")
print(f"{'='*60}")
result = await get_port_recommendation(query)
print(f"Recommendation: {result}")
print()
if __name__ == "__main__":
asyncio.run(main())
|