Skip to content

Commit 9532175

Browse files
committed
format
1 parent 65f9230 commit 9532175

3 files changed

Lines changed: 22 additions & 10 deletions

File tree

sentry_sdk/integrations/cohere/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def _normalize_embedding_input(texts):
4646
"system": "cohere",
4747
"operation": "embeddings",
4848
"params": {"model": SPANDATA.GEN_AI_REQUEST_MODEL},
49-
"extract_messages": lambda kw: _normalize_embedding_input(kw["texts"]) if "texts" in kw else None,
49+
"extract_messages": lambda kw: (
50+
_normalize_embedding_input(kw["texts"]) if "texts" in kw else None
51+
),
5052
"message_target": SPANDATA.GEN_AI_EMBEDDINGS_INPUT,
5153
"truncation_fn": None,
5254
}

sentry_sdk/integrations/cohere/v1.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ def _wrap_chat(f, streaming):
100100
if not _has_chat_types:
101101
return f
102102

103-
104103
@wraps(f)
105104
def new_chat(*args, **kwargs):
106105
# type: (*Any, **Any) -> Any
@@ -129,10 +128,15 @@ def new_chat(*args, **kwargs):
129128
reraise(*exc_info)
130129

131130
with capture_internal_exceptions():
132-
set_input_span_data(span, kwargs, integration, {
133-
**COHERE_V1_CHAT_CONFIG,
134-
"extra_static": {SPANDATA.GEN_AI_RESPONSE_STREAMING: streaming},
135-
})
131+
set_input_span_data(
132+
span,
133+
kwargs,
134+
integration,
135+
{
136+
**COHERE_V1_CHAT_CONFIG,
137+
"extra_static": {SPANDATA.GEN_AI_RESPONSE_STREAMING: streaming},
138+
},
139+
)
136140

137141
if streaming:
138142
old_iterator = res
@@ -194,4 +198,5 @@ def collect_chat_response_fields(span, res, include_pii):
194198
input_tokens=res.meta.tokens.input_tokens,
195199
output_tokens=res.meta.tokens.output_tokens,
196200
)
201+
197202
return new_chat

sentry_sdk/integrations/cohere/v2.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,15 @@ def new_chat(*args, **kwargs):
189189
extra = {SPANDATA.GEN_AI_RESPONSE_STREAMING: streaming}
190190
if model:
191191
extra[SPANDATA.GEN_AI_RESPONSE_MODEL] = model
192-
set_input_span_data(span, kwargs, integration, {
193-
**COHERE_V2_CHAT_CONFIG,
194-
"extra_static": extra,
195-
})
192+
set_input_span_data(
193+
span,
194+
kwargs,
195+
integration,
196+
{
197+
**COHERE_V2_CHAT_CONFIG,
198+
"extra_static": extra,
199+
},
200+
)
196201

197202
if streaming:
198203
old_iterator = res

0 commit comments

Comments
 (0)