arize-phoenix 5.4.0__py3-none-any.whl → 5.5.1__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.
- arize_phoenix-5.5.1.dist-info/METADATA +262 -0
- {arize_phoenix-5.4.0.dist-info → arize_phoenix-5.5.1.dist-info}/RECORD +13 -13
- phoenix/server/api/subscriptions.py +227 -94
- phoenix/server/static/.vite/manifest.json +14 -14
- phoenix/server/static/assets/{components-8zh9kCOG.js → components-mVBxvljU.js} +2 -2
- phoenix/server/static/assets/{index-Ci93KI-L.js → index-BHfTZ6x_.js} +1 -1
- phoenix/server/static/assets/{pages-CFNU-U_5.js → pages-aAez_Ntk.js} +173 -173
- phoenix/server/static/assets/{vendor-arizeai-uC2sozJ6.js → vendor-arizeai-DRZuoyuF.js} +26 -26
- phoenix/version.py +1 -1
- arize_phoenix-5.4.0.dist-info/METADATA +0 -202
- {arize_phoenix-5.4.0.dist-info → arize_phoenix-5.5.1.dist-info}/WHEEL +0 -0
- {arize_phoenix-5.4.0.dist-info → arize_phoenix-5.5.1.dist-info}/entry_points.txt +0 -0
- {arize_phoenix-5.4.0.dist-info → arize_phoenix-5.5.1.dist-info}/licenses/IP_NOTICE +0 -0
- {arize_phoenix-5.4.0.dist-info → arize_phoenix-5.5.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
+
from abc import ABC, abstractmethod
|
|
2
3
|
from collections import defaultdict
|
|
3
4
|
from dataclasses import fields
|
|
4
5
|
from datetime import datetime
|
|
@@ -9,6 +10,7 @@ from typing import (
|
|
|
9
10
|
Annotated,
|
|
10
11
|
Any,
|
|
11
12
|
AsyncIterator,
|
|
13
|
+
Callable,
|
|
12
14
|
DefaultDict,
|
|
13
15
|
Dict,
|
|
14
16
|
Iterable,
|
|
@@ -16,6 +18,7 @@ from typing import (
|
|
|
16
18
|
List,
|
|
17
19
|
Optional,
|
|
18
20
|
Tuple,
|
|
21
|
+
Type,
|
|
19
22
|
Union,
|
|
20
23
|
)
|
|
21
24
|
|
|
@@ -56,14 +59,13 @@ from phoenix.utilities.template_formatters import (
|
|
|
56
59
|
)
|
|
57
60
|
|
|
58
61
|
if TYPE_CHECKING:
|
|
62
|
+
from anthropic.types import MessageParam
|
|
59
63
|
from openai.types import CompletionUsage
|
|
60
|
-
from openai.types.chat import
|
|
61
|
-
ChatCompletionMessageParam,
|
|
62
|
-
)
|
|
64
|
+
from openai.types.chat import ChatCompletionMessageParam
|
|
63
65
|
|
|
64
66
|
PLAYGROUND_PROJECT_NAME = "playground"
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
ToolCallID: TypeAlias = str
|
|
67
69
|
|
|
68
70
|
|
|
69
71
|
@strawberry.enum
|
|
@@ -127,39 +129,202 @@ class ChatCompletionInput:
|
|
|
127
129
|
api_key: Optional[str] = strawberry.field(default=None)
|
|
128
130
|
|
|
129
131
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
from openai.types.chat import (
|
|
134
|
-
ChatCompletionAssistantMessageParam,
|
|
135
|
-
ChatCompletionSystemMessageParam,
|
|
136
|
-
ChatCompletionUserMessageParam,
|
|
137
|
-
)
|
|
132
|
+
PLAYGROUND_STREAMING_CLIENT_REGISTRY: Dict[
|
|
133
|
+
GenerativeProviderKey, Type["PlaygroundStreamingClient"]
|
|
134
|
+
] = {}
|
|
138
135
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
136
|
+
|
|
137
|
+
def register_llm_client(
|
|
138
|
+
provider_key: GenerativeProviderKey,
|
|
139
|
+
) -> Callable[[Type["PlaygroundStreamingClient"]], Type["PlaygroundStreamingClient"]]:
|
|
140
|
+
def decorator(cls: Type["PlaygroundStreamingClient"]) -> Type["PlaygroundStreamingClient"]:
|
|
141
|
+
PLAYGROUND_STREAMING_CLIENT_REGISTRY[provider_key] = cls
|
|
142
|
+
return cls
|
|
143
|
+
|
|
144
|
+
return decorator
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class PlaygroundStreamingClient(ABC):
|
|
148
|
+
def __init__(self, model: GenerativeModelInput, api_key: Optional[str] = None) -> None: ...
|
|
149
|
+
|
|
150
|
+
@abstractmethod
|
|
151
|
+
async def chat_completion_create(
|
|
152
|
+
self,
|
|
153
|
+
messages: List[Tuple[ChatCompletionMessageRole, str]],
|
|
154
|
+
tools: List[JSONScalarType],
|
|
155
|
+
**invocation_parameters: Any,
|
|
156
|
+
) -> AsyncIterator[ChatCompletionSubscriptionPayload]:
|
|
157
|
+
# a yield statement is needed to satisfy the type-checker
|
|
158
|
+
# https://mypy.readthedocs.io/en/stable/more_types.html#asynchronous-iterators
|
|
159
|
+
yield TextChunk(content="")
|
|
160
|
+
|
|
161
|
+
@property
|
|
162
|
+
@abstractmethod
|
|
163
|
+
def attributes(self) -> Dict[str, Any]: ...
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
@register_llm_client(GenerativeProviderKey.OPENAI)
|
|
167
|
+
class OpenAIStreamingClient(PlaygroundStreamingClient):
|
|
168
|
+
def __init__(self, model: GenerativeModelInput, api_key: Optional[str] = None) -> None:
|
|
169
|
+
from openai import AsyncOpenAI
|
|
170
|
+
|
|
171
|
+
self.client = AsyncOpenAI(api_key=api_key)
|
|
172
|
+
self.model_name = model.name
|
|
173
|
+
self._attributes: Dict[str, Any] = {}
|
|
174
|
+
|
|
175
|
+
async def chat_completion_create(
|
|
176
|
+
self,
|
|
177
|
+
messages: List[Tuple[ChatCompletionMessageRole, str]],
|
|
178
|
+
tools: List[JSONScalarType],
|
|
179
|
+
**invocation_parameters: Any,
|
|
180
|
+
) -> AsyncIterator[ChatCompletionSubscriptionPayload]:
|
|
181
|
+
from openai import NOT_GIVEN
|
|
182
|
+
from openai.types.chat import ChatCompletionStreamOptionsParam
|
|
183
|
+
|
|
184
|
+
# Convert standard messages to OpenAI messages
|
|
185
|
+
openai_messages = [self.to_openai_chat_completion_param(*message) for message in messages]
|
|
186
|
+
tool_call_ids: Dict[int, str] = {}
|
|
187
|
+
token_usage: Optional["CompletionUsage"] = None
|
|
188
|
+
async for chunk in await self.client.chat.completions.create(
|
|
189
|
+
messages=openai_messages,
|
|
190
|
+
model=self.model_name,
|
|
191
|
+
stream=True,
|
|
192
|
+
stream_options=ChatCompletionStreamOptionsParam(include_usage=True),
|
|
193
|
+
tools=tools or NOT_GIVEN,
|
|
194
|
+
**invocation_parameters,
|
|
195
|
+
):
|
|
196
|
+
if (usage := chunk.usage) is not None:
|
|
197
|
+
token_usage = usage
|
|
198
|
+
continue
|
|
199
|
+
choice = chunk.choices[0]
|
|
200
|
+
delta = choice.delta
|
|
201
|
+
if choice.finish_reason is None:
|
|
202
|
+
if isinstance(chunk_content := delta.content, str):
|
|
203
|
+
text_chunk = TextChunk(content=chunk_content)
|
|
204
|
+
yield text_chunk
|
|
205
|
+
if (tool_calls := delta.tool_calls) is not None:
|
|
206
|
+
for tool_call_index, tool_call in enumerate(tool_calls):
|
|
207
|
+
tool_call_id = (
|
|
208
|
+
tool_call.id
|
|
209
|
+
if tool_call.id is not None
|
|
210
|
+
else tool_call_ids[tool_call_index]
|
|
211
|
+
)
|
|
212
|
+
tool_call_ids[tool_call_index] = tool_call_id
|
|
213
|
+
if (function := tool_call.function) is not None:
|
|
214
|
+
tool_call_chunk = ToolCallChunk(
|
|
215
|
+
id=tool_call_id,
|
|
216
|
+
function=FunctionCallChunk(
|
|
217
|
+
name=function.name or "",
|
|
218
|
+
arguments=function.arguments or "",
|
|
219
|
+
),
|
|
220
|
+
)
|
|
221
|
+
yield tool_call_chunk
|
|
222
|
+
if token_usage is not None:
|
|
223
|
+
self._attributes.update(_llm_token_counts(token_usage))
|
|
224
|
+
|
|
225
|
+
def to_openai_chat_completion_param(
|
|
226
|
+
self, role: ChatCompletionMessageRole, content: JSONScalarType
|
|
227
|
+
) -> "ChatCompletionMessageParam":
|
|
228
|
+
from openai.types.chat import (
|
|
229
|
+
ChatCompletionAssistantMessageParam,
|
|
230
|
+
ChatCompletionSystemMessageParam,
|
|
231
|
+
ChatCompletionUserMessageParam,
|
|
152
232
|
)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
233
|
+
|
|
234
|
+
if role is ChatCompletionMessageRole.USER:
|
|
235
|
+
return ChatCompletionUserMessageParam(
|
|
236
|
+
{
|
|
237
|
+
"content": content,
|
|
238
|
+
"role": "user",
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
if role is ChatCompletionMessageRole.SYSTEM:
|
|
242
|
+
return ChatCompletionSystemMessageParam(
|
|
243
|
+
{
|
|
244
|
+
"content": content,
|
|
245
|
+
"role": "system",
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
if role is ChatCompletionMessageRole.AI:
|
|
249
|
+
return ChatCompletionAssistantMessageParam(
|
|
250
|
+
{
|
|
251
|
+
"content": content,
|
|
252
|
+
"role": "assistant",
|
|
253
|
+
}
|
|
254
|
+
)
|
|
255
|
+
if role is ChatCompletionMessageRole.TOOL:
|
|
256
|
+
raise NotImplementedError
|
|
257
|
+
assert_never(role)
|
|
258
|
+
|
|
259
|
+
@property
|
|
260
|
+
def attributes(self) -> Dict[str, Any]:
|
|
261
|
+
return self._attributes
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
@register_llm_client(GenerativeProviderKey.AZURE_OPENAI)
|
|
265
|
+
class AzureOpenAIStreamingClient(OpenAIStreamingClient):
|
|
266
|
+
def __init__(self, model: GenerativeModelInput, api_key: Optional[str] = None):
|
|
267
|
+
from openai import AsyncAzureOpenAI
|
|
268
|
+
|
|
269
|
+
if model.endpoint is None or model.api_version is None:
|
|
270
|
+
raise ValueError("endpoint and api_version are required for Azure OpenAI models")
|
|
271
|
+
self.client = AsyncAzureOpenAI(
|
|
272
|
+
api_key=api_key,
|
|
273
|
+
azure_endpoint=model.endpoint,
|
|
274
|
+
api_version=model.api_version,
|
|
159
275
|
)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
@register_llm_client(GenerativeProviderKey.ANTHROPIC)
|
|
279
|
+
class AnthropicStreamingClient(PlaygroundStreamingClient):
|
|
280
|
+
def __init__(self, model: GenerativeModelInput, api_key: Optional[str] = None) -> None:
|
|
281
|
+
import anthropic
|
|
282
|
+
|
|
283
|
+
self.client = anthropic.AsyncAnthropic(api_key=api_key)
|
|
284
|
+
self.model_name = model.name
|
|
285
|
+
|
|
286
|
+
async def chat_completion_create(
|
|
287
|
+
self,
|
|
288
|
+
messages: List[Tuple[ChatCompletionMessageRole, str]],
|
|
289
|
+
tools: List[JSONScalarType],
|
|
290
|
+
**invocation_parameters: Any,
|
|
291
|
+
) -> AsyncIterator[ChatCompletionSubscriptionPayload]:
|
|
292
|
+
anthropic_messages, system_prompt = self._build_anthropic_messages(messages)
|
|
293
|
+
|
|
294
|
+
anthropic_params = {
|
|
295
|
+
"messages": anthropic_messages,
|
|
296
|
+
"model": self.model_name,
|
|
297
|
+
"system": system_prompt,
|
|
298
|
+
"max_tokens": 1024,
|
|
299
|
+
**invocation_parameters,
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
async with self.client.messages.stream(**anthropic_params) as stream:
|
|
303
|
+
async for text in stream.text_stream:
|
|
304
|
+
yield TextChunk(content=text)
|
|
305
|
+
|
|
306
|
+
def _build_anthropic_messages(
|
|
307
|
+
self, messages: List[Tuple[ChatCompletionMessageRole, str]]
|
|
308
|
+
) -> Tuple[List["MessageParam"], str]:
|
|
309
|
+
anthropic_messages: List["MessageParam"] = []
|
|
310
|
+
system_prompt = ""
|
|
311
|
+
for role, content in messages:
|
|
312
|
+
if role == ChatCompletionMessageRole.USER:
|
|
313
|
+
anthropic_messages.append({"role": "user", "content": content})
|
|
314
|
+
elif role == ChatCompletionMessageRole.AI:
|
|
315
|
+
anthropic_messages.append({"role": "assistant", "content": content})
|
|
316
|
+
elif role == ChatCompletionMessageRole.SYSTEM:
|
|
317
|
+
system_prompt += content + "\n"
|
|
318
|
+
elif role == ChatCompletionMessageRole.TOOL:
|
|
319
|
+
raise NotImplementedError
|
|
320
|
+
else:
|
|
321
|
+
assert_never(role)
|
|
322
|
+
|
|
323
|
+
return anthropic_messages, system_prompt
|
|
324
|
+
|
|
325
|
+
@property
|
|
326
|
+
def attributes(self) -> Dict[str, Any]:
|
|
327
|
+
return dict()
|
|
163
328
|
|
|
164
329
|
|
|
165
330
|
@strawberry.type
|
|
@@ -168,30 +333,20 @@ class Subscription:
|
|
|
168
333
|
async def chat_completion(
|
|
169
334
|
self, info: Info[Context, None], input: ChatCompletionInput
|
|
170
335
|
) -> AsyncIterator[ChatCompletionSubscriptionPayload]:
|
|
171
|
-
|
|
172
|
-
|
|
336
|
+
# Determine which LLM client to use based on provider_key
|
|
337
|
+
provider_key = input.model.provider_key
|
|
338
|
+
llm_client_class = PLAYGROUND_STREAMING_CLIENT_REGISTRY.get(provider_key)
|
|
339
|
+
if llm_client_class is None:
|
|
340
|
+
raise ValueError(f"No LLM client registered for provider '{provider_key}'")
|
|
173
341
|
|
|
174
|
-
|
|
342
|
+
llm_client = llm_client_class(model=input.model, api_key=input.api_key)
|
|
175
343
|
|
|
176
|
-
|
|
177
|
-
if input.model.endpoint is None or input.model.api_version is None:
|
|
178
|
-
raise ValueError("endpoint and api_version are required for Azure OpenAI models")
|
|
179
|
-
client = AsyncAzureOpenAI(
|
|
180
|
-
api_key=input.api_key,
|
|
181
|
-
azure_endpoint=input.model.endpoint,
|
|
182
|
-
api_version=input.model.api_version,
|
|
183
|
-
)
|
|
184
|
-
else:
|
|
185
|
-
client = AsyncOpenAI(api_key=input.api_key)
|
|
186
|
-
|
|
187
|
-
invocation_parameters = jsonify(input.invocation_parameters)
|
|
344
|
+
messages = [(message.role, message.content) for message in input.messages]
|
|
188
345
|
|
|
189
|
-
messages: List[Tuple[ChatCompletionMessageRole, str]] = [
|
|
190
|
-
(message.role, message.content) for message in input.messages
|
|
191
|
-
]
|
|
192
346
|
if template_options := input.template:
|
|
193
347
|
messages = list(_formatted_messages(messages, template_options))
|
|
194
|
-
|
|
348
|
+
|
|
349
|
+
invocation_parameters = jsonify(input.invocation_parameters)
|
|
195
350
|
|
|
196
351
|
in_memory_span_exporter = InMemorySpanExporter()
|
|
197
352
|
tracer_provider = TracerProvider()
|
|
@@ -200,6 +355,7 @@ class Subscription:
|
|
|
200
355
|
)
|
|
201
356
|
tracer = tracer_provider.get_tracer(__name__)
|
|
202
357
|
span_name = "ChatCompletion"
|
|
358
|
+
|
|
203
359
|
with tracer.start_span(
|
|
204
360
|
span_name,
|
|
205
361
|
attributes=dict(
|
|
@@ -215,52 +371,29 @@ class Subscription:
|
|
|
215
371
|
) as span:
|
|
216
372
|
response_chunks = []
|
|
217
373
|
text_chunks: List[TextChunk] = []
|
|
218
|
-
tool_call_chunks: DefaultDict[
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
model=input.model.name,
|
|
224
|
-
stream=True,
|
|
225
|
-
tools=input.tools or NOT_GIVEN,
|
|
226
|
-
stream_options=ChatCompletionStreamOptionsParam(include_usage=True),
|
|
374
|
+
tool_call_chunks: DefaultDict[ToolCallID, List[ToolCallChunk]] = defaultdict(list)
|
|
375
|
+
|
|
376
|
+
async for chunk in llm_client.chat_completion_create(
|
|
377
|
+
messages=messages,
|
|
378
|
+
tools=input.tools or [],
|
|
227
379
|
**invocation_parameters,
|
|
228
380
|
):
|
|
229
381
|
response_chunks.append(chunk)
|
|
230
|
-
if (
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if choice.finish_reason is None:
|
|
238
|
-
if isinstance(chunk_content := delta.content, str):
|
|
239
|
-
text_chunk = TextChunk(content=chunk_content)
|
|
240
|
-
yield text_chunk
|
|
241
|
-
text_chunks.append(text_chunk)
|
|
242
|
-
if (tool_calls := delta.tool_calls) is not None:
|
|
243
|
-
for tool_call_index, tool_call in enumerate(tool_calls):
|
|
244
|
-
if (function := tool_call.function) is not None:
|
|
245
|
-
if (tool_call_id := tool_call.id) is None:
|
|
246
|
-
first_tool_call_chunk = tool_call_chunks[tool_call_index][0]
|
|
247
|
-
tool_call_id = first_tool_call_chunk.id
|
|
248
|
-
tool_call_chunk = ToolCallChunk(
|
|
249
|
-
id=tool_call_id,
|
|
250
|
-
function=FunctionCallChunk(
|
|
251
|
-
name=function.name or "",
|
|
252
|
-
arguments=function.arguments or "",
|
|
253
|
-
),
|
|
254
|
-
)
|
|
255
|
-
yield tool_call_chunk
|
|
256
|
-
tool_call_chunks[tool_call_index].append(tool_call_chunk)
|
|
382
|
+
if isinstance(chunk, TextChunk):
|
|
383
|
+
yield chunk
|
|
384
|
+
text_chunks.append(chunk)
|
|
385
|
+
elif isinstance(chunk, ToolCallChunk):
|
|
386
|
+
yield chunk
|
|
387
|
+
tool_call_chunks[chunk.id].append(chunk)
|
|
388
|
+
|
|
257
389
|
span.set_status(StatusCode.OK)
|
|
258
|
-
|
|
390
|
+
llm_client_attributes = llm_client.attributes
|
|
391
|
+
|
|
259
392
|
span.set_attributes(
|
|
260
393
|
dict(
|
|
261
394
|
chain(
|
|
262
395
|
_output_value_and_mime_type(response_chunks),
|
|
263
|
-
|
|
396
|
+
llm_client_attributes.items(),
|
|
264
397
|
_llm_output_messages(text_chunks, tool_call_chunks),
|
|
265
398
|
)
|
|
266
399
|
)
|
|
@@ -272,8 +405,8 @@ class Subscription:
|
|
|
272
405
|
assert (attributes := finished_span.attributes) is not None
|
|
273
406
|
start_time = _datetime(epoch_nanoseconds=finished_span.start_time)
|
|
274
407
|
end_time = _datetime(epoch_nanoseconds=finished_span.end_time)
|
|
275
|
-
prompt_tokens =
|
|
276
|
-
completion_tokens =
|
|
408
|
+
prompt_tokens = llm_client_attributes.get(LLM_TOKEN_COUNT_PROMPT, 0)
|
|
409
|
+
completion_tokens = llm_client_attributes.get(LLM_TOKEN_COUNT_COMPLETION, 0)
|
|
277
410
|
trace_id = _hex(finished_span.context.trace_id)
|
|
278
411
|
span_id = _hex(finished_span.context.span_id)
|
|
279
412
|
status = finished_span.status
|
|
@@ -367,7 +500,7 @@ def _llm_input_messages(
|
|
|
367
500
|
|
|
368
501
|
def _llm_output_messages(
|
|
369
502
|
text_chunks: List[TextChunk],
|
|
370
|
-
tool_call_chunks: DefaultDict[
|
|
503
|
+
tool_call_chunks: DefaultDict[ToolCallID, List[ToolCallChunk]],
|
|
371
504
|
) -> Iterator[Tuple[str, Any]]:
|
|
372
505
|
yield f"{LLM_OUTPUT_MESSAGES}.0.{MESSAGE_ROLE}", "assistant"
|
|
373
506
|
if content := "".join(chunk.content for chunk in text_chunks):
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_components-
|
|
3
|
-
"file": "assets/components-
|
|
2
|
+
"_components-mVBxvljU.js": {
|
|
3
|
+
"file": "assets/components-mVBxvljU.js",
|
|
4
4
|
"name": "components",
|
|
5
5
|
"imports": [
|
|
6
6
|
"_vendor-6IcPAw_j.js",
|
|
7
|
-
"_vendor-arizeai-
|
|
8
|
-
"_pages-
|
|
7
|
+
"_vendor-arizeai-DRZuoyuF.js",
|
|
8
|
+
"_pages-aAez_Ntk.js",
|
|
9
9
|
"_vendor-three-DwGkEfCM.js",
|
|
10
10
|
"_vendor-codemirror-DVE2_WBr.js"
|
|
11
11
|
]
|
|
12
12
|
},
|
|
13
|
-
"_pages-
|
|
14
|
-
"file": "assets/pages-
|
|
13
|
+
"_pages-aAez_Ntk.js": {
|
|
14
|
+
"file": "assets/pages-aAez_Ntk.js",
|
|
15
15
|
"name": "pages",
|
|
16
16
|
"imports": [
|
|
17
17
|
"_vendor-6IcPAw_j.js",
|
|
18
|
-
"_vendor-arizeai-
|
|
19
|
-
"_components-
|
|
18
|
+
"_vendor-arizeai-DRZuoyuF.js",
|
|
19
|
+
"_components-mVBxvljU.js",
|
|
20
20
|
"_vendor-recharts-DwrexFA4.js",
|
|
21
21
|
"_vendor-codemirror-DVE2_WBr.js"
|
|
22
22
|
]
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"assets/vendor-DxkFTwjz.css"
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
|
-
"_vendor-arizeai-
|
|
39
|
-
"file": "assets/vendor-arizeai-
|
|
38
|
+
"_vendor-arizeai-DRZuoyuF.js": {
|
|
39
|
+
"file": "assets/vendor-arizeai-DRZuoyuF.js",
|
|
40
40
|
"name": "vendor-arizeai",
|
|
41
41
|
"imports": [
|
|
42
42
|
"_vendor-6IcPAw_j.js"
|
|
@@ -61,15 +61,15 @@
|
|
|
61
61
|
"name": "vendor-three"
|
|
62
62
|
},
|
|
63
63
|
"index.tsx": {
|
|
64
|
-
"file": "assets/index-
|
|
64
|
+
"file": "assets/index-BHfTZ6x_.js",
|
|
65
65
|
"name": "index",
|
|
66
66
|
"src": "index.tsx",
|
|
67
67
|
"isEntry": true,
|
|
68
68
|
"imports": [
|
|
69
69
|
"_vendor-6IcPAw_j.js",
|
|
70
|
-
"_vendor-arizeai-
|
|
71
|
-
"_pages-
|
|
72
|
-
"_components-
|
|
70
|
+
"_vendor-arizeai-DRZuoyuF.js",
|
|
71
|
+
"_pages-aAez_Ntk.js",
|
|
72
|
+
"_components-mVBxvljU.js",
|
|
73
73
|
"_vendor-three-DwGkEfCM.js",
|
|
74
74
|
"_vendor-recharts-DwrexFA4.js",
|
|
75
75
|
"_vendor-codemirror-DVE2_WBr.js"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as p,R as j,j as e,n as tn,a as ue,e as Ke,s as n1,b as Ze,c as me,d as c1,f as kt,g as oe,h as St,i as xt,k as d1,l as s,m as Mt,o as Te,C as Qe,p as Oe,q as De,t as X,u as Tt,v as It,w as an,x as m,L as rn,y as Et,N as Vt,z as Pt,A as Ot,$ as D,B as qe,D as Dt,E as _t,F as Ft,G as At,H as V1,I as de,J as ge,K as Rt,M as ln,S as Nt,O as zt,Q as P1,P as Ht,T as Kt,U as $t,V as t1,W as h1,X as Bt,Y as Zt,Z as Gt,_ as Qt,a0 as Ut,a1 as Wt,a2 as jt,a3 as qt,a4 as Xt,a5 as _e,a6 as _,a7 as on,a8 as Yt,a9 as Jt,aa as ea,ab as na,ac as ta,ad as aa,ae as ra,af as sn,ag as cn,ah as dn,ai as Y,aj as ia}from"./vendor-6IcPAw_j.js";import{u as la,A as oa,I as E,a as S,_ as un,b as y,c as M,d as v,e as H,f as q,T as $,g as sa,h as ee,i as we,j as P,F as mn,k as N,l as ca,m as da,P as ua,R as U,n as Fe,o as ma,p as pa,L as fe,q as ne,r as te,s as Ae,t as pn,v as hn,E as gn,w as ha,x as ga,y as fa,z as La,B as fn,C as g1,D as Ca,G as ba,H as O1,J as ya}from"./vendor-arizeai-
|
|
1
|
+
import{r as p,R as j,j as e,n as tn,a as ue,e as Ke,s as n1,b as Ze,c as me,d as c1,f as kt,g as oe,h as St,i as xt,k as d1,l as s,m as Mt,o as Te,C as Qe,p as Oe,q as De,t as X,u as Tt,v as It,w as an,x as m,L as rn,y as Et,N as Vt,z as Pt,A as Ot,$ as D,B as qe,D as Dt,E as _t,F as Ft,G as At,H as V1,I as de,J as ge,K as Rt,M as ln,S as Nt,O as zt,Q as P1,P as Ht,T as Kt,U as $t,V as t1,W as h1,X as Bt,Y as Zt,Z as Gt,_ as Qt,a0 as Ut,a1 as Wt,a2 as jt,a3 as qt,a4 as Xt,a5 as _e,a6 as _,a7 as on,a8 as Yt,a9 as Jt,aa as ea,ab as na,ac as ta,ad as aa,ae as ra,af as sn,ag as cn,ah as dn,ai as Y,aj as ia}from"./vendor-6IcPAw_j.js";import{u as la,A as oa,I as E,a as S,_ as un,b as y,c as M,d as v,e as H,f as q,T as $,g as sa,h as ee,i as we,j as P,F as mn,k as N,l as ca,m as da,P as ua,R as U,n as Fe,o as ma,p as pa,L as fe,q as ne,r as te,s as Ae,t as pn,v as hn,E as gn,w as ha,x as ga,y as fa,z as La,B as fn,C as g1,D as Ca,G as ba,H as O1,J as ya}from"./vendor-arizeai-DRZuoyuF.js";import{u as va}from"./pages-aAez_Ntk.js";import{V as wa}from"./vendor-three-DwGkEfCM.js";import{j as Ln,E as Cn,l as u1,a as bn,h as ka,b as Sa,c as xa,d as Ma,e as Ta,f as Ia,s as Ea,R as Re,g as yn,n as Ne,p as Va,i as Pa,L as vn,k as wn}from"./vendor-codemirror-DVE2_WBr.js";const kn=function(){var n={defaultValue:null,kind:"LocalArgument",name:"clusters"},t={defaultValue:null,kind:"LocalArgument",name:"dataQualityMetricColumnName"},a={defaultValue:null,kind:"LocalArgument",name:"fetchDataQualityMetric"},r={defaultValue:null,kind:"LocalArgument",name:"fetchPerformanceMetric"},i={defaultValue:null,kind:"LocalArgument",name:"performanceMetric"},l=[{alias:null,args:null,kind:"ScalarField",name:"primaryValue",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"referenceValue",storageKey:null}],o=[{alias:null,args:[{kind:"Variable",name:"clusters",variableName:"clusters"}],concreteType:"Cluster",kind:"LinkedField",name:"clusters",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"eventIds",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"driftRatio",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"primaryToCorpusRatio",storageKey:null},{condition:"fetchDataQualityMetric",kind:"Condition",passingValue:!0,selections:[{alias:null,args:[{fields:[{kind:"Variable",name:"columnName",variableName:"dataQualityMetricColumnName"},{kind:"Literal",name:"metric",value:"mean"}],kind:"ObjectValue",name:"metric"}],concreteType:"DatasetValues",kind:"LinkedField",name:"dataQualityMetric",plural:!1,selections:l,storageKey:null}]},{condition:"fetchPerformanceMetric",kind:"Condition",passingValue:!0,selections:[{alias:null,args:[{fields:[{kind:"Variable",name:"metric",variableName:"performanceMetric"}],kind:"ObjectValue",name:"metric"}],concreteType:"DatasetValues",kind:"LinkedField",name:"performanceMetric",plural:!1,selections:l,storageKey:null}]}],storageKey:null}];return{fragment:{argumentDefinitions:[n,t,a,r,i],kind:"Fragment",metadata:null,name:"pointCloudStore_clusterMetricsQuery",selections:o,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,a,t,r,i],kind:"Operation",name:"pointCloudStore_clusterMetricsQuery",selections:o},params:{cacheID:"86666967012812887ac0a0149d2d2535",id:null,metadata:{},name:"pointCloudStore_clusterMetricsQuery",operationKind:"query",text:`query pointCloudStore_clusterMetricsQuery(
|
|
2
2
|
$clusters: [ClusterInput!]!
|
|
3
3
|
$fetchDataQualityMetric: Boolean!
|
|
4
4
|
$dataQualityMetricColumnName: String
|
|
@@ -144,7 +144,7 @@ import{r as p,R as j,j as e,n as tn,a as ue,e as Ke,s as n1,b as Ze,c as me,d as
|
|
|
144
144
|
id
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
`}}}();Mn.hash="e8fa488a0d466b5e40fdadc1e5227a57";const Oa=30,D1=5,_1=100,Da=0,F1=0,A1=.99,_a=500,R1=300,N1=1e5,Fa=10,z1=1,Aa=2,Ra=1,Na=0;var I=(n=>(n.inferences="inferences",n.correctness="correctness",n.dimension="dimension",n))(I||{}),Ce=(n=>(n.list="list",n.gallery="gallery",n))(Ce||{}),Le=(n=>(n.small="small",n.medium="medium",n.large="large",n))(Le||{}),V=(n=>(n.primary="primary",n.reference="reference",n.corpus="corpus",n))(V||{}),A=(n=>(n.correct="correct",n.incorrect="incorrect",n.unknown="unknown",n))(A||{});const za=["#05fbff","#cb8afd"],Ha=["#00add0","#4500d9"],J="#a5a5a5",pe=J;var W=(n=>(n.primary="primary",n.reference="reference",n.corpus="corpus",n))(W||{});function F(n){throw new Error("Unreachable")}function f1(n){return typeof n=="number"||n===null}function Ka(n){return typeof n=="string"||n===null}function so(n){return Array.isArray(n)?n.every(t=>typeof t=="string"):!1}function $a(n){return typeof n=="object"&&n!==null}const co=()=>n=>n,L1=p.createContext(null);function Xe(){const n=j.useContext(L1);if(n===null)throw new Error("useInferences must be used within a InferencesProvider");return n}function uo(n){return e(L1.Provider,{value:{primaryInferences:n.primaryInferences,referenceInferences:n.referenceInferences,corpusInferences:n.corpusInferences,getInferencesNameByRole:t=>{var a,r;switch(t){case W.primary:return n.primaryInferences.name;case W.reference:return((a=n.referenceInferences)==null?void 0:a.name)??"reference";case W.corpus:return((r=n.corpusInferences)==null?void 0:r.name)??"corpus";default:F()}}},children:n.children})}const C1=p.createContext(null);function mo({children:n,...t}){const[a]=p.useState(()=>sr(t));return e(C1.Provider,{value:a,children:n})}function b(n,t){const a=p.useContext(C1);if(!a)throw new Error("Missing PointCloudContext.Provider in the tree");return tn(a,n,t)}var G=(n=>(n.last_hour="Last Hour",n.last_day="Last Day",n.last_week="Last Week",n.last_month="Last Month",n.last_3_months="Last 3 Months",n.first_hour="First Hour",n.first_day="First Day",n.first_week="First Week",n.first_month="First Month",n.all="All",n))(G||{});const Tn=p.createContext(null);function Ba(){const n=p.useContext(Tn);if(n===null)throw new Error("useTimeRange must be used within a TimeRangeProvider");return n}function Za(n,t){return p.useMemo(()=>{switch(n){case"Last Hour":{const r=ue(xt(t.end),{roundingMethod:"ceil"});return{start:d1(r,1),end:r}}case"Last Day":{const r=ue(St(t.end),{roundingMethod:"ceil"});return{start:oe(r,1),end:r}}case"Last Week":{const r=ue(Ke(t.end),{roundingMethod:"ceil"});return{start:oe(r,7),end:r}}case"Last Month":{const r=ue(Ke(t.end),{roundingMethod:"ceil"});return{start:oe(r,30),end:r}}case"Last 3 Months":{const r=ue(Ke(t.end),{roundingMethod:"ceil"});return{start:oe(r,90),end:r}}case"First Hour":{const r=c1(t.start);return{start:r,end:kt(r,1)}}case"First Day":{const r=me(t.start);return{start:r,end:Ze(r,1)}}case"First Week":{const r=n1(t.start);return{start:r,end:Ze(r,7)}}case"First Month":{const r=n1(t.start);return{start:r,end:Ze(r,30)}}case"All":{const r=ue(Ke(t.end),{roundingMethod:"floor"});return{start:n1(t.start),end:r}}default:F()}},[n,t])}function po(n){const[t,a]=p.useState("Last Month"),r=Za(t,n.timeRangeBounds),i=p.useCallback(l=>{p.startTransition(()=>{a(l)})},[]);return e(Tn.Provider,{value:{timeRange:r,timePreset:t,setTimePreset:i},children:n.children})}const In=p.createContext(null);function ho({children:n}){const[t,a]=la({style:{zIndex:1e3}}),r=p.useCallback(l=>{t({variant:"danger",...l})},[t]),i=p.useCallback(l=>{t({variant:"success",...l})},[t]);return s(In.Provider,{value:{notify:t,notifyError:r,notifySuccess:i},children:[n,a]})}function En(){const n=p.useContext(In);if(n===null)throw new Error("useGlobalNotification must be used within a NotificationProvider");return n}function go(){return En().notifyError}function fo(){return En().notifySuccess}const Vn="arize-phoenix-theme";function Pn(){return localStorage.getItem(Vn)==="light"?"light":"dark"}const b1=p.createContext(null);function B(){const n=p.useContext(b1);if(n===null)throw new Error("useTheme must be used within a ThemeProvider");return n}function Lo(n){const[t,a]=p.useState(Pn()),r=p.useCallback(i=>{localStorage.setItem(Vn,i),a(i)},[]);return e(b1.Provider,{value:{theme:t,setTheme:r},children:n.children})}function Ga(n){return n.endsWith("/")?n.slice(0,-1):n}const On=Ga(window.Config.basename),Qa=window.location.protocol==="https:",ze=`${window.location.protocol}//${window.location.host}${On}`,Ua=`${Qa?"wss":"ws"}://${window.location.host}${On}`,Co=window.Config.platformVersion,Ue="returnUrl",Wa=()=>window.location.pathname+window.location.search,ja=()=>`${Ue}=${encodeURIComponent(Wa())}`,bo=({path:n,searchParams:t})=>{const r=new URL(window.location.href).searchParams.get(Ue),i=new URLSearchParams(t||{});r&&i.set(Ue,r);const l=i.toString();return`${n}${l?`?${l}`:""}`},qa=n=>!(typeof n!="string"||!n.startsWith("/")||n.replace(/\\/g,"/").startsWith("//")),Xa=n=>qa(n)?n:"/",yo=()=>{const n=new URL(window.location.href);return Xa(n.searchParams.get(Ue))},Ya=ze+"/auth/refresh";class H1 extends Error{constructor(){super("Unauthorized")}}async function Ja(n,t){try{return await fetch(n,t).then(a=>{if(a.status===401)throw new H1;return a})}catch(a){if(a instanceof H1)return await er(),fetch(n,t)}throw new Error("An unexpected error occurred while fetching data")}let xe=null;async function er(){return xe||(xe=fetch(Ya,{method:"POST"}).then(n=>(n.ok||(window.location.href=`/login?${ja()}`),xe=null,n)),xe)}const nr=ze+"/graphql",tr=window.Config.authenticationEnabled?Ja:fetch,ar=async(n,t,a)=>{const i=await(await tr(nr,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:n.text,variables:t})})).json();if(Array.isArray(i.errors))throw new Error(`Error fetching GraphQL query '${n.name}' with variables '${JSON.stringify(t)}': ${JSON.stringify(i.errors)}`);return i},rr=Mt({url:`${Ua}/graphql`}),ir=(n,t)=>Te.Observable.create(a=>rr.subscribe({operationName:n.name,query:n.text,variables:t},a)),He=new Te.Environment({network:Te.Network.create(ar,ir),store:new Te.Store(new Te.RecordSource,{gcReleaseBufferSize:10})});function Dn(n){return n.includes("PRIMARY")?W.primary:n.includes("CORPUS")?W.corpus:W.reference}function y1(n){const t=[],a=[],r=[];return n.forEach(i=>{const l=Dn(i);l==W.primary?t.push(i):l==W.corpus?r.push(i):a.push(i)}),{primaryEventIds:t,referenceEventIds:a,corpusEventIds:r}}const We=10,Ie="unknown",_n=It,Fn=Tt,lr=n=>Fn[n],or=n=>_n(n/We);var be=(n=>(n.move="move",n.select="select",n))(be||{}),v1=(n=>(n.default="default",n.highlight="highlight",n))(v1||{});const he=()=>Pn()==="light"?Ha:za;function vo(){const n=he();return{coloringStrategy:I.inferences,pointGroupVisibility:{[V.primary]:!0,[V.reference]:!0},pointGroupColors:{[V.primary]:n[0],[V.reference]:n[1],[V.corpus]:J},metric:{type:"drift",metric:"euclideanDistance"}}}function wo(){const n=he();return{coloringStrategy:I.inferences,pointGroupVisibility:{[V.primary]:!0,[V.corpus]:!0},pointGroupColors:{[V.primary]:n[0],[V.corpus]:J},metric:{type:"retrieval",metric:"queryDistance"},clusterSort:{dir:"desc",column:"primaryMetricValue"}}}function ko(){return{coloringStrategy:I.correctness,pointGroupVisibility:{[A.correct]:!0,[A.incorrect]:!0,[A.unknown]:!0},pointGroupColors:{[A.correct]:Qe.Discrete2.LightBlueOrange[0],[A.incorrect]:Qe.Discrete2.LightBlueOrange[1],[A.unknown]:pe},metric:{type:"performance",metric:"accuracyScore"},clusterSort:{dir:"asc",column:"primaryMetricValue"}}}const sr=n=>{const t={loading:!1,errorMessage:null,points:[],eventIdToDataMap:new Map,clusters:[],clusterSort:{dir:"desc",column:"driftRatio"},pointData:null,selectedEventIds:new Set,hoveredEventId:null,highlightedClusterId:null,selectedClusterId:null,canvasMode:"move",pointSizeScale:1,clusterColorMode:"default",coloringStrategy:I.inferences,inferencesVisibility:{primary:!0,reference:!0,corpus:!0},pointGroupVisibility:{[V.primary]:!0,[V.reference]:!0,[V.corpus]:!0},pointGroupColors:{[V.primary]:he()[0],[V.reference]:he()[1],[V.corpus]:J},eventIdToGroup:{},selectionDisplay:Ce.gallery,selectionGridSize:Le.large,dimension:null,dimensionMetadata:null,umapParameters:{minDist:Da,nNeighbors:Oa,nSamples:_a},hdbscanParameters:{minClusterSize:Fa,clusterMinSamples:Ra,clusterSelectionEpsilon:Na},clustersLoading:!1,metric:{type:"drift",metric:"euclideanDistance"},selectionSearchText:""},a=(r,i)=>({...t,...n,setInitialData:async({points:l,clusters:o,retrievals:d})=>{const c=i(),u=new Map,g=d.reduce((L,C)=>{const{queryId:k}=C;return L[k]?L[k].push(C):L[k]=[C],L},{});l.forEach(L=>{L={...L,retrievals:g[L.eventId]??[]},u.set(L.eventId,L)});const h=o.map($1).sort(r1(c.clusterSort));r({loading:!1,points:l,eventIdToDataMap:u,clusters:h,clustersLoading:!1,selectedEventIds:new Set,selectedClusterId:null,pointData:null,eventIdToGroup:le({points:l,coloringStrategy:c.coloringStrategy,pointsData:c.pointData??{},dimension:c.dimension||null,dimensionMetadata:c.dimensionMetadata})});const f=await ur(l.map(L=>L.eventId)).catch(()=>r({errorMessage:"Failed to load the point events"}));f&&r({pointData:f,clusters:h,clustersLoading:!1,eventIdToGroup:le({points:l,coloringStrategy:c.coloringStrategy,pointsData:f??{},dimension:c.dimension||null,dimensionMetadata:c.dimensionMetadata})})},setClusters:l=>{const o=i(),d=l.map($1).sort(r1(o.clusterSort));r({clusters:d,clustersLoading:!1,selectedClusterId:null,highlightedClusterId:null})},setClusterSort:l=>{const d=[...i().clusters].sort(r1(l));r({clusterSort:l,clusters:d})},setSelectedEventIds:l=>r({selectedEventIds:l,selectionSearchText:""}),setHoveredEventId:l=>r({hoveredEventId:l}),setHighlightedClusterId:l=>r({highlightedClusterId:l}),setSelectedClusterId:l=>r({selectedClusterId:l,highlightedClusterId:null}),setPointSizeScale:l=>r({pointSizeScale:l}),setCanvasMode:l=>r({canvasMode:l}),setClusterColorMode:l=>r({clusterColorMode:l}),setColoringStrategy:l=>{const o=i();switch(r({coloringStrategy:l}),l){case I.correctness:r({pointGroupVisibility:{[A.correct]:!0,[A.incorrect]:!0,[A.unknown]:!0},pointGroupColors:{[A.correct]:Qe.Discrete2.LightBlueOrange[0],[A.incorrect]:Qe.Discrete2.LightBlueOrange[1],[A.unknown]:pe},dimension:null,dimensionMetadata:null,eventIdToGroup:le({points:o.points,coloringStrategy:l,pointsData:o.pointData??{},dimension:o.dimension||null,dimensionMetadata:o.dimensionMetadata})});break;case I.inferences:{r({pointGroupVisibility:{[V.primary]:!0,[V.reference]:!0,[V.corpus]:!0},pointGroupColors:{[V.primary]:he()[0],[V.reference]:he()[1],[V.corpus]:J},dimension:null,dimensionMetadata:null,eventIdToGroup:le({points:o.points,coloringStrategy:l,pointsData:o.pointData??{},dimension:o.dimension||null,dimensionMetadata:o.dimensionMetadata})});break}case I.dimension:{r({pointGroupVisibility:{unknown:!0},pointGroupColors:{unknown:pe},dimension:null,dimensionMetadata:null,eventIdToGroup:le({points:o.points,coloringStrategy:l,pointsData:o.pointData??{},dimension:o.dimension||null,dimensionMetadata:o.dimensionMetadata})});break}default:F()}},inferencesVisibility:{primary:!0,reference:!0,corpus:!0},setInferencesVisibility:l=>r({inferencesVisibility:l}),setPointGroupVisibility:l=>r({pointGroupVisibility:l}),selectionDisplay:Ce.gallery,setSelectionDisplay:l=>r({selectionDisplay:l}),setSelectionGridSize:l=>r({selectionGridSize:l}),reset:()=>{r({points:[],clusters:[],selectedEventIds:new Set,selectedClusterId:null,eventIdToGroup:{}})},setDimension:async l=>{const o=i();r({dimension:l,dimensionMetadata:null});const d=await dr(l).catch(()=>r({errorMessage:"Failed to load the dimension metadata"}));if(d){if(r({dimensionMetadata:d}),d.categories&&d.categories.length){const c=d.categories.length,g=c<=Fn.length?lr:h=>_n(h/c);r({pointGroupVisibility:{...d.categories.reduce((h,f)=>({...h,[f]:!0}),{}),unknown:!0},pointGroupColors:{...d.categories.reduce((h,f,L)=>({...h,[f]:g(L)}),{}),unknown:pe},eventIdToGroup:le({points:o.points,coloringStrategy:o.coloringStrategy,pointsData:o.pointData??{},dimension:l,dimensionMetadata:d})})}else if(d.interval!==null){const c=An(d.interval);r({pointGroupVisibility:{...c.reduce((u,g)=>({...u,[g.name]:!0}),{}),unknown:!0},pointGroupColors:{...c.reduce((u,g,h)=>({...u,[g.name]:or(h)}),{}),unknown:pe},eventIdToGroup:le({points:o.points,coloringStrategy:o.coloringStrategy,pointsData:o.pointData??{},dimension:l,dimensionMetadata:d})})}}},setDimensionMetadata:l=>r({dimensionMetadata:l}),setUMAPParameters:l=>r({umapParameters:l}),setHDBSCANParameters:async l=>{const o=i();r({hdbscanParameters:l,clustersLoading:!0});const d=await mr({metric:o.metric,points:o.points,hdbscanParameters:l});o.setClusters(d)},getHDSCANParameters:()=>i().hdbscanParameters,getMetric:()=>i().metric,setErrorMessage:l=>r({errorMessage:l}),setLoading:l=>r({loading:l}),setMetric:async l=>{const o=i();r({metric:l,clustersLoading:!0});const d=await pr({metric:l,clusters:o.clusters,hdbscanParameters:o.hdbscanParameters});o.setClusters(d)},setSelectionSearchText:l=>r({selectionSearchText:l})});return Oe()(De(a))},K1=new Intl.NumberFormat([],{maximumFractionDigits:2});function cr({min:n,max:t}){return`${K1.format(n)} - ${K1.format(t)}`}function An({min:n,max:t}){const r=(t-n)/We,i=[];for(let l=0;l<We;l++){const o=n+l*r,d=n+(l+1)*r;i.push({min:o,max:d,name:cr({min:o,max:d})})}return i}function a1({numericGroupIntervals:n,numericValue:t}){let a=Ie,r=n.findIndex(i=>t>=i.min&&t<i.max);return r=r===-1?We-1:r,a=n[r].name,a}function le(n){const{points:t,coloringStrategy:a,pointsData:r,dimension:i,dimensionMetadata:l}=n,o={},d=t.map(c=>c.eventId);switch(a){case I.inferences:{const{primaryEventIds:c,referenceEventIds:u,corpusEventIds:g}=y1(d);c.forEach(h=>{o[h]=V.primary}),u.forEach(h=>{o[h]=V.reference}),g.forEach(h=>{o[h]=V.corpus});break}case I.correctness:{t.forEach(c=>{let u=A.unknown;const{predictionLabel:g,actualLabel:h}=c.eventMetadata;g!==null&&h!==null&&(u=g===h?A.correct:A.incorrect),o[c.eventId]=u});break}case I.dimension:{let c;l&&(l==null?void 0:l.interval)!==null&&(c=An(l.interval));const u=(i==null?void 0:i.type)==="prediction"&&(i==null?void 0:i.dataType)==="categorical",g=(i==null?void 0:i.type)==="prediction"&&(i==null?void 0:i.dataType)==="numeric",h=(i==null?void 0:i.type)==="actual"&&(i==null?void 0:i.dataType)==="categorical",f=(i==null?void 0:i.type)==="actual"&&(i==null?void 0:i.dataType)==="numeric";t.forEach(L=>{let C=Ie;const k=r[L.eventId];if(i!=null&&k!=null)if(u)C=k.eventMetadata.predictionLabel??Ie;else if(g){if(c==null)throw new Error("Cannot color by prediction score without numeric group intervals");const x=k.eventMetadata.predictionScore;typeof x=="number"&&(C=a1({numericGroupIntervals:c,numericValue:x}))}else if(f){if(c==null)throw new Error("Cannot color by actual score without numeric group intervals");const x=k.eventMetadata.actualScore;typeof x=="number"&&(C=a1({numericGroupIntervals:c,numericValue:x}))}else if(h)C=k.eventMetadata.actualLabel??Ie;else{const x=k.dimensions.find(R=>R.dimension.name===i.name);if(x!=null&&i.dataType==="categorical")C=x.value??Ie;else if(x!=null&&i.dataType==="numeric"&&c!=null){const R=typeof(x==null?void 0:x.value)=="string"?parseFloat(x.value):null;typeof R=="number"&&(C=a1({numericGroupIntervals:c,numericValue:R}))}}o[L.eventId]=C});break}default:F()}return o}async function dr(n){const t=await X.fetchQuery(He,Mn,{id:n.id,getDimensionMinMax:n.dataType==="numeric",getDimensionCategories:n.dataType==="categorical"}).toPromise(),a=t==null?void 0:t.dimension;if(!n)throw new Error("Dimension not found");let r=null;return typeof(a==null?void 0:a.min)=="number"&&typeof(a==null?void 0:a.max)=="number"&&(r={min:a.min,max:a.max}),{interval:r,categories:(a==null?void 0:a.categories)??null}}async function ur(n){var u,g,h,f,L,C;const{primaryEventIds:t,referenceEventIds:a,corpusEventIds:r}=y1([...n]),i=await X.fetchQuery(He,xn,{primaryEventIds:t,referenceEventIds:a,corpusEventIds:r}).toPromise(),l=((g=(u=i==null?void 0:i.model)==null?void 0:u.primaryInferences)==null?void 0:g.events)??[],o=((f=(h=i==null?void 0:i.model)==null?void 0:h.referenceInferences)==null?void 0:f.events)??[],d=((C=(L=i==null?void 0:i.model)==null?void 0:L.corpusInferences)==null?void 0:C.events)??[];return[...l,...o,...d].reduce((k,z)=>(k[z.id]=z,k),{})}async function mr({metric:n,points:t,hdbscanParameters:a}){const r=await X.fetchQuery(He,Sn,{eventIds:t.map(i=>i.eventId),coordinates:t.map(i=>({x:i.position[0],y:i.position[1],z:i.position[2]})),fetchDataQualityMetric:n.type==="dataQuality",dataQualityMetricColumnName:n.type==="dataQuality"?n.dimension.name:null,fetchPerformanceMetric:n.type==="performance",performanceMetric:n.type==="performance"?n.metric:"accuracyScore",...a},{fetchPolicy:"network-only"}).toPromise();return(r==null?void 0:r.hdbscanClustering)??[]}async function pr({metric:n,clusters:t,hdbscanParameters:a}){const r=await X.fetchQuery(He,kn,{clusters:t.map(i=>({id:i.id,eventIds:i.eventIds})),fetchDataQualityMetric:n.type==="dataQuality",dataQualityMetricColumnName:n.type==="dataQuality"?n.dimension.name:null,fetchPerformanceMetric:n.type==="performance",performanceMetric:n.type==="performance"?n.metric:"accuracyScore",...a},{fetchPolicy:"network-only"}).toPromise();return(r==null?void 0:r.clusters)??[]}const r1=n=>(t,a)=>{const{dir:r,column:i}=n,l=r==="asc",o=t[i],d=a[i];return o==null?1:d==null?-1:o>d?l?1:-1:o<d?l?-1:1:0};function $1(n){let t=n.driftRatio,a=null;return n.dataQualityMetric?(t=n.dataQualityMetric.primaryValue,a=n.dataQualityMetric.referenceValue):n.performanceMetric?(t=n.performanceMetric.primaryValue,a=n.performanceMetric.referenceValue):n.primaryToCorpusRatio!=null&&(t=(n.primaryToCorpusRatio+1)/2*100),{...n,size:n.eventIds.length,primaryMetricValue:t,referenceMetricValue:a}}const So=n=>{const t=a=>({...n,columnVisibility:{metadata:!1},annotationColumnVisibility:{},setColumnVisibility:r=>{a({columnVisibility:r})},setAnnotationColumnVisibility:r=>{a({annotationColumnVisibility:r})}});return Oe()(De(t))},ye={FString:"F_STRING",Mustache:"MUSTACHE"},xo={OPENAI:"OpenAI",AZURE_OPENAI:"Azure OpenAI",ANTHROPIC:"Anthropic"},hr="OPENAI",gr="user",Mo=["2024-10-01-preview","2024-09-01-preview","2024-08-01-preview","2024-07-01-preview","2024-06-01","2024-05-01-preview","2024-04-01-preview","2024-03-01-preview","2024-02-15-preview","2024-02-01","2023-10-01-preview","2023-09-01-preview","2023-08-01-preview","2023-07-01-preview","2023-06-01-preview","2023-05-15","2023-03-15-preview"],fr=n=>"variablesValueCache"in n;let Lr=0,B1=0,Cr=1,br=0;const Rn=()=>Lr++,Z1=()=>Cr++,yr=()=>br++,Nn=()=>({__type:"chat",messages:[{id:Z1(),role:"system",content:"You are a chatbot"},{id:Z1(),role:"user",content:"{{question}}"}]}),vr={__type:"text_completion",prompt:"{{question}}"};function wr(){return{id:Rn(),template:Nn(),model:{provider:hr,modelName:"gpt-4o"},tools:[],toolChoice:"auto",input:{variablesValueCache:{}},output:void 0,spanId:null,activeRunId:null,isRunning:!1}}function To(n){return{id:yr(),definition:{type:"function",function:{name:`new_function_${n}`,parameters:{type:"object",properties:{new_arg:{type:"string"}},required:[]}}}}}const Io=n=>Oe(De((a,r)=>({operationType:"chat",inputMode:"manual",input:{variablesValueCache:{}},templateLanguage:ye.Mustache,setInputMode:i=>a({inputMode:i}),instances:[wr()],setOperationType:i=>{a(i==="chat"?{instances:r().instances.map(l=>({...l,template:Nn()}))}:{instances:r().instances.map(l=>({...l,template:vr}))}),a({operationType:i})},addInstance:()=>{const i=r().instances,l=r().instances[0];l&&a({instances:[...i,{...l,id:Rn(),activeRunId:null,isRunning:!1,spanId:null}]})},updateModel:({instanceId:i,model:l})=>{const o=r().instances,d=o.find(u=>u.id===i);if(!d)return;const c=d.model;l.provider!==c.provider&&(l={...l,modelName:void 0}),a({instances:o.map(u=>u.id===i?{...u,model:{...u.model,...l}}:u)})},deleteInstance:i=>{const l=r().instances;a({instances:l.filter(o=>o.id!==i)})},addMessage:({playgroundInstanceId:i})=>{const l=r().instances;a({instances:l.map(o=>o.id===i&&(o!=null&&o.template)&&(o==null?void 0:o.template.__type)==="chat"?{...o,messages:[...o.template.messages,{role:gr,content:"{question}"}]}:o)})},updateInstance:({instanceId:i,patch:l})=>{const o=r().instances;a({instances:o.map(d=>d.id===i?{...d,...l}:d)})},runPlaygroundInstances:()=>{const i=r().instances;a({instances:i.map(l=>({...l,activeRunId:B1++,isRunning:!0,spanId:null}))})},runPlaygroundInstance:i=>{const l=r().instances;a({instances:l.map(o=>o.id===i?{...o,activeRunId:B1++,isRunning:!0,spanId:null}:o)})},markPlaygroundInstanceComplete:i=>{const l=r().instances;a({instances:l.map(o=>o.id===i?{...o,isRunning:!1}:o)})},setTemplateLanguage:i=>{a({templateLanguage:i})},setVariableValue:(i,l)=>{const o=r().input;fr(o)&&a({input:{...o,variablesValueCache:{...o.variablesValueCache,[i]:l}}})},...n}))),Eo=n=>{const t=a=>({setCredential:({provider:r,value:i})=>{a({[r]:i})},...n});return Oe()(an(De(t),{name:"arize-phoenix-credentials"}))},kr=n=>{const t=a=>({markdownDisplayMode:"text",setMarkdownDisplayMode:r=>{a({markdownDisplayMode:r})},traceStreamingEnabled:!0,setTraceStreamingEnabled:r=>{a({traceStreamingEnabled:r})},lastNTimeRangeKey:"7d",setLastNTimeRangeKey:r=>{a({lastNTimeRangeKey:r})},projectsAutoRefreshEnabled:!0,setProjectAutoRefreshEnabled:r=>{a({projectsAutoRefreshEnabled:r})},showSpanAside:!0,setShowSpanAside:r=>{a({showSpanAside:r})},showMetricsInTraceTree:!0,setShowMetricsInTraceTree:r=>{a({showMetricsInTraceTree:r})},...n});return Oe()(an(De(t),{name:"arize-phoenix-preferences"}))},zn=p.createContext(null);function Vo({children:n,...t}){const[a]=p.useState(()=>kr(t));return e(zn.Provider,{value:a,children:n})}function ce(n,t){const a=j.useContext(zn);if(!a)throw new Error("Missing PreferencesContext.Provider in the tree");return tn(a,n,t)}function Hn(n){return e("div",{onClick:t=>t.stopPropagation(),css:m`
|
|
147
|
+
`}}}();Mn.hash="e8fa488a0d466b5e40fdadc1e5227a57";const Oa=30,D1=5,_1=100,Da=0,F1=0,A1=.99,_a=500,R1=300,N1=1e5,Fa=10,z1=1,Aa=2,Ra=1,Na=0;var I=(n=>(n.inferences="inferences",n.correctness="correctness",n.dimension="dimension",n))(I||{}),Ce=(n=>(n.list="list",n.gallery="gallery",n))(Ce||{}),Le=(n=>(n.small="small",n.medium="medium",n.large="large",n))(Le||{}),V=(n=>(n.primary="primary",n.reference="reference",n.corpus="corpus",n))(V||{}),A=(n=>(n.correct="correct",n.incorrect="incorrect",n.unknown="unknown",n))(A||{});const za=["#05fbff","#cb8afd"],Ha=["#00add0","#4500d9"],J="#a5a5a5",pe=J;var W=(n=>(n.primary="primary",n.reference="reference",n.corpus="corpus",n))(W||{});function F(n){throw new Error("Unreachable")}function f1(n){return typeof n=="number"||n===null}function Ka(n){return typeof n=="string"||n===null}function so(n){return Array.isArray(n)?n.every(t=>typeof t=="string"):!1}function $a(n){return typeof n=="object"&&n!==null}const co=()=>n=>n,L1=p.createContext(null);function Xe(){const n=j.useContext(L1);if(n===null)throw new Error("useInferences must be used within a InferencesProvider");return n}function uo(n){return e(L1.Provider,{value:{primaryInferences:n.primaryInferences,referenceInferences:n.referenceInferences,corpusInferences:n.corpusInferences,getInferencesNameByRole:t=>{var a,r;switch(t){case W.primary:return n.primaryInferences.name;case W.reference:return((a=n.referenceInferences)==null?void 0:a.name)??"reference";case W.corpus:return((r=n.corpusInferences)==null?void 0:r.name)??"corpus";default:F()}}},children:n.children})}const C1=p.createContext(null);function mo({children:n,...t}){const[a]=p.useState(()=>sr(t));return e(C1.Provider,{value:a,children:n})}function b(n,t){const a=p.useContext(C1);if(!a)throw new Error("Missing PointCloudContext.Provider in the tree");return tn(a,n,t)}var G=(n=>(n.last_hour="Last Hour",n.last_day="Last Day",n.last_week="Last Week",n.last_month="Last Month",n.last_3_months="Last 3 Months",n.first_hour="First Hour",n.first_day="First Day",n.first_week="First Week",n.first_month="First Month",n.all="All",n))(G||{});const Tn=p.createContext(null);function Ba(){const n=p.useContext(Tn);if(n===null)throw new Error("useTimeRange must be used within a TimeRangeProvider");return n}function Za(n,t){return p.useMemo(()=>{switch(n){case"Last Hour":{const r=ue(xt(t.end),{roundingMethod:"ceil"});return{start:d1(r,1),end:r}}case"Last Day":{const r=ue(St(t.end),{roundingMethod:"ceil"});return{start:oe(r,1),end:r}}case"Last Week":{const r=ue(Ke(t.end),{roundingMethod:"ceil"});return{start:oe(r,7),end:r}}case"Last Month":{const r=ue(Ke(t.end),{roundingMethod:"ceil"});return{start:oe(r,30),end:r}}case"Last 3 Months":{const r=ue(Ke(t.end),{roundingMethod:"ceil"});return{start:oe(r,90),end:r}}case"First Hour":{const r=c1(t.start);return{start:r,end:kt(r,1)}}case"First Day":{const r=me(t.start);return{start:r,end:Ze(r,1)}}case"First Week":{const r=n1(t.start);return{start:r,end:Ze(r,7)}}case"First Month":{const r=n1(t.start);return{start:r,end:Ze(r,30)}}case"All":{const r=ue(Ke(t.end),{roundingMethod:"floor"});return{start:n1(t.start),end:r}}default:F()}},[n,t])}function po(n){const[t,a]=p.useState("Last Month"),r=Za(t,n.timeRangeBounds),i=p.useCallback(l=>{p.startTransition(()=>{a(l)})},[]);return e(Tn.Provider,{value:{timeRange:r,timePreset:t,setTimePreset:i},children:n.children})}const In=p.createContext(null);function ho({children:n}){const[t,a]=la({style:{zIndex:1e3}}),r=p.useCallback(l=>{t({variant:"danger",...l})},[t]),i=p.useCallback(l=>{t({variant:"success",...l})},[t]);return s(In.Provider,{value:{notify:t,notifyError:r,notifySuccess:i},children:[n,a]})}function En(){const n=p.useContext(In);if(n===null)throw new Error("useGlobalNotification must be used within a NotificationProvider");return n}function go(){return En().notifyError}function fo(){return En().notifySuccess}const Vn="arize-phoenix-theme";function Pn(){return localStorage.getItem(Vn)==="light"?"light":"dark"}const b1=p.createContext(null);function B(){const n=p.useContext(b1);if(n===null)throw new Error("useTheme must be used within a ThemeProvider");return n}function Lo(n){const[t,a]=p.useState(Pn()),r=p.useCallback(i=>{localStorage.setItem(Vn,i),a(i)},[]);return e(b1.Provider,{value:{theme:t,setTheme:r},children:n.children})}function Ga(n){return n.endsWith("/")?n.slice(0,-1):n}const On=Ga(window.Config.basename),Qa=window.location.protocol==="https:",ze=`${window.location.protocol}//${window.location.host}${On}`,Ua=`${Qa?"wss":"ws"}://${window.location.host}${On}`,Co=window.Config.platformVersion,Ue="returnUrl",Wa=()=>window.location.pathname+window.location.search,ja=()=>`${Ue}=${encodeURIComponent(Wa())}`,bo=({path:n,searchParams:t})=>{const r=new URL(window.location.href).searchParams.get(Ue),i=new URLSearchParams(t||{});r&&i.set(Ue,r);const l=i.toString();return`${n}${l?`?${l}`:""}`},qa=n=>!(typeof n!="string"||!n.startsWith("/")||n.replace(/\\/g,"/").startsWith("//")),Xa=n=>qa(n)?n:"/",yo=()=>{const n=new URL(window.location.href);return Xa(n.searchParams.get(Ue))},Ya=ze+"/auth/refresh";class H1 extends Error{constructor(){super("Unauthorized")}}async function Ja(n,t){try{return await fetch(n,t).then(a=>{if(a.status===401)throw new H1;return a})}catch(a){if(a instanceof H1)return await er(),fetch(n,t)}throw new Error("An unexpected error occurred while fetching data")}let xe=null;async function er(){return xe||(xe=fetch(Ya,{method:"POST"}).then(n=>(n.ok||(window.location.href=`/login?${ja()}`),xe=null,n)),xe)}const nr=ze+"/graphql",tr=window.Config.authenticationEnabled?Ja:fetch,ar=async(n,t,a)=>{const i=await(await tr(nr,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:n.text,variables:t})})).json();if(Array.isArray(i.errors))throw new Error(`Error fetching GraphQL query '${n.name}' with variables '${JSON.stringify(t)}': ${JSON.stringify(i.errors)}`);return i},rr=Mt({url:`${Ua}/graphql`}),ir=(n,t)=>Te.Observable.create(a=>rr.subscribe({operationName:n.name,query:n.text,variables:t},a)),He=new Te.Environment({network:Te.Network.create(ar,ir),store:new Te.Store(new Te.RecordSource,{gcReleaseBufferSize:10})});function Dn(n){return n.includes("PRIMARY")?W.primary:n.includes("CORPUS")?W.corpus:W.reference}function y1(n){const t=[],a=[],r=[];return n.forEach(i=>{const l=Dn(i);l==W.primary?t.push(i):l==W.corpus?r.push(i):a.push(i)}),{primaryEventIds:t,referenceEventIds:a,corpusEventIds:r}}const We=10,Ie="unknown",_n=It,Fn=Tt,lr=n=>Fn[n],or=n=>_n(n/We);var be=(n=>(n.move="move",n.select="select",n))(be||{}),v1=(n=>(n.default="default",n.highlight="highlight",n))(v1||{});const he=()=>Pn()==="light"?Ha:za;function vo(){const n=he();return{coloringStrategy:I.inferences,pointGroupVisibility:{[V.primary]:!0,[V.reference]:!0},pointGroupColors:{[V.primary]:n[0],[V.reference]:n[1],[V.corpus]:J},metric:{type:"drift",metric:"euclideanDistance"}}}function wo(){const n=he();return{coloringStrategy:I.inferences,pointGroupVisibility:{[V.primary]:!0,[V.corpus]:!0},pointGroupColors:{[V.primary]:n[0],[V.corpus]:J},metric:{type:"retrieval",metric:"queryDistance"},clusterSort:{dir:"desc",column:"primaryMetricValue"}}}function ko(){return{coloringStrategy:I.correctness,pointGroupVisibility:{[A.correct]:!0,[A.incorrect]:!0,[A.unknown]:!0},pointGroupColors:{[A.correct]:Qe.Discrete2.LightBlueOrange[0],[A.incorrect]:Qe.Discrete2.LightBlueOrange[1],[A.unknown]:pe},metric:{type:"performance",metric:"accuracyScore"},clusterSort:{dir:"asc",column:"primaryMetricValue"}}}const sr=n=>{const t={loading:!1,errorMessage:null,points:[],eventIdToDataMap:new Map,clusters:[],clusterSort:{dir:"desc",column:"driftRatio"},pointData:null,selectedEventIds:new Set,hoveredEventId:null,highlightedClusterId:null,selectedClusterId:null,canvasMode:"move",pointSizeScale:1,clusterColorMode:"default",coloringStrategy:I.inferences,inferencesVisibility:{primary:!0,reference:!0,corpus:!0},pointGroupVisibility:{[V.primary]:!0,[V.reference]:!0,[V.corpus]:!0},pointGroupColors:{[V.primary]:he()[0],[V.reference]:he()[1],[V.corpus]:J},eventIdToGroup:{},selectionDisplay:Ce.gallery,selectionGridSize:Le.large,dimension:null,dimensionMetadata:null,umapParameters:{minDist:Da,nNeighbors:Oa,nSamples:_a},hdbscanParameters:{minClusterSize:Fa,clusterMinSamples:Ra,clusterSelectionEpsilon:Na},clustersLoading:!1,metric:{type:"drift",metric:"euclideanDistance"},selectionSearchText:""},a=(r,i)=>({...t,...n,setInitialData:async({points:l,clusters:o,retrievals:d})=>{const c=i(),u=new Map,g=d.reduce((L,C)=>{const{queryId:k}=C;return L[k]?L[k].push(C):L[k]=[C],L},{});l.forEach(L=>{L={...L,retrievals:g[L.eventId]??[]},u.set(L.eventId,L)});const h=o.map($1).sort(r1(c.clusterSort));r({loading:!1,points:l,eventIdToDataMap:u,clusters:h,clustersLoading:!1,selectedEventIds:new Set,selectedClusterId:null,pointData:null,eventIdToGroup:le({points:l,coloringStrategy:c.coloringStrategy,pointsData:c.pointData??{},dimension:c.dimension||null,dimensionMetadata:c.dimensionMetadata})});const f=await ur(l.map(L=>L.eventId)).catch(()=>r({errorMessage:"Failed to load the point events"}));f&&r({pointData:f,clusters:h,clustersLoading:!1,eventIdToGroup:le({points:l,coloringStrategy:c.coloringStrategy,pointsData:f??{},dimension:c.dimension||null,dimensionMetadata:c.dimensionMetadata})})},setClusters:l=>{const o=i(),d=l.map($1).sort(r1(o.clusterSort));r({clusters:d,clustersLoading:!1,selectedClusterId:null,highlightedClusterId:null})},setClusterSort:l=>{const d=[...i().clusters].sort(r1(l));r({clusterSort:l,clusters:d})},setSelectedEventIds:l=>r({selectedEventIds:l,selectionSearchText:""}),setHoveredEventId:l=>r({hoveredEventId:l}),setHighlightedClusterId:l=>r({highlightedClusterId:l}),setSelectedClusterId:l=>r({selectedClusterId:l,highlightedClusterId:null}),setPointSizeScale:l=>r({pointSizeScale:l}),setCanvasMode:l=>r({canvasMode:l}),setClusterColorMode:l=>r({clusterColorMode:l}),setColoringStrategy:l=>{const o=i();switch(r({coloringStrategy:l}),l){case I.correctness:r({pointGroupVisibility:{[A.correct]:!0,[A.incorrect]:!0,[A.unknown]:!0},pointGroupColors:{[A.correct]:Qe.Discrete2.LightBlueOrange[0],[A.incorrect]:Qe.Discrete2.LightBlueOrange[1],[A.unknown]:pe},dimension:null,dimensionMetadata:null,eventIdToGroup:le({points:o.points,coloringStrategy:l,pointsData:o.pointData??{},dimension:o.dimension||null,dimensionMetadata:o.dimensionMetadata})});break;case I.inferences:{r({pointGroupVisibility:{[V.primary]:!0,[V.reference]:!0,[V.corpus]:!0},pointGroupColors:{[V.primary]:he()[0],[V.reference]:he()[1],[V.corpus]:J},dimension:null,dimensionMetadata:null,eventIdToGroup:le({points:o.points,coloringStrategy:l,pointsData:o.pointData??{},dimension:o.dimension||null,dimensionMetadata:o.dimensionMetadata})});break}case I.dimension:{r({pointGroupVisibility:{unknown:!0},pointGroupColors:{unknown:pe},dimension:null,dimensionMetadata:null,eventIdToGroup:le({points:o.points,coloringStrategy:l,pointsData:o.pointData??{},dimension:o.dimension||null,dimensionMetadata:o.dimensionMetadata})});break}default:F()}},inferencesVisibility:{primary:!0,reference:!0,corpus:!0},setInferencesVisibility:l=>r({inferencesVisibility:l}),setPointGroupVisibility:l=>r({pointGroupVisibility:l}),selectionDisplay:Ce.gallery,setSelectionDisplay:l=>r({selectionDisplay:l}),setSelectionGridSize:l=>r({selectionGridSize:l}),reset:()=>{r({points:[],clusters:[],selectedEventIds:new Set,selectedClusterId:null,eventIdToGroup:{}})},setDimension:async l=>{const o=i();r({dimension:l,dimensionMetadata:null});const d=await dr(l).catch(()=>r({errorMessage:"Failed to load the dimension metadata"}));if(d){if(r({dimensionMetadata:d}),d.categories&&d.categories.length){const c=d.categories.length,g=c<=Fn.length?lr:h=>_n(h/c);r({pointGroupVisibility:{...d.categories.reduce((h,f)=>({...h,[f]:!0}),{}),unknown:!0},pointGroupColors:{...d.categories.reduce((h,f,L)=>({...h,[f]:g(L)}),{}),unknown:pe},eventIdToGroup:le({points:o.points,coloringStrategy:o.coloringStrategy,pointsData:o.pointData??{},dimension:l,dimensionMetadata:d})})}else if(d.interval!==null){const c=An(d.interval);r({pointGroupVisibility:{...c.reduce((u,g)=>({...u,[g.name]:!0}),{}),unknown:!0},pointGroupColors:{...c.reduce((u,g,h)=>({...u,[g.name]:or(h)}),{}),unknown:pe},eventIdToGroup:le({points:o.points,coloringStrategy:o.coloringStrategy,pointsData:o.pointData??{},dimension:l,dimensionMetadata:d})})}}},setDimensionMetadata:l=>r({dimensionMetadata:l}),setUMAPParameters:l=>r({umapParameters:l}),setHDBSCANParameters:async l=>{const o=i();r({hdbscanParameters:l,clustersLoading:!0});const d=await mr({metric:o.metric,points:o.points,hdbscanParameters:l});o.setClusters(d)},getHDSCANParameters:()=>i().hdbscanParameters,getMetric:()=>i().metric,setErrorMessage:l=>r({errorMessage:l}),setLoading:l=>r({loading:l}),setMetric:async l=>{const o=i();r({metric:l,clustersLoading:!0});const d=await pr({metric:l,clusters:o.clusters,hdbscanParameters:o.hdbscanParameters});o.setClusters(d)},setSelectionSearchText:l=>r({selectionSearchText:l})});return Oe()(De(a))},K1=new Intl.NumberFormat([],{maximumFractionDigits:2});function cr({min:n,max:t}){return`${K1.format(n)} - ${K1.format(t)}`}function An({min:n,max:t}){const r=(t-n)/We,i=[];for(let l=0;l<We;l++){const o=n+l*r,d=n+(l+1)*r;i.push({min:o,max:d,name:cr({min:o,max:d})})}return i}function a1({numericGroupIntervals:n,numericValue:t}){let a=Ie,r=n.findIndex(i=>t>=i.min&&t<i.max);return r=r===-1?We-1:r,a=n[r].name,a}function le(n){const{points:t,coloringStrategy:a,pointsData:r,dimension:i,dimensionMetadata:l}=n,o={},d=t.map(c=>c.eventId);switch(a){case I.inferences:{const{primaryEventIds:c,referenceEventIds:u,corpusEventIds:g}=y1(d);c.forEach(h=>{o[h]=V.primary}),u.forEach(h=>{o[h]=V.reference}),g.forEach(h=>{o[h]=V.corpus});break}case I.correctness:{t.forEach(c=>{let u=A.unknown;const{predictionLabel:g,actualLabel:h}=c.eventMetadata;g!==null&&h!==null&&(u=g===h?A.correct:A.incorrect),o[c.eventId]=u});break}case I.dimension:{let c;l&&(l==null?void 0:l.interval)!==null&&(c=An(l.interval));const u=(i==null?void 0:i.type)==="prediction"&&(i==null?void 0:i.dataType)==="categorical",g=(i==null?void 0:i.type)==="prediction"&&(i==null?void 0:i.dataType)==="numeric",h=(i==null?void 0:i.type)==="actual"&&(i==null?void 0:i.dataType)==="categorical",f=(i==null?void 0:i.type)==="actual"&&(i==null?void 0:i.dataType)==="numeric";t.forEach(L=>{let C=Ie;const k=r[L.eventId];if(i!=null&&k!=null)if(u)C=k.eventMetadata.predictionLabel??Ie;else if(g){if(c==null)throw new Error("Cannot color by prediction score without numeric group intervals");const x=k.eventMetadata.predictionScore;typeof x=="number"&&(C=a1({numericGroupIntervals:c,numericValue:x}))}else if(f){if(c==null)throw new Error("Cannot color by actual score without numeric group intervals");const x=k.eventMetadata.actualScore;typeof x=="number"&&(C=a1({numericGroupIntervals:c,numericValue:x}))}else if(h)C=k.eventMetadata.actualLabel??Ie;else{const x=k.dimensions.find(R=>R.dimension.name===i.name);if(x!=null&&i.dataType==="categorical")C=x.value??Ie;else if(x!=null&&i.dataType==="numeric"&&c!=null){const R=typeof(x==null?void 0:x.value)=="string"?parseFloat(x.value):null;typeof R=="number"&&(C=a1({numericGroupIntervals:c,numericValue:R}))}}o[L.eventId]=C});break}default:F()}return o}async function dr(n){const t=await X.fetchQuery(He,Mn,{id:n.id,getDimensionMinMax:n.dataType==="numeric",getDimensionCategories:n.dataType==="categorical"}).toPromise(),a=t==null?void 0:t.dimension;if(!n)throw new Error("Dimension not found");let r=null;return typeof(a==null?void 0:a.min)=="number"&&typeof(a==null?void 0:a.max)=="number"&&(r={min:a.min,max:a.max}),{interval:r,categories:(a==null?void 0:a.categories)??null}}async function ur(n){var u,g,h,f,L,C;const{primaryEventIds:t,referenceEventIds:a,corpusEventIds:r}=y1([...n]),i=await X.fetchQuery(He,xn,{primaryEventIds:t,referenceEventIds:a,corpusEventIds:r}).toPromise(),l=((g=(u=i==null?void 0:i.model)==null?void 0:u.primaryInferences)==null?void 0:g.events)??[],o=((f=(h=i==null?void 0:i.model)==null?void 0:h.referenceInferences)==null?void 0:f.events)??[],d=((C=(L=i==null?void 0:i.model)==null?void 0:L.corpusInferences)==null?void 0:C.events)??[];return[...l,...o,...d].reduce((k,z)=>(k[z.id]=z,k),{})}async function mr({metric:n,points:t,hdbscanParameters:a}){const r=await X.fetchQuery(He,Sn,{eventIds:t.map(i=>i.eventId),coordinates:t.map(i=>({x:i.position[0],y:i.position[1],z:i.position[2]})),fetchDataQualityMetric:n.type==="dataQuality",dataQualityMetricColumnName:n.type==="dataQuality"?n.dimension.name:null,fetchPerformanceMetric:n.type==="performance",performanceMetric:n.type==="performance"?n.metric:"accuracyScore",...a},{fetchPolicy:"network-only"}).toPromise();return(r==null?void 0:r.hdbscanClustering)??[]}async function pr({metric:n,clusters:t,hdbscanParameters:a}){const r=await X.fetchQuery(He,kn,{clusters:t.map(i=>({id:i.id,eventIds:i.eventIds})),fetchDataQualityMetric:n.type==="dataQuality",dataQualityMetricColumnName:n.type==="dataQuality"?n.dimension.name:null,fetchPerformanceMetric:n.type==="performance",performanceMetric:n.type==="performance"?n.metric:"accuracyScore",...a},{fetchPolicy:"network-only"}).toPromise();return(r==null?void 0:r.clusters)??[]}const r1=n=>(t,a)=>{const{dir:r,column:i}=n,l=r==="asc",o=t[i],d=a[i];return o==null?1:d==null?-1:o>d?l?1:-1:o<d?l?-1:1:0};function $1(n){let t=n.driftRatio,a=null;return n.dataQualityMetric?(t=n.dataQualityMetric.primaryValue,a=n.dataQualityMetric.referenceValue):n.performanceMetric?(t=n.performanceMetric.primaryValue,a=n.performanceMetric.referenceValue):n.primaryToCorpusRatio!=null&&(t=(n.primaryToCorpusRatio+1)/2*100),{...n,size:n.eventIds.length,primaryMetricValue:t,referenceMetricValue:a}}const So=n=>{const t=a=>({...n,columnVisibility:{metadata:!1},annotationColumnVisibility:{},setColumnVisibility:r=>{a({columnVisibility:r})},setAnnotationColumnVisibility:r=>{a({annotationColumnVisibility:r})}});return Oe()(De(t))},ye={FString:"F_STRING",Mustache:"MUSTACHE"},xo={OPENAI:"OpenAI",AZURE_OPENAI:"Azure OpenAI",ANTHROPIC:"Anthropic"},hr="OPENAI",gr="user",Mo=["2024-10-01-preview","2024-09-01-preview","2024-08-01-preview","2024-07-01-preview","2024-06-01","2024-05-01-preview","2024-04-01-preview","2024-03-01-preview","2024-02-15-preview","2024-02-01","2023-10-01-preview","2023-09-01-preview","2023-08-01-preview","2023-07-01-preview","2023-06-01-preview","2023-05-15","2023-03-15-preview"],fr=n=>"variablesValueCache"in n;let Lr=0,B1=0,Cr=1,br=0;const Rn=()=>Lr++,Z1=()=>Cr++,yr=()=>br++,Nn=()=>({__type:"chat",messages:[{id:Z1(),role:"system",content:"You are a chatbot"},{id:Z1(),role:"user",content:"{{question}}"}]}),vr={__type:"text_completion",prompt:"{{question}}"};function wr(){return{id:Rn(),template:Nn(),model:{provider:hr,modelName:"gpt-4o"},tools:[],toolChoice:"auto",input:{variablesValueCache:{}},output:void 0,spanId:null,activeRunId:null,isRunning:!1}}function To(n){return{id:yr(),definition:{type:"function",function:{name:`new_function_${n}`,parameters:{type:"object",properties:{new_arg:{type:"string"}},required:[]}}}}}const Io=n=>Oe(De((a,r)=>({streaming:!0,operationType:"chat",inputMode:"manual",input:{variablesValueCache:{}},templateLanguage:ye.Mustache,setInputMode:i=>a({inputMode:i}),instances:[wr()],setOperationType:i=>{a(i==="chat"?{instances:r().instances.map(l=>({...l,template:Nn()}))}:{instances:r().instances.map(l=>({...l,template:vr}))}),a({operationType:i})},addInstance:()=>{const i=r().instances,l=r().instances[0];l&&a({instances:[...i,{...l,id:Rn(),activeRunId:null,isRunning:!1,spanId:null}]})},updateModel:({instanceId:i,model:l})=>{const o=r().instances,d=o.find(u=>u.id===i);if(!d)return;const c=d.model;l.provider!==c.provider&&(l={...l,modelName:void 0}),a({instances:o.map(u=>u.id===i?{...u,model:{...u.model,...l}}:u)})},deleteInstance:i=>{const l=r().instances;a({instances:l.filter(o=>o.id!==i)})},addMessage:({playgroundInstanceId:i})=>{const l=r().instances;a({instances:l.map(o=>o.id===i&&(o!=null&&o.template)&&(o==null?void 0:o.template.__type)==="chat"?{...o,messages:[...o.template.messages,{role:gr,content:"{question}"}]}:o)})},updateInstance:({instanceId:i,patch:l})=>{const o=r().instances;a({instances:o.map(d=>d.id===i?{...d,...l}:d)})},runPlaygroundInstances:()=>{const i=r().instances;a({instances:i.map(l=>({...l,activeRunId:B1++,isRunning:!0,spanId:null}))})},runPlaygroundInstance:i=>{const l=r().instances;a({instances:l.map(o=>o.id===i?{...o,activeRunId:B1++,isRunning:!0,spanId:null}:o)})},markPlaygroundInstanceComplete:i=>{const l=r().instances;a({instances:l.map(o=>o.id===i?{...o,isRunning:!1}:o)})},setTemplateLanguage:i=>{a({templateLanguage:i})},setVariableValue:(i,l)=>{const o=r().input;fr(o)&&a({input:{...o,variablesValueCache:{...o.variablesValueCache,[i]:l}}})},setStreaming:i=>{a({streaming:i})},...n}))),Eo=n=>{const t=a=>({setCredential:({provider:r,value:i})=>{a({[r]:i})},...n});return Oe()(an(De(t),{name:"arize-phoenix-credentials"}))},kr=n=>{const t=a=>({markdownDisplayMode:"text",setMarkdownDisplayMode:r=>{a({markdownDisplayMode:r})},traceStreamingEnabled:!0,setTraceStreamingEnabled:r=>{a({traceStreamingEnabled:r})},lastNTimeRangeKey:"7d",setLastNTimeRangeKey:r=>{a({lastNTimeRangeKey:r})},projectsAutoRefreshEnabled:!0,setProjectAutoRefreshEnabled:r=>{a({projectsAutoRefreshEnabled:r})},showSpanAside:!0,setShowSpanAside:r=>{a({showSpanAside:r})},showMetricsInTraceTree:!0,setShowMetricsInTraceTree:r=>{a({showMetricsInTraceTree:r})},...n});return Oe()(an(De(t),{name:"arize-phoenix-preferences"}))},zn=p.createContext(null);function Vo({children:n,...t}){const[a]=p.useState(()=>kr(t));return e(zn.Provider,{value:a,children:n})}function ce(n,t){const a=j.useContext(zn);if(!a)throw new Error("Missing PreferencesContext.Provider in the tree");return tn(a,n,t)}function Hn(n){return e("div",{onClick:t=>t.stopPropagation(),css:m`
|
|
148
148
|
display: inline-block;
|
|
149
149
|
`,children:e(rn,{css:m`
|
|
150
150
|
color: var(--ac-global-color-primary);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,x as h,b7 as x,du as b,dv as f,l as n,dw as r,dx as y,dy as P,r as v,t as w,dz as R}from"./vendor-6IcPAw_j.js";import{v as L,a4 as z}from"./vendor-arizeai-
|
|
1
|
+
import{j as e,x as h,b7 as x,du as b,dv as f,l as n,dw as r,dx as y,dy as P,r as v,t as w,dz as R}from"./vendor-6IcPAw_j.js";import{v as L,a4 as z}from"./vendor-arizeai-DRZuoyuF.js";import{E as k,L as E,R as $,r as j,a as I,F as S,A,b as C,c as F,P as T,h as O,M as D,d,D as B,e as G,f as M,g as N,i as W,j as q,T as H,p as _,k as c,l as J,m as K,n as p,o as Q,q as m,s as g,t as U,v as V,w as X,x as Y,y as Z,z as ee,S as re,B as ae,C as oe,G as te,H as ne,I as se,J as le}from"./pages-aAez_Ntk.js";import{bG as ie,j as de,R as ce,bH as pe,bI as me}from"./components-mVBxvljU.js";import"./vendor-three-DwGkEfCM.js";import"./vendor-recharts-DwrexFA4.js";import"./vendor-codemirror-DVE2_WBr.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const t of o)if(t.type==="childList")for(const l of t.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function u(o){const t={};return o.integrity&&(t.integrity=o.integrity),o.referrerPolicy&&(t.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?t.credentials="include":o.crossOrigin==="anonymous"?t.credentials="omit":t.credentials="same-origin",t}function i(o){if(o.ep)return;o.ep=!0;const t=u(o);fetch(o.href,t)}})();function ge(){return e(x,{styles:a=>h`
|
|
2
2
|
body {
|
|
3
3
|
background-color: var(--ac-global-color-grey-75);
|
|
4
4
|
color: var(--ac-global-text-color-900);
|