arize-phoenix 4.10.2rc2__py3-none-any.whl → 4.11.0__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.

@@ -4,7 +4,7 @@ from threading import Thread
4
4
  from time import sleep, time
5
5
  from typing import Generator
6
6
 
7
- from fastapi import FastAPI
7
+ from starlette.applications import Starlette
8
8
  from uvicorn import Config, Server
9
9
  from uvicorn.config import LoopSetupType
10
10
 
@@ -24,7 +24,7 @@ class ThreadServer(Server):
24
24
 
25
25
  def __init__(
26
26
  self,
27
- app: FastAPI,
27
+ app: Starlette,
28
28
  host: str,
29
29
  port: int,
30
30
  root_path: str,
@@ -33,6 +33,7 @@ from typing import (
33
33
  cast,
34
34
  )
35
35
 
36
+ import numpy as np
36
37
  from openinference.semconv import trace
37
38
  from openinference.semconv.trace import DocumentAttributes, SpanAttributes
38
39
  from typing_extensions import assert_never
@@ -307,7 +308,7 @@ def _flatten_mapping(
307
308
  json_string_attributes=json_string_attributes,
308
309
  separator=separator,
309
310
  )
310
- elif isinstance(value, Sequence) and recurse_on_sequence:
311
+ elif (isinstance(value, Sequence) or isinstance(value, np.ndarray)) and recurse_on_sequence:
311
312
  yield from _flatten_sequence(
312
313
  value,
313
314
  prefix=prefixed_key,
phoenix/trace/schemas.py CHANGED
@@ -39,6 +39,7 @@ class SpanKind(Enum):
39
39
  AGENT = "AGENT"
40
40
  RERANKER = "RERANKER"
41
41
  EVALUATOR = "EVALUATOR"
42
+ GUARDRAIL = "GUARDRAIL"
42
43
  UNKNOWN = "UNKNOWN"
43
44
 
44
45
  def __str__(self) -> str:
@@ -81,7 +81,7 @@ def json_to_span(data: Dict[str, Any]) -> Any:
81
81
  timestamp=datetime.fromisoformat(event["timestamp"]),
82
82
  )
83
83
  for event in (
84
- data["events"] if isinstance(data["events"], list) else json.loads(data["events"])
84
+ json.loads(data["events"]) if isinstance(data["events"], str) else data["events"]
85
85
  )
86
86
  ]
87
87
  data["conversation"] = (
phoenix/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "4.10.2rc2"
1
+ __version__ = "4.11.0"
@@ -1,94 +0,0 @@
1
- from typing import Any, Dict, Generic, List, Optional, TypedDict, Union
2
-
3
- from pydantic import BaseModel
4
- from typing_extensions import TypeAlias, TypeVar, assert_never
5
-
6
- StatusCode: TypeAlias = int
7
- DataType = TypeVar("DataType")
8
- Responses: TypeAlias = Dict[
9
- Union[int, str], Dict[str, Any]
10
- ] # input type for the `responses` parameter of a fastapi route
11
-
12
-
13
- class StatusCodeWithDescription(TypedDict):
14
- """
15
- A duck type for a status code with a description detailing under what
16
- conditions the status code is raised.
17
- """
18
-
19
- status_code: StatusCode
20
- description: str
21
-
22
-
23
- class RequestBody(BaseModel, Generic[DataType]):
24
- # A generic request type accepted by V1 routes.
25
- #
26
- # Don't use """ for this docstring or it will be included as a description
27
- # in the generated OpenAPI schema.
28
- data: DataType
29
-
30
-
31
- class ResponseBody(BaseModel, Generic[DataType]):
32
- # A generic response type returned by V1 routes.
33
- #
34
- # Don't use """ for this docstring or it will be included as a description
35
- # in the generated OpenAPI schema.
36
-
37
- data: DataType
38
-
39
-
40
- class PaginatedResponseBody(BaseModel, Generic[DataType]):
41
- # A generic paginated response type returned by V1 routes.
42
- #
43
- # Don't use """ for this docstring or it will be included as a description
44
- # in the generated OpenAPI schema.
45
-
46
- data: List[DataType]
47
- next_cursor: Optional[str]
48
-
49
-
50
- def add_errors_to_responses(
51
- errors: List[Union[StatusCode, StatusCodeWithDescription]],
52
- /,
53
- *,
54
- responses: Optional[Responses] = None,
55
- ) -> Responses:
56
- """
57
- Creates or updates a patch for an OpenAPI schema's `responses` section to
58
- include status codes in the generated OpenAPI schema.
59
- """
60
- output_responses: Responses = responses or {}
61
- for error in errors:
62
- status_code: int
63
- description: Optional[str] = None
64
- if isinstance(error, StatusCode):
65
- status_code = error
66
- elif isinstance(error, dict):
67
- status_code = error["status_code"]
68
- description = error["description"]
69
- else:
70
- assert_never(error)
71
- if status_code not in output_responses:
72
- output_responses[status_code] = {
73
- "content": {"text/plain": {"schema": {"type": "string"}}}
74
- }
75
- if description:
76
- output_responses[status_code]["description"] = description
77
- return output_responses
78
-
79
-
80
- def add_text_csv_content_to_responses(
81
- status_code: StatusCode, /, *, responses: Optional[Responses] = None
82
- ) -> Responses:
83
- """
84
- Creates or updates a patch for an OpenAPI schema's `responses` section to
85
- ensure that the response for the given status code is marked as text/csv in
86
- the generated OpenAPI schema.
87
- """
88
- output_responses: Responses = responses or {}
89
- if status_code not in output_responses:
90
- output_responses[status_code] = {}
91
- output_responses[status_code]["content"] = {
92
- "text/csv": {"schema": {"type": "string", "contentMediaType": "text/csv"}}
93
- }
94
- return output_responses