|
1 | | -from typing import Any, Callable, Optional, TYPE_CHECKING |
| 1 | +from typing import Any, Callable, Optional, TYPE_CHECKING, Union |
2 | 2 |
|
3 | 3 | from azure.durable_functions.models.DurableOrchestrationContext import ( |
4 | 4 | DurableOrchestrationContext, |
|
8 | 8 | from agents import RunContextWrapper, Tool |
9 | 9 | from agents.function_schema import function_schema |
10 | 10 | from agents.tool import FunctionTool |
| 11 | + |
| 12 | +from azure.durable_functions.models.Task import TaskBase |
11 | 13 | from .task_tracker import TaskTracker |
12 | 14 |
|
13 | 15 |
|
@@ -55,17 +57,53 @@ def __init__( |
55 | 57 | self._task_tracker = task_tracker |
56 | 58 | self._model_retry_options = model_retry_options |
57 | 59 |
|
58 | | - def call_activity(self, activity_name, input: str): |
59 | | - """Call an activity function and record the activity call.""" |
60 | | - task = self._context.call_activity(activity_name, input) |
| 60 | + def call_activity( |
| 61 | + self, name: Union[str, Callable], input_: Optional[Any] = None |
| 62 | + ) -> TaskBase: |
| 63 | + """Schedule an activity for execution. |
| 64 | +
|
| 65 | + Parameters |
| 66 | + ---------- |
| 67 | + name: str | Callable |
| 68 | + Either the name of the activity function to call, as a string or, |
| 69 | + in the Python V2 programming model, the activity function itself. |
| 70 | + input_: Optional[Any] |
| 71 | + The JSON-serializable input to pass to the activity function. |
| 72 | +
|
| 73 | + Returns |
| 74 | + ------- |
| 75 | + Task |
| 76 | + A Durable Task that completes when the called activity function completes or fails. |
| 77 | + """ |
| 78 | + task = self._context.call_activity(name, input_) |
61 | 79 | self._task_tracker.record_activity_call() |
62 | 80 | return task |
63 | 81 |
|
64 | 82 | def call_activity_with_retry( |
65 | | - self, activity_name, retry_options: RetryOptions, input: str = None |
66 | | - ): |
67 | | - """Call an activity function with retry options and record the activity call.""" |
68 | | - task = self._context.call_activity_with_retry(activity_name, retry_options, input) |
| 83 | + self, |
| 84 | + name: Union[str, Callable], |
| 85 | + retry_options: RetryOptions, |
| 86 | + input_: Optional[Any] = None, |
| 87 | + ) -> TaskBase: |
| 88 | + """Schedule an activity for execution with retry options. |
| 89 | +
|
| 90 | + Parameters |
| 91 | + ---------- |
| 92 | + name: str | Callable |
| 93 | + Either the name of the activity function to call, as a string or, |
| 94 | + in the Python V2 programming model, the activity function itself. |
| 95 | + retry_options: RetryOptions |
| 96 | + The retry options for the activity function. |
| 97 | + input_: Optional[Any] |
| 98 | + The JSON-serializable input to pass to the activity function. |
| 99 | +
|
| 100 | + Returns |
| 101 | + ------- |
| 102 | + Task |
| 103 | + A Durable Task that completes when the called activity function completes or |
| 104 | + fails completely. |
| 105 | + """ |
| 106 | + task = self._context.call_activity_with_retry(name, retry_options, input_) |
69 | 107 | self._task_tracker.record_activity_call() |
70 | 108 | return task |
71 | 109 |
|
|
0 commit comments