arize-phoenix 0.0.36__py3-none-any.whl → 0.0.38__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of arize-phoenix might be problematic. Click here for more details.

@@ -2,7 +2,7 @@ import json
2
2
  from collections import defaultdict
3
3
  from datetime import datetime
4
4
  from enum import Enum
5
- from typing import Any, DefaultDict, List, Mapping, Optional, cast
5
+ from typing import Any, DefaultDict, Dict, List, Mapping, Optional, cast
6
6
 
7
7
  import strawberry
8
8
  from strawberry import ID
@@ -19,6 +19,8 @@ from phoenix.server.api.context import Context
19
19
  from phoenix.server.api.types.MimeType import MimeType
20
20
  from phoenix.trace.schemas import SpanID
21
21
  from phoenix.trace.semantic_conventions import (
22
+ EMBEDDING_EMBEDDINGS,
23
+ EMBEDDING_VECTOR,
22
24
  EXCEPTION_MESSAGE,
23
25
  INPUT_MIME_TYPE,
24
26
  INPUT_VALUE,
@@ -159,7 +161,7 @@ def to_gql_span(span: trace_schema.Span) -> "Span":
159
161
  span_id=cast(ID, span.context.span_id),
160
162
  ),
161
163
  attributes=json.dumps(
162
- _nested_attributes(span.attributes),
164
+ _nested_attributes(_hide_embedding_vectors(span.attributes)),
163
165
  default=_json_encode,
164
166
  ),
165
167
  token_count_total=cast(
@@ -227,3 +229,19 @@ def _nested_attributes(
227
229
  trie = trie[key]
228
230
  trie[keys[-1]] = attribute_value
229
231
  return nested_attributes
232
+
233
+
234
+ def _hide_embedding_vectors(
235
+ attributes: Mapping[str, Any],
236
+ ) -> Dict[str, Any]:
237
+ _attributes = dict(attributes)
238
+ if not (embeddings := _attributes.get(EMBEDDING_EMBEDDINGS)):
239
+ return _attributes
240
+ _embeddings = []
241
+ for embedding in embeddings:
242
+ _embedding = dict(embedding)
243
+ if vector := _embedding.get(EMBEDDING_VECTOR):
244
+ _embedding[EMBEDDING_VECTOR] = f"<{len(vector)} dimensional vector>"
245
+ _embeddings.append(_embedding)
246
+ _attributes[EMBEDDING_EMBEDDINGS] = _embeddings
247
+ return _attributes
@@ -7,14 +7,7 @@ import pandas as pd
7
7
  import strawberry
8
8
  from strawberry import UNSET
9
9
 
10
- from phoenix.core.model_schema import (
11
- CONTINUOUS,
12
- PRIMARY,
13
- REFERENCE,
14
- Column,
15
- Dataset,
16
- Dimension,
17
- )
10
+ from phoenix.core.model_schema import CONTINUOUS, PRIMARY, REFERENCE, Column, Dataset, Dimension
18
11
  from phoenix.metrics import Metric, binning
19
12
  from phoenix.metrics.mixins import UnaryOperator
20
13
  from phoenix.metrics.timeseries import timeseries