mirror of
https://github.com/invariantlabs-ai/invariant-gateway.git
synced 2026-07-10 12:48:35 +02:00
fix more cases
This commit is contained in:
committed by
Hemang
parent
0157aad27b
commit
e66232215e
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user