22import os
33import azure .functions as func
44from openai import AsyncAzureOpenAI
5- from agents import Agent , Runner , set_default_openai_client , function_tool
5+ from agents import Agent , Runner , set_default_openai_client , function_tool , WebSearchTool
6+ from agents .model_settings import ModelSettings
67from durable_decorators import durable_openai_agent_orchestrator
78from model_activity import create_invoke_model_activity
89from azure .identity import DefaultAzureCredential
@@ -146,7 +147,6 @@ async def get_weather(city: str) -> str:
146147 return f"Weather in { weather .city } : { weather .temperature_range } , { weather .conditions } "
147148
148149
149-
150150@function_tool
151151def calculate_circle_area (radius : float ) -> float :
152152 """Calculate the area of a circle given its radius."""
@@ -165,6 +165,29 @@ def math_assistant(context):
165165 return result .final_output
166166
167167
168+ INSTRUCTIONS = (
169+ "You are a research assistant. Given a search term, you search the web for that term and "
170+ "produce a concise summary of the results. The summary must 2-3 paragraphs and less than 300 "
171+ "words. Capture the main points. Write succinctly, no need to have complete sentences or good "
172+ "grammar. This will be consumed by someone synthesizing a report, so its vital you capture the "
173+ "essence and ignore any fluff. Do not include any additional commentary other than the summary "
174+ "itself."
175+ )
176+
177+ @app .orchestration_trigger (context_name = "context" )
178+ @durable_openai_agent_orchestrator
179+ def search_agent (context ):
180+ webSearchTool = WebSearchTool ()
181+ agent = Agent (
182+ name = "Search agent" ,
183+ instructions = INSTRUCTIONS ,
184+ tools = [webSearchTool ],
185+ model_settings = ModelSettings (tool_choice = "required" ),
186+ )
187+ result = Runner .run_sync (agent , input = "Search term: recursion" )
188+ return result .final_output
189+
190+
168191#region Implementation details
169192
170193create_invoke_model_activity (app ) # TODO: Can we hide this line?
0 commit comments