Spaces:
Sleeping
Sleeping
| import asyncio | |
| from agents import Agent, ItemHelpers, MessageOutputItem, Runner, trace | |
| from agents import Agent, Runner, function_tool | |
| import asyncio | |
| import os | |
| import dotenv | |
| from agents import Agent, ModelSettings, function_tool , Runner | |
| def vector_db_agent_tool(query: str) -> str: | |
| print("vector_db_agent(query)") | |
| def neo4j_agent_tool(query: str) -> str: | |
| print("neo4j_agent(query)") | |
| # async def main(): | |
| # result = await Runner.run( | |
| # Dataframe_agent, | |
| # "so analayse the df and give some insights on it", | |
| # ) | |
| # print(result) | |
| # if __name__ == "__main__": | |
| # asyncio.run(main()) | |
| #custom agents for the project and why | |
| orchestrator_agent = Agent( | |
| name="orchestrator_agent", | |
| instructions=( | |
| "You are a translation agent. You use the tools given to you to translate." | |
| "If asked for multiple translations, you call the relevant tools in order." | |
| "You never translate on your own, you always use the provided tools." | |
| ), | |
| tools=[ | |
| vector_db_agent_tool.as_tool( | |
| tool_name="vector_db_agent", | |
| tool_description="Analyse the dataframe and give some insights on it and will use for reports and visualizations", | |
| ), | |
| neo4j_agent_tool.as_tool( | |
| tool_name="neo4j_agent", | |
| tool_description="Analyse the dataframe and give some insights on it and will use for reports and visualizations", | |
| ), | |
| ], | |
| ) | |
| synthesizer_agent = Agent( | |
| name="synthesizer_agent", | |
| instructions="You inspect translations, correct them if needed, and produce a final concatenated response.", | |
| ) | |
| async def main(): | |
| msg = input("Hi! What would you like translated, and to which languages? ") | |
| # Run the entire orchestration in a single trace | |
| with trace("Orchestrator evaluator"): | |
| orchestrator_result = await Runner.run(orchestrator_agent, msg) | |
| for item in orchestrator_result.new_items: | |
| if isinstance(item, MessageOutputItem): | |
| text = ItemHelpers.text_message_output(item) | |
| if text: | |
| print(f" - Translation step: {text}") | |
| synthesizer_result = await Runner.run( | |
| synthesizer_agent, orchestrator_result.to_input_list() | |
| ) | |
| print(f"\n\nFinal response:\n{synthesizer_result.final_output}") | |
| if __name__ == "__main__": | |
| asyncio.run(main()) |