File tree Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change 11import azure .functions as func
2- from agents import ModelResponse
32from model_invoker import ModelInvoker , ActivityModelInput
43from durable_decorators import durable_openai_agent_orchestrator
4+ from model_activity import create_invoke_model_activity
55
66
77app = func .FunctionApp (http_auth_level = func .AuthLevel .FUNCTION )
88
9+ # TODO: Can we hide this line?
10+ create_invoke_model_activity (app )
11+
912
1013@app .route (route = "orchestrators/{functionName}" )
1114@app .durable_client_input (client_name = "client" )
@@ -22,14 +25,3 @@ def basic_hello_world_orchestrator(context):
2225 from basic .hello_world import main
2326 result = main ()
2427 return result
25-
26-
27- @app .activity_trigger (input_name = "input" )
28- async def invoke_model_activity (input : str ):
29- activity_input = ActivityModelInput .from_json (input )
30-
31- model_invoker = ModelInvoker ()
32- result = await model_invoker .invoke_model_activity (activity_input )
33-
34- json_obj = ModelResponse .__pydantic_serializer__ .to_json (result )
35- return json_obj .decode ()
Original file line number Diff line number Diff line change 1+ import azure .functions as func
2+ from agents import ModelResponse
3+ from model_invoker import ModelInvoker , ActivityModelInput
4+
5+
6+ def create_invoke_model_activity (app : func .FunctionApp ):
7+ """Create and register the invoke_model_activity function with the provided FunctionApp."""
8+
9+ @app .activity_trigger (input_name = "input" )
10+ async def invoke_model_activity (input : str ):
11+ activity_input = ActivityModelInput .from_json (input )
12+
13+ model_invoker = ModelInvoker ()
14+ result = await model_invoker .invoke_model_activity (activity_input )
15+
16+ json_obj = ModelResponse .__pydantic_serializer__ .to_json (result )
17+ return json_obj .decode ()
18+
19+ return invoke_model_activity
You can’t perform that action at this time.
0 commit comments