You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Decorator for user-defined reward and evaluation functions with resource management.
@@ -64,6 +66,8 @@ def reward_function(
64
66
resources: Optional dictionary of resource types to resource instances.
65
67
Example: {"llms": [llm_resource]}
66
68
Resources are automatically setup before evaluation and cleaned up after.
69
+
concurrency: Optional number of concurrent requests to the reward function. This will only take effect if the function is async or there are async resources binded to the reward function (e.g. LLM resource).
70
+
timeout: Optional timeout for the reward function. This will only take effect if the function is async or there are async resources binded to the reward function (e.g. LLM resource).
67
71
68
72
Returns:
69
73
A decorator if `_func` is None, or the decorated function.
@@ -94,38 +98,14 @@ def decorator(func: F) -> F:
94
98
managers.append(resource)
95
99
resource_managers[resource_type] =managers
96
100
97
-
@wraps(func)
98
-
defwrapper(
99
-
# The wrapper's signature should be generic enough to accept what the original func might take.
100
-
# The specific coercion below targets 'messages' and 'ground_truth'.
101
-
# For 'pointwise', 'messages' is expected. For 'batch', 'rollouts_messages' is more typical.
102
-
# This simplified wrapper signature might need adjustment if we generalize input param coercion.
103
-
*args: Any,
104
-
**kwargs: Any,
105
-
) ->Union[EvaluateResult, List[EvaluateResult]]: # Return type depends on mode
106
-
107
-
# For now, we'll assume 'messages' is the primary input for pointwise,
108
-
# and it's passed via kwargs or as the first arg if not named 'messages'.
109
-
# This part needs to be more robust based on actual function signatures.
110
-
# The current reverted logic specifically looks for 'messages' in params.
111
-
112
-
# Extract 'messages' or 'rollouts_messages' from args/kwargs for processing
113
-
# This is a simplification; a more robust solution would inspect `sig`
114
-
# to find the correct parameter name based on `mode`.
115
-
# For now, sticking to the structure of the reverted file which explicitly handles 'messages'.
116
-
117
-
current_messages_arg_name="messages"# Default for pointwise
118
-
ifmode=="batch":
119
-
# A common pattern for batch mode is 'rollouts_messages'
120
-
# We'd need to find this in *args or **kwargs if not hardcoded.
121
-
# For now, let's assume it's still passed as 'messages' for simplicity of this step,
122
-
# or that the user function handles it. The key is output validation.
123
-
pass
124
-
125
-
# The reverted logic for input coercion:
126
-
# It explicitly looks for 'messages' and 'ground_truth' in params.
127
-
# We need to adapt how `processed_messages` and `kwargs` are prepared for `func` call.
101
+
# Detect if the user supplied function is a coroutine (async def)
0 commit comments