2
2
import os
3
3
import azure .functions as func
4
4
from 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
6
7
from durable_decorators import durable_openai_agent_orchestrator
7
8
from model_activity import create_invoke_model_activity
8
9
from azure .identity import DefaultAzureCredential
@@ -146,7 +147,6 @@ async def get_weather(city: str) -> str:
146
147
return f"Weather in { weather .city } : { weather .temperature_range } , { weather .conditions } "
147
148
148
149
149
-
150
150
@function_tool
151
151
def calculate_circle_area (radius : float ) -> float :
152
152
"""Calculate the area of a circle given its radius."""
@@ -165,6 +165,29 @@ def math_assistant(context):
165
165
return result .final_output
166
166
167
167
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
+
168
191
#region Implementation details
169
192
170
193
create_invoke_model_activity (app ) # TODO: Can we hide this line?
0 commit comments