fix more cases

This commit is contained in:
Luca Beurer-Kellner
2025-03-27 15:14:22 +01:00
committed by Hemang
parent 0157aad27b
commit e66232215e
2 changed files with 12 additions and 2 deletions
+2 -2
View File
@@ -365,8 +365,8 @@ class RequestInstrumentor(StreamInstrumentor):
# pretend the 'request_task' is an async iterable with a single item
result = [item async for item in self.stream(wrapped_request_task())]
assert len(result) == 1, "RequestInstrumentor should yield exactly one item"
return result[0]
assert len(result) >= 1, "RequestInstrumentor must yield at least one item"
return result[-1]
async def check_guardrails(
+10
View File
@@ -486,6 +486,16 @@ async def handle_non_streaming_response(
# block on the guardrails check
guardrails_execution_result = await get_guardrails_check_result(context)
if guardrails_execution_result.get("errors", []):
# Push annotated trace to the explorer - don't block on its response
if context.dataset_name:
asyncio.create_task(
push_to_explorer(
context,
{},
guardrails_execution_result,
)
)
# replace the response with the error message
raise YieldException(
Response(