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 1
1
import azure .functions as func
2
- from agents import ModelResponse
3
2
from model_invoker import ModelInvoker , ActivityModelInput
4
3
from durable_decorators import durable_openai_agent_orchestrator
4
+ from model_activity import create_invoke_model_activity
5
5
6
6
7
7
app = func .FunctionApp (http_auth_level = func .AuthLevel .FUNCTION )
8
8
9
+ # TODO: Can we hide this line?
10
+ create_invoke_model_activity (app )
11
+
9
12
10
13
@app .route (route = "orchestrators/{functionName}" )
11
14
@app .durable_client_input (client_name = "client" )
@@ -22,14 +25,3 @@ def basic_hello_world_orchestrator(context):
22
25
from basic .hello_world import main
23
26
result = main ()
24
27
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