File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ def weather_expert(context):
124
124
name = "Hello world" ,
125
125
instructions = "You are a helpful agent." ,
126
126
tools = [
127
- activity_as_tool (get_weather )
127
+ activity_as_tool (context , get_weather )
128
128
],
129
129
)
130
130
Original file line number Diff line number Diff line change 14
14
default_tool_error_function ,
15
15
function_tool ,
16
16
)
17
+ from durable_ai_agent_context import DurableAIAgentContext
17
18
18
19
19
- def activity_as_tool (activity_func : Callable ) -> Tool :
20
+ def activity_as_tool (context : DurableAIAgentContext , activity_func : Callable ) -> Tool :
20
21
"""
21
22
Convert an Azure Durable Functions activity to an OpenAI Agents SDK Tool.
22
23
@@ -27,11 +28,12 @@ def activity_as_tool(activity_func: Callable) -> Tool:
27
28
Tool: An OpenAI Agents SDK Tool object
28
29
"""
29
30
30
- async def run_activity (ctx : RunContextWrapper [Any ], input : str ) -> Any :
31
- return "Weather in Tokyo: 14-20C, sunny with wind."
32
-
33
31
activity_name = activity_func ._function ._name
34
32
33
+ def run_activity (ctx : RunContextWrapper [Any ], input : str ) -> Any :
34
+ result = context .get_activity_call_result (activity_name , input )
35
+ return result
36
+
35
37
schema = function_schema (
36
38
func = run_activity ,
37
39
name_override = activity_name ,
You can’t perform that action at this time.
0 commit comments