mirror of
https://github.com/invariantlabs-ai/invariant-gateway.git
synced 2026-02-12 14:32:45 +00:00
Format diff.
This commit is contained in:
@@ -251,7 +251,9 @@ class AnthropicProvider(BaseProvider):
|
||||
}
|
||||
}
|
||||
)
|
||||
return ExtraItem(f"event: error\ndata: {error_chunk}\n\n".encode(), end_of_stream=True)
|
||||
return ExtraItem(
|
||||
f"event: error\ndata: {error_chunk}\n\n".encode(), end_of_stream=True
|
||||
)
|
||||
|
||||
def should_push_trace(self, _1: dict[str, Any], _2: bool) -> bool:
|
||||
"""Anthropic always pushes traces"""
|
||||
@@ -309,7 +311,7 @@ class AnthropicProvider(BaseProvider):
|
||||
elif line.startswith("data:"):
|
||||
event_data = line[5:].strip()
|
||||
|
||||
if event_data and event_type != "ping": # Ignore ping events
|
||||
if event_data and event_type != "ping": # Ignore ping events
|
||||
try:
|
||||
event_json = json.loads(event_data)
|
||||
update_merged_response(event_json, merged_response)
|
||||
|
||||
@@ -290,7 +290,10 @@ class GeminiProvider(BaseProvider):
|
||||
location: Literal["request", "response"] = "response",
|
||||
) -> ExtraItem:
|
||||
"""Gemini streaming error format"""
|
||||
return ExtraItem(json.dumps(make_refusal(location, guardrails_execution_result)), end_of_stream=True)
|
||||
return ExtraItem(
|
||||
json.dumps(make_refusal(location, guardrails_execution_result)),
|
||||
end_of_stream=True,
|
||||
)
|
||||
|
||||
def should_push_trace(
|
||||
self, merged_response: dict[str, Any], has_errors: bool
|
||||
|
||||
@@ -170,8 +170,8 @@ class BaseInstrumentedResponse(ABC):
|
||||
|
||||
if self.is_streaming:
|
||||
return self.provider.create_error_chunk(
|
||||
self.guardrails_execution_result, location="request"
|
||||
)
|
||||
self.guardrails_execution_result, location="request"
|
||||
)
|
||||
return self.provider.create_non_streaming_error_response(
|
||||
self.guardrails_execution_result, location="request"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user