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
"""Runs a generic action, and adds both the action and the result to the context.
77
78
78
79
Args:
79
80
action: the Component from which to generate.
80
81
context: the context being used as a history from which to generate the response.
81
-
backend: the backend used to generate the response.
82
+
backend: the backend used to generate the response.
82
83
requirements: used as additional requirements when a sampling strategy is provided.
83
84
strategy: a SamplingStrategy that describes the strategy for validating and repairing/retrying for the instruct-validate-repair pattern. None means that no particular sampling strategy is used.
84
85
return_sampling_results: attach the (successful and failed) sampling attempts to the results.
"""Asynchronous version of .act; runs a generic action, and adds both the action and the result to the context.
122
124
123
125
Args:
124
126
action: the Component from which to generate.
125
127
context: the context being used as a history from which to generate the response.
126
-
backend: the backend used to generate the response.
128
+
backend: the backend used to generate the response.
127
129
requirements: used as additional requirements when a sampling strategy is provided
128
130
strategy: a SamplingStrategy that describes the strategy for validating and repairing/retrying for the instruct-validate-repair pattern. None means that no particular sampling strategy is used.
129
131
return_sampling_results: attach the (successful and failed) sampling attempts to the results.
@@ -167,10 +169,10 @@ async def _act(
167
169
requirements= []
168
170
169
171
sampling_result=awaitstrategy.sample(
170
-
action,
171
-
context=context,
172
-
backend=backend,
173
-
requirements=requirements,
172
+
action,
173
+
context=context,
174
+
backend=backend,
175
+
requirements=requirements,
174
176
validation_ctx=None,
175
177
format=format,
176
178
model_options=model_options,
@@ -179,9 +181,7 @@ async def _act(
179
181
180
182
assertsampling_result.sample_generationsisnotNone
181
183
forresultinsampling_result.sample_generations:
182
-
assert (
183
-
result._generate_logisnotNone
184
-
) # Cannot be None after generation.
184
+
assertresult._generate_logisnotNone# Cannot be None after generation.
185
185
generate_logs.append(result._generate_log)
186
186
187
187
# TODO: JAL. Extract the context from the sampling result.
generate_logs: list[GenerateLog] |None=None, # TODO: Can we get rid of gen logs here and in act?
359
+
generate_logs: list[GenerateLog]
360
+
|None=None, # TODO: Can we get rid of gen logs here and in act?
355
361
input: CBlock|None=None,
356
362
) ->list[ValidationResult]:
357
363
"""Validates a set of requirements over the output (if provided) or the current context (if the output is not provided)."""
@@ -367,12 +373,13 @@ def validate(
367
373
model_options=model_options,
368
374
generate_logs=generate_logs,
369
375
input=input,
370
-
),
376
+
)
371
377
)
372
378
373
379
# Wait for and return the result.
374
380
returnout
375
381
382
+
376
383
asyncdef_validate(
377
384
reqs: Requirement|list[Requirement],
378
385
context: Context,
@@ -383,7 +390,9 @@ async def _validate(
383
390
model_options: dict|None=None,
384
391
generate_logs: list[GenerateLog] |None=None,
385
392
input: CBlock|None=None,
386
-
) ->list[ValidationResult]: # TODO: JAL. We should think about returning the contexts as well.
393
+
) ->list[
394
+
ValidationResult
395
+
]: # TODO: JAL. We should think about returning the contexts as well.
387
396
"""Asynchronous version of .validate; validates a set of requirements over the output (if provided) or the current context (if the output is not provided)."""
388
397
# Turn a solitary requirement in to a list of requirements, and then reqify if needed.
0 commit comments