55"""
66
77import functools
8- import re
98import time
109from datetime import UTC , datetime
1110from typing import Annotated , Any , Optional , cast
@@ -84,9 +83,6 @@ class TemplateRenderError(Exception):
8483 OpenAIAPIStatusError ,
8584)
8685
87- _PRIVATE_ERROR_BLOCK_PATTERN = re .compile (r"\bPRIVATE\b[^\r\n,;)]*" , re .IGNORECASE )
88- _SECRET_KEY_PATTERN = re .compile (r"\bsk-[A-Za-z0-9][A-Za-z0-9_-]*" )
89-
9086
9187infer_responses : dict [int | str , dict [str , Any ]] = {
9288 200 : RlsapiV1InferResponse .openapi_response (),
@@ -103,23 +99,6 @@ class TemplateRenderError(Exception):
10399}
104100
105101
106- def _redact_sensitive_error_text (error_text : str ) -> str :
107- """Redact sensitive substrings from backend error text before telemetry.
108-
109- Backend exceptions can include provider request snippets or credentials in
110- their string representation. Splunk events need enough context to explain
111- the failure, but they must not contain private prompt blocks or API keys.
112-
113- Args:
114- error_text: Raw exception string returned by ``str(error)``.
115-
116- Returns:
117- Error text with known sensitive substrings replaced by placeholders.
118- """
119- redacted_text = _PRIVATE_ERROR_BLOCK_PATTERN .sub ("PRIVATE [REDACTED]" , error_text )
120- return _SECRET_KEY_PATTERN .sub ("sk-[REDACTED]" , redacted_text )
121-
122-
123102def _build_instructions (systeminfo : RlsapiV1SystemInfo ) -> str :
124103 """Build LLM instructions by rendering the system prompt as a Jinja2 template.
125104
0 commit comments