Spaces:
Runtime error
Runtime error
| from agents import Agent, ModelSettings, function_tool | |
| from duckduckgo_search import DDGS | |
| from model import model | |
| from writer_agent import writer_agent | |
| INSTRUCTIONS = ( | |
| "You are a research assistant. Given a search term, you search the web for that term and " | |
| "produce a concise summary of the results. The summary must 2-3 paragraphs and less than 300 " | |
| "words. Capture the main points. Write succintly, no need to have complete sentences or good " | |
| "grammar. This will be consumed by someone synthesizing a report, so its vital you capture the " | |
| "essence and ignore any fluff. Do not include any additional commentary other than the summary itself." | |
| ) | |
| def duckduckgo_search(query: str, max_results: str = 5) -> list[dict]: | |
| """Search the web using DuckDuckGo and return results.""" | |
| # Cast to int just in case the model passes a string | |
| max_results = int(max_results) | |
| with DDGS() as ddgs: | |
| return [r for r in ddgs.text(query, max_results=max_results)] | |
| search_agent = Agent( | |
| name="Search agent", | |
| instructions=INSTRUCTIONS, | |
| tools=[duckduckgo_search], | |
| model=model, | |
| handoff_description='After searching, handoff to writer_agent to generate a report', | |
| handoffs=[writer_agent], | |
| model_settings=ModelSettings(tool_choice="required"), | |
| ) |