@arizeai/phoenix-client 6.9.2 → 6.10.0

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.
Files changed (80) hide show
  1. package/dist/esm/__generated__/api/v1.d.ts +1676 -142
  2. package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
  3. package/dist/esm/constants/serverRequirements.d.ts +3 -0
  4. package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
  5. package/dist/esm/constants/serverRequirements.js +24 -0
  6. package/dist/esm/constants/serverRequirements.js.map +1 -1
  7. package/dist/esm/prompts/sdks/toOpenAI.d.ts.map +1 -1
  8. package/dist/esm/prompts/sdks/toOpenAI.js +39 -7
  9. package/dist/esm/prompts/sdks/toOpenAI.js.map +1 -1
  10. package/dist/esm/schemas/llm/constants.d.ts +1 -1
  11. package/dist/esm/schemas/llm/converters.d.ts +4 -4
  12. package/dist/esm/schemas/llm/openai/converters.d.ts +1 -1
  13. package/dist/esm/schemas/llm/openai/messageSchemas.d.ts +1 -1
  14. package/dist/esm/schemas/llm/phoenixPrompt/converters.d.ts +2 -2
  15. package/dist/esm/schemas/llm/phoenixPrompt/messageSchemas.d.ts +3 -3
  16. package/dist/esm/schemas/llm/schemas.d.ts +1 -1
  17. package/dist/esm/schemas/llm/vercel/messageSchemas.d.ts +1 -1
  18. package/dist/esm/sessions/addSessionNote.d.ts +11 -2
  19. package/dist/esm/sessions/addSessionNote.d.ts.map +1 -1
  20. package/dist/esm/sessions/addSessionNote.js +12 -3
  21. package/dist/esm/sessions/addSessionNote.js.map +1 -1
  22. package/dist/esm/spans/addSpanNote.d.ts +11 -5
  23. package/dist/esm/spans/addSpanNote.d.ts.map +1 -1
  24. package/dist/esm/spans/addSpanNote.js +13 -5
  25. package/dist/esm/spans/addSpanNote.js.map +1 -1
  26. package/dist/esm/spans/getSpanAnnotations.d.ts +1 -1
  27. package/dist/esm/spans/getSpanAnnotations.d.ts.map +1 -1
  28. package/dist/esm/traces/addTraceNote.d.ts +11 -5
  29. package/dist/esm/traces/addTraceNote.d.ts.map +1 -1
  30. package/dist/esm/traces/addTraceNote.js +12 -6
  31. package/dist/esm/traces/addTraceNote.js.map +1 -1
  32. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  33. package/dist/esm/utils/formatPromptMessages.d.ts.map +1 -1
  34. package/dist/esm/utils/getPromptBySelector.d.ts.map +1 -1
  35. package/dist/src/__generated__/api/v1.d.ts +1676 -142
  36. package/dist/src/__generated__/api/v1.d.ts.map +1 -1
  37. package/dist/src/constants/serverRequirements.d.ts +3 -0
  38. package/dist/src/constants/serverRequirements.d.ts.map +1 -1
  39. package/dist/src/constants/serverRequirements.js +25 -1
  40. package/dist/src/constants/serverRequirements.js.map +1 -1
  41. package/dist/src/prompts/sdks/toOpenAI.d.ts.map +1 -1
  42. package/dist/src/prompts/sdks/toOpenAI.js +39 -7
  43. package/dist/src/prompts/sdks/toOpenAI.js.map +1 -1
  44. package/dist/src/schemas/llm/constants.d.ts +1 -1
  45. package/dist/src/schemas/llm/converters.d.ts +4 -4
  46. package/dist/src/schemas/llm/openai/converters.d.ts +1 -1
  47. package/dist/src/schemas/llm/openai/messageSchemas.d.ts +1 -1
  48. package/dist/src/schemas/llm/phoenixPrompt/converters.d.ts +2 -2
  49. package/dist/src/schemas/llm/phoenixPrompt/messageSchemas.d.ts +3 -3
  50. package/dist/src/schemas/llm/schemas.d.ts +1 -1
  51. package/dist/src/schemas/llm/vercel/messageSchemas.d.ts +1 -1
  52. package/dist/src/sessions/addSessionNote.d.ts +11 -2
  53. package/dist/src/sessions/addSessionNote.d.ts.map +1 -1
  54. package/dist/src/sessions/addSessionNote.js +11 -2
  55. package/dist/src/sessions/addSessionNote.js.map +1 -1
  56. package/dist/src/spans/addSpanNote.d.ts +11 -5
  57. package/dist/src/spans/addSpanNote.d.ts.map +1 -1
  58. package/dist/src/spans/addSpanNote.js +13 -5
  59. package/dist/src/spans/addSpanNote.js.map +1 -1
  60. package/dist/src/spans/getSpanAnnotations.d.ts +1 -1
  61. package/dist/src/spans/getSpanAnnotations.d.ts.map +1 -1
  62. package/dist/src/traces/addTraceNote.d.ts +11 -5
  63. package/dist/src/traces/addTraceNote.d.ts.map +1 -1
  64. package/dist/src/traces/addTraceNote.js +11 -5
  65. package/dist/src/traces/addTraceNote.js.map +1 -1
  66. package/dist/src/utils/formatPromptMessages.d.ts.map +1 -1
  67. package/dist/src/utils/getPromptBySelector.d.ts.map +1 -1
  68. package/dist/tsconfig.tsbuildinfo +1 -1
  69. package/docs/annotations.mdx +7 -3
  70. package/docs/overview.mdx +1 -1
  71. package/docs/sessions.mdx +20 -0
  72. package/docs/traces.mdx +76 -5
  73. package/package.json +2 -2
  74. package/src/__generated__/api/v1.ts +1676 -142
  75. package/src/constants/serverRequirements.ts +27 -0
  76. package/src/prompts/sdks/toOpenAI.ts +41 -8
  77. package/src/sessions/addSessionNote.ts +22 -3
  78. package/src/spans/addSpanNote.ts +20 -5
  79. package/src/spans/getSpanAnnotations.ts +1 -1
  80. package/src/traces/addTraceNote.ts +22 -6
@@ -106,6 +106,30 @@ export const DATASET_UPLOAD_EXAMPLE_IDS: ParameterRequirement = {
106
106
  minServerVersion: [15, 0, 0],
107
107
  };
108
108
 
109
+ export const ADD_TRACE_NOTE_IDENTIFIER: ParameterRequirement = {
110
+ kind: "parameter",
111
+ parameterName: "identifier",
112
+ parameterLocation: "body",
113
+ route: "POST /v1/trace_notes",
114
+ minServerVersion: [15, 5, 0],
115
+ };
116
+
117
+ export const ADD_SPAN_NOTE_IDENTIFIER: ParameterRequirement = {
118
+ kind: "parameter",
119
+ parameterName: "identifier",
120
+ parameterLocation: "body",
121
+ route: "POST /v1/span_notes",
122
+ minServerVersion: [15, 5, 0],
123
+ };
124
+
125
+ export const ADD_SESSION_NOTE_IDENTIFIER: ParameterRequirement = {
126
+ kind: "parameter",
127
+ parameterName: "identifier",
128
+ parameterLocation: "body",
129
+ route: "POST /v1/session_notes",
130
+ minServerVersion: [15, 5, 0],
131
+ };
132
+
109
133
  /**
110
134
  * Aggregate list of every known capability requirement.
111
135
  *
@@ -125,4 +149,7 @@ export const ALL_REQUIREMENTS: readonly CapabilityRequirement[] = [
125
149
  GET_SPANS_BY_ATTRIBUTE,
126
150
  LIST_PROJECT_TRACES,
127
151
  DATASET_UPLOAD_EXAMPLE_IDS,
152
+ ADD_TRACE_NOTE_IDENTIFIER,
153
+ ADD_SPAN_NOTE_IDENTIFIER,
154
+ ADD_SESSION_NOTE_IDENTIFIER,
128
155
  ] as const;
@@ -36,14 +36,47 @@ export const toOpenAI = <V extends Variables = Variables>({
36
36
  }: ToOpenAIParams<V>): ChatCompletionCreateParams | null => {
37
37
  try {
38
38
  let invocationParameters: Partial<ChatCompletionCreateParams>;
39
- if (prompt.invocation_parameters.type === "openai") {
40
- invocationParameters = prompt.invocation_parameters.openai;
41
- } else {
42
- // eslint-disable-next-line no-console
43
- console.warn(
44
- "Prompt is not an OpenAI prompt, falling back to default OpenAI invocation parameters"
45
- );
46
- invocationParameters = {};
39
+ switch (prompt.invocation_parameters.type) {
40
+ case "openai":
41
+ invocationParameters = prompt.invocation_parameters.openai;
42
+ break;
43
+ case "azure_openai":
44
+ invocationParameters = prompt.invocation_parameters.azure_openai;
45
+ break;
46
+ case "deepseek":
47
+ invocationParameters = prompt.invocation_parameters.deepseek;
48
+ break;
49
+ case "xai":
50
+ invocationParameters = prompt.invocation_parameters.xai;
51
+ break;
52
+ case "ollama":
53
+ invocationParameters = prompt.invocation_parameters.ollama;
54
+ break;
55
+ case "cerebras":
56
+ invocationParameters = prompt.invocation_parameters.cerebras;
57
+ break;
58
+ case "fireworks":
59
+ invocationParameters = prompt.invocation_parameters.fireworks;
60
+ break;
61
+ case "groq":
62
+ invocationParameters = prompt.invocation_parameters.groq;
63
+ break;
64
+ case "moonshot":
65
+ invocationParameters = prompt.invocation_parameters.moonshot;
66
+ break;
67
+ case "perplexity":
68
+ invocationParameters = prompt.invocation_parameters.perplexity;
69
+ break;
70
+ case "together":
71
+ invocationParameters = prompt.invocation_parameters.together;
72
+ break;
73
+ default:
74
+ // eslint-disable-next-line no-console
75
+ console.warn(
76
+ "Prompt is not an OpenAI-family prompt, falling back to default OpenAI invocation parameters"
77
+ );
78
+ invocationParameters = {};
79
+ break;
47
80
  }
48
81
  // parts of the prompt that can be directly converted to OpenAI params
49
82
  const baseCompletionParams = {
@@ -1,5 +1,8 @@
1
1
  import { createClient } from "../client";
2
- import { ADD_SESSION_NOTE } from "../constants/serverRequirements";
2
+ import {
3
+ ADD_SESSION_NOTE,
4
+ ADD_SESSION_NOTE_IDENTIFIER,
5
+ } from "../constants/serverRequirements";
3
6
  import type { ClientFn } from "../types/core";
4
7
  import { formatApiError } from "../utils/apiErrorUtils";
5
8
  import { ensureServerCapability } from "../utils/serverVersionUtils";
@@ -16,6 +19,13 @@ export interface SessionNote {
16
19
  * The note text to add to the session.
17
20
  */
18
21
  note: string;
22
+ /**
23
+ * Optional caller-supplied identifier. When non-empty, the note is upserted
24
+ * on `(sessionId, name='note', identifier)` — repeated calls with the same
25
+ * identifier overwrite the existing note. When omitted, the server stamps a
26
+ * unique `px-session-note:<uuid>` identifier so each call appends a new note.
27
+ */
28
+ identifier?: string;
19
29
  }
20
30
 
21
31
  /**
@@ -28,8 +38,10 @@ export interface AddSessionNoteParams extends ClientFn {
28
38
  /**
29
39
  * Add a note to a session.
30
40
  *
31
- * Notes are a special type of annotation that allow multiple entries per session.
32
- * Each note gets a unique UUIDv4 identifier.
41
+ * When `sessionNote.identifier` is omitted, each call appends a new note with
42
+ * an auto-generated identifier. When `identifier` is non-empty, repeated calls
43
+ * with the same `(sessionId, name='note', identifier)` overwrite the existing
44
+ * note.
33
45
  *
34
46
  * @param params - The parameters to add a session note.
35
47
  * @returns The ID of the created note annotation.
@@ -52,12 +64,19 @@ export async function addSessionNote({
52
64
  }: AddSessionNoteParams): Promise<{ id: string }> {
53
65
  const client = _client ?? createClient();
54
66
  await ensureServerCapability({ client, requirement: ADD_SESSION_NOTE });
67
+ if (sessionNote.identifier) {
68
+ await ensureServerCapability({
69
+ client,
70
+ requirement: ADD_SESSION_NOTE_IDENTIFIER,
71
+ });
72
+ }
55
73
 
56
74
  const { data, error } = await client.POST("/v1/session_notes", {
57
75
  body: {
58
76
  data: {
59
77
  session_id: sessionNote.sessionId.trim(),
60
78
  note: sessionNote.note,
79
+ identifier: sessionNote.identifier,
61
80
  },
62
81
  },
63
82
  });
@@ -1,6 +1,8 @@
1
1
  import { createClient } from "../client";
2
+ import { ADD_SPAN_NOTE_IDENTIFIER } from "../constants/serverRequirements";
2
3
  import type { ClientFn } from "../types/core";
3
4
  import { formatApiError } from "../utils/apiErrorUtils";
5
+ import { ensureServerCapability } from "../utils/serverVersionUtils";
4
6
 
5
7
  /**
6
8
  * Parameters for a single span note
@@ -14,6 +16,13 @@ export interface SpanNote {
14
16
  * The note text to add to the span
15
17
  */
16
18
  note: string;
19
+ /**
20
+ * Optional caller-supplied identifier. When non-empty, the note is upserted
21
+ * on `(spanId, name='note', identifier)` — repeated calls with the same
22
+ * identifier overwrite the existing note. When omitted, the server stamps a
23
+ * unique `px-span-note:<uuid>` identifier so each call appends a new note.
24
+ */
25
+ identifier?: string;
17
26
  }
18
27
 
19
28
  /**
@@ -26,11 +35,10 @@ export interface AddSpanNoteParams extends ClientFn {
26
35
  /**
27
36
  * Add a note to a span.
28
37
  *
29
- * Notes are append-only: each call creates a new note with an auto-generated
30
- * UUIDv4 identifier, so multiple notes accumulate on the same span. Structured
31
- * annotations, by contrast, are keyed by `(name, spanId, identifier)` — to keep
32
- * multiple structured annotations with the same name on a span, supply distinct
33
- * identifiers; otherwise re-writing the same name overwrites the existing one.
38
+ * When `spanNote.identifier` is omitted, each call appends a new note with an
39
+ * auto-generated identifier. When `identifier` is non-empty, repeated calls
40
+ * with the same `(spanId, name='note', identifier)` overwrite the existing
41
+ * note.
34
42
  *
35
43
  * @param params - The parameters to add a span note
36
44
  * @returns The ID of the created note annotation
@@ -50,12 +58,19 @@ export async function addSpanNote({
50
58
  spanNote,
51
59
  }: AddSpanNoteParams): Promise<{ id: string }> {
52
60
  const client = _client ?? createClient();
61
+ if (spanNote.identifier) {
62
+ await ensureServerCapability({
63
+ client,
64
+ requirement: ADD_SPAN_NOTE_IDENTIFIER,
65
+ });
66
+ }
53
67
 
54
68
  const { data, error } = await client.POST("/v1/span_notes", {
55
69
  body: {
56
70
  data: {
57
71
  span_id: spanNote.spanId.trim(),
58
72
  note: spanNote.note,
73
+ identifier: spanNote.identifier,
59
74
  },
60
75
  },
61
76
  });
@@ -12,7 +12,7 @@ export interface GetSpanAnnotationsParams extends ClientFn {
12
12
  project: ProjectIdentifier;
13
13
  /** One or more span IDs to fetch annotations for */
14
14
  spanIds: string[];
15
- /** Optional list of annotation names to include. If provided, only annotations with these names will be returned. 'note' annotations are excluded by default unless explicitly included in this list. */
15
+ /** Optional list of annotation names to include. If provided, only annotations with these names will be returned (allowlist). When omitted, the response includes every matching row regardless of name (no annotation names are excluded by default). */
16
16
  includeAnnotationNames?: string[];
17
17
  /** Optional list of annotation names to exclude from results. */
18
18
  excludeAnnotationNames?: string[];
@@ -1,5 +1,8 @@
1
1
  import { createClient } from "../client";
2
- import { ADD_TRACE_NOTE } from "../constants/serverRequirements";
2
+ import {
3
+ ADD_TRACE_NOTE,
4
+ ADD_TRACE_NOTE_IDENTIFIER,
5
+ } from "../constants/serverRequirements";
3
6
  import type { ClientFn } from "../types/core";
4
7
  import { formatApiError } from "../utils/apiErrorUtils";
5
8
  import { ensureServerCapability } from "../utils/serverVersionUtils";
@@ -16,6 +19,13 @@ export interface TraceNote {
16
19
  * The note text to add to the trace.
17
20
  */
18
21
  note: string;
22
+ /**
23
+ * Optional caller-supplied identifier. When non-empty, the note is upserted
24
+ * on `(traceId, name='note', identifier)` — repeated calls with the same
25
+ * identifier overwrite the existing note. When omitted, the server stamps a
26
+ * unique `px-trace-note:<uuid>` identifier so each call appends a new note.
27
+ */
28
+ identifier?: string;
19
29
  }
20
30
 
21
31
  /**
@@ -28,11 +38,10 @@ export interface AddTraceNoteParams extends ClientFn {
28
38
  /**
29
39
  * Add a note to a trace.
30
40
  *
31
- * Notes are append-only: each call creates a new note with an auto-generated
32
- * UUIDv4 identifier, so multiple notes accumulate on the same trace. Structured
33
- * annotations, by contrast, are keyed by `(name, traceId, identifier)` — to keep
34
- * multiple structured annotations with the same name on a trace, supply distinct
35
- * identifiers; otherwise re-writing the same name overwrites the existing one.
41
+ * When `traceNote.identifier` is omitted, each call appends a new note with an
42
+ * auto-generated identifier. When `identifier` is non-empty, repeated calls
43
+ * with the same `(traceId, name='note', identifier)` overwrite the existing
44
+ * note.
36
45
  *
37
46
  * @param params - The parameters to add a trace note.
38
47
  * @returns The ID of the created note annotation.
@@ -53,12 +62,19 @@ export async function addTraceNote({
53
62
  }: AddTraceNoteParams): Promise<{ id: string }> {
54
63
  const client = _client ?? createClient();
55
64
  await ensureServerCapability({ client, requirement: ADD_TRACE_NOTE });
65
+ if (traceNote.identifier) {
66
+ await ensureServerCapability({
67
+ client,
68
+ requirement: ADD_TRACE_NOTE_IDENTIFIER,
69
+ });
70
+ }
56
71
 
57
72
  const { data, error } = await client.POST("/v1/trace_notes", {
58
73
  body: {
59
74
  data: {
60
75
  trace_id: traceNote.traceId.trim(),
61
76
  note: traceNote.note,
77
+ identifier: traceNote.identifier,
62
78
  },
63
79
  },
64
80
  });