@arizeai/phoenix-client 2.1.1 → 2.2.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 (71) hide show
  1. package/dist/esm/__generated__/api/v1.d.ts +331 -16
  2. package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
  3. package/dist/esm/prompts/constants.d.ts.map +1 -1
  4. package/dist/esm/prompts/constants.js +4 -0
  5. package/dist/esm/prompts/constants.js.map +1 -1
  6. package/dist/esm/prompts/createPrompt.d.ts +12 -4
  7. package/dist/esm/prompts/createPrompt.d.ts.map +1 -1
  8. package/dist/esm/prompts/createPrompt.js +32 -0
  9. package/dist/esm/prompts/createPrompt.js.map +1 -1
  10. package/dist/esm/spans/getSpanAnnotations.d.ts +78 -0
  11. package/dist/esm/spans/getSpanAnnotations.d.ts.map +1 -0
  12. package/dist/esm/spans/getSpanAnnotations.js +83 -0
  13. package/dist/esm/spans/getSpanAnnotations.js.map +1 -0
  14. package/dist/esm/spans/getSpans.d.ts +78 -0
  15. package/dist/esm/spans/getSpans.d.ts.map +1 -0
  16. package/dist/esm/spans/getSpans.js +85 -0
  17. package/dist/esm/spans/getSpans.js.map +1 -0
  18. package/dist/esm/spans/index.d.ts +2 -0
  19. package/dist/esm/spans/index.d.ts.map +1 -1
  20. package/dist/esm/spans/index.js +2 -0
  21. package/dist/esm/spans/index.js.map +1 -1
  22. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  23. package/dist/esm/types/projects.d.ts +10 -0
  24. package/dist/esm/types/projects.d.ts.map +1 -0
  25. package/dist/esm/types/projects.js +2 -0
  26. package/dist/esm/types/projects.js.map +1 -0
  27. package/dist/esm/types/prompts.d.ts +17 -1
  28. package/dist/esm/types/prompts.d.ts.map +1 -1
  29. package/dist/esm/utils/formatPromptMessages.d.ts.map +1 -1
  30. package/dist/esm/utils/getPromptBySelector.d.ts +1 -1
  31. package/dist/esm/utils/getPromptBySelector.d.ts.map +1 -1
  32. package/dist/src/__generated__/api/v1.d.ts +331 -16
  33. package/dist/src/__generated__/api/v1.d.ts.map +1 -1
  34. package/dist/src/prompts/constants.d.ts.map +1 -1
  35. package/dist/src/prompts/constants.js +4 -0
  36. package/dist/src/prompts/constants.js.map +1 -1
  37. package/dist/src/prompts/createPrompt.d.ts +12 -4
  38. package/dist/src/prompts/createPrompt.d.ts.map +1 -1
  39. package/dist/src/prompts/createPrompt.js +32 -0
  40. package/dist/src/prompts/createPrompt.js.map +1 -1
  41. package/dist/src/spans/getSpanAnnotations.d.ts +78 -0
  42. package/dist/src/spans/getSpanAnnotations.d.ts.map +1 -0
  43. package/dist/src/spans/getSpanAnnotations.js +98 -0
  44. package/dist/src/spans/getSpanAnnotations.js.map +1 -0
  45. package/dist/src/spans/getSpans.d.ts +78 -0
  46. package/dist/src/spans/getSpans.d.ts.map +1 -0
  47. package/dist/src/spans/getSpans.js +100 -0
  48. package/dist/src/spans/getSpans.js.map +1 -0
  49. package/dist/src/spans/index.d.ts +2 -0
  50. package/dist/src/spans/index.d.ts.map +1 -1
  51. package/dist/src/spans/index.js +2 -0
  52. package/dist/src/spans/index.js.map +1 -1
  53. package/dist/src/types/projects.d.ts +10 -0
  54. package/dist/src/types/projects.d.ts.map +1 -0
  55. package/dist/src/types/projects.js +3 -0
  56. package/dist/src/types/projects.js.map +1 -0
  57. package/dist/src/types/prompts.d.ts +17 -1
  58. package/dist/src/types/prompts.d.ts.map +1 -1
  59. package/dist/src/utils/formatPromptMessages.d.ts.map +1 -1
  60. package/dist/src/utils/getPromptBySelector.d.ts +1 -1
  61. package/dist/src/utils/getPromptBySelector.d.ts.map +1 -1
  62. package/dist/tsconfig.tsbuildinfo +1 -1
  63. package/package.json +1 -1
  64. package/src/__generated__/api/v1.ts +331 -16
  65. package/src/prompts/constants.ts +4 -0
  66. package/src/prompts/createPrompt.ts +51 -3
  67. package/src/spans/getSpanAnnotations.ts +131 -0
  68. package/src/spans/getSpans.ts +127 -0
  69. package/src/spans/index.ts +2 -0
  70. package/src/types/projects.ts +5 -0
  71. package/src/types/prompts.ts +29 -1
@@ -0,0 +1,83 @@
1
+ import { createClient } from "../client.js";
2
+ /**
3
+ * Get span annotations for a list of span IDs.
4
+ *
5
+ * This method allows you to retrieve annotations for specific spans within a project.
6
+ * You can filter annotations by name and support cursor-based pagination.
7
+ *
8
+ * @experimental this function is experimental and may change in the future
9
+ *
10
+ * @param params - The parameters to get span annotations
11
+ * @returns A paginated response containing annotations and optional next cursor
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // Get annotations for specific spans
16
+ * const result = await getSpanAnnotations({
17
+ * client,
18
+ * project: { projectName: "my-project" },
19
+ * spanIds: ["span1", "span2", "span3"],
20
+ * limit: 50
21
+ * });
22
+ *
23
+ * // Get specific annotation types
24
+ * const result = await getSpanAnnotations({
25
+ * client,
26
+ * project: { projectName: "my-project" },
27
+ * spanIds: ["span1"],
28
+ * includeAnnotationNames: ["quality_score", "sentiment"],
29
+ * limit: 100
30
+ * });
31
+ *
32
+ * // Paginate through results
33
+ * let cursor: string | undefined;
34
+ * do {
35
+ * const result = await getSpanAnnotations({
36
+ * client,
37
+ * project: { projectName: "my-project" },
38
+ * spanIds: ["span1"],
39
+ * cursor,
40
+ * limit: 100
41
+ * });
42
+ *
43
+ * // Process annotations
44
+ * result.annotations.forEach(annotation => {
45
+ * console.log(`Annotation: ${annotation.name}, Label: ${annotation.result.label}`);
46
+ * });
47
+ *
48
+ * cursor = result.nextCursor || undefined;
49
+ * } while (cursor);
50
+ * ```
51
+ */
52
+ export async function getSpanAnnotations({ client: _client, project, spanIds, includeAnnotationNames, excludeAnnotationNames, cursor, limit = 100, }) {
53
+ const client = _client ?? createClient();
54
+ const projectIdentifier = "projectId" in project ? project.projectId : project.projectName;
55
+ const params = {
56
+ span_ids: spanIds,
57
+ limit,
58
+ };
59
+ if (cursor) {
60
+ params.cursor = cursor;
61
+ }
62
+ if (includeAnnotationNames !== undefined) {
63
+ params.include_annotation_names = includeAnnotationNames;
64
+ }
65
+ if (excludeAnnotationNames !== undefined) {
66
+ params.exclude_annotation_names = excludeAnnotationNames;
67
+ }
68
+ const { data, error } = await client.GET("/v1/projects/{project_identifier}/span_annotations", {
69
+ params: {
70
+ path: {
71
+ project_identifier: projectIdentifier,
72
+ },
73
+ query: params,
74
+ },
75
+ });
76
+ if (error)
77
+ throw error;
78
+ return {
79
+ annotations: data?.data ?? [],
80
+ nextCursor: data?.next_cursor ?? null,
81
+ };
82
+ }
83
+ //# sourceMappingURL=getSpanAnnotations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSpanAnnotations.js","sourceRoot":"","sources":["../../../src/spans/getSpanAnnotations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AA+BzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,EACvC,MAAM,EAAE,OAAO,EACf,OAAO,EACP,OAAO,EACP,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,EACN,KAAK,GAAG,GAAG,GACc;IACzB,MAAM,MAAM,GAAG,OAAO,IAAI,YAAY,EAAE,CAAC;IACzC,MAAM,iBAAiB,GACrB,WAAW,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;IAEnE,MAAM,MAAM,GAER;QACF,QAAQ,EAAE,OAAO;QACjB,KAAK;KACN,CAAC;IAEF,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,IAAI,sBAAsB,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,CAAC,wBAAwB,GAAG,sBAAsB,CAAC;IAC3D,CAAC;IAED,IAAI,sBAAsB,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,CAAC,wBAAwB,GAAG,sBAAsB,CAAC;IAC3D,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CACtC,oDAAoD,EACpD;QACE,MAAM,EAAE;YACN,IAAI,EAAE;gBACJ,kBAAkB,EAAE,iBAAiB;aACtC;YACD,KAAK,EAAE,MAAM;SACd;KACF,CACF,CAAC;IAEF,IAAI,KAAK;QAAE,MAAM,KAAK,CAAC;IACvB,OAAO;QACL,WAAW,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE;QAC7B,UAAU,EAAE,IAAI,EAAE,WAAW,IAAI,IAAI;KACtC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,78 @@
1
+ import { ClientFn } from "../types/core.js";
2
+ import { operations } from "../__generated__/api/v1.js";
3
+ import { ProjectSelector } from "../types/projects.js";
4
+ /**
5
+ * Parameters to get spans from a project using auto-generated types
6
+ */
7
+ interface GetSpansParams extends ClientFn {
8
+ /** The project to get spans from */
9
+ project: ProjectSelector;
10
+ /** Inclusive lower bound time. Must be a valid ISO 8601 string or Date object. */
11
+ startTime?: Date | string | null;
12
+ /** Exclusive upper bound time. Must be a valid ISO 8601 string or Date object. */
13
+ endTime?: Date | string | null;
14
+ /** Pagination cursor (Span Global ID) */
15
+ cursor?: string | null;
16
+ /** Maximum number of spans to return */
17
+ limit?: number;
18
+ }
19
+ type GetSpansResponse = operations["getSpans"]["responses"]["200"];
20
+ export type GetSpansResult = {
21
+ spans: GetSpansResponse["content"]["application/json"]["data"];
22
+ nextCursor: GetSpansResponse["content"]["application/json"]["next_cursor"];
23
+ };
24
+ /**
25
+ * Get spans from a project with filtering criteria.
26
+ *
27
+ * This method allows you to search for spans within a project using various filters
28
+ * such as time range and supports cursor-based pagination.
29
+ * The spans are returned in Phoenix's standard format with human-readable timestamps
30
+ * and simplified attribute structures.
31
+ *
32
+ * @experimental this function is experimental and may change in the future
33
+ *
34
+ * @param params - The parameters to search for spans
35
+ * @returns A paginated response containing spans and optional next cursor
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * // Get recent spans from a project
40
+ * const result = await getSpans({
41
+ * client,
42
+ * project: { projectName: "my-project" },
43
+ * limit: 50
44
+ * });
45
+ *
46
+ * // Get spans in a time range
47
+
48
+ * const result = await getSpans({
49
+ * client,
50
+ * project: { projectName: "my-project" },
51
+ * startTime: new Date("2024-01-01"),
52
+ * endTime: new Date("2024-01-02"),
53
+ * limit: 100
54
+ * });
55
+
56
+ *
57
+ * // Paginate through results
58
+ * let cursor: string | undefined;
59
+ * do {
60
+ * const result = await getSpans({
61
+ * client,
62
+ * project: { projectName: "my-project" },
63
+ * cursor,
64
+ * limit: 100
65
+ * });
66
+ *
67
+ * // Process spans
68
+ * result.spans.forEach(span => {
69
+ * console.log(`Span: ${span.name}, Trace: ${span.context.trace_id}`);
70
+ * });
71
+ *
72
+ * cursor = result.nextCursor || undefined;
73
+ * } while (cursor);
74
+ * ```
75
+ */
76
+ export declare function getSpans({ client: _client, project, cursor, limit, startTime, endTime, }: GetSpansParams): Promise<GetSpansResult>;
77
+ export {};
78
+ //# sourceMappingURL=getSpans.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSpans.d.ts","sourceRoot":"","sources":["../../../src/spans/getSpans.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;GAEG;AACH,UAAU,cAAe,SAAQ,QAAQ;IACvC,oCAAoC;IACpC,OAAO,EAAE,eAAe,CAAC;IACzB,kFAAkF;IAClF,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IACjC,kFAAkF;IAClF,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IAC/B,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,gBAAgB,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC;AAEnE,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/D,UAAU,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,aAAa,CAAC,CAAC;CAC5E,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAsB,QAAQ,CAAC,EAC7B,MAAM,EAAE,OAAO,EACf,OAAO,EACP,MAAM,EACN,KAAW,EACX,SAAS,EACT,OAAO,GACR,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAuC1C"}
@@ -0,0 +1,85 @@
1
+ import { createClient } from "../client.js";
2
+ /**
3
+ * Get spans from a project with filtering criteria.
4
+ *
5
+ * This method allows you to search for spans within a project using various filters
6
+ * such as time range and supports cursor-based pagination.
7
+ * The spans are returned in Phoenix's standard format with human-readable timestamps
8
+ * and simplified attribute structures.
9
+ *
10
+ * @experimental this function is experimental and may change in the future
11
+ *
12
+ * @param params - The parameters to search for spans
13
+ * @returns A paginated response containing spans and optional next cursor
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * // Get recent spans from a project
18
+ * const result = await getSpans({
19
+ * client,
20
+ * project: { projectName: "my-project" },
21
+ * limit: 50
22
+ * });
23
+ *
24
+ * // Get spans in a time range
25
+
26
+ * const result = await getSpans({
27
+ * client,
28
+ * project: { projectName: "my-project" },
29
+ * startTime: new Date("2024-01-01"),
30
+ * endTime: new Date("2024-01-02"),
31
+ * limit: 100
32
+ * });
33
+
34
+ *
35
+ * // Paginate through results
36
+ * let cursor: string | undefined;
37
+ * do {
38
+ * const result = await getSpans({
39
+ * client,
40
+ * project: { projectName: "my-project" },
41
+ * cursor,
42
+ * limit: 100
43
+ * });
44
+ *
45
+ * // Process spans
46
+ * result.spans.forEach(span => {
47
+ * console.log(`Span: ${span.name}, Trace: ${span.context.trace_id}`);
48
+ * });
49
+ *
50
+ * cursor = result.nextCursor || undefined;
51
+ * } while (cursor);
52
+ * ```
53
+ */
54
+ export async function getSpans({ client: _client, project, cursor, limit = 100, startTime, endTime, }) {
55
+ const client = _client ?? createClient();
56
+ const projectIdentifier = "projectId" in project ? project.projectId : project.projectName;
57
+ const params = {
58
+ limit,
59
+ };
60
+ if (cursor) {
61
+ params.cursor = cursor;
62
+ }
63
+ if (startTime) {
64
+ params.start_time =
65
+ startTime instanceof Date ? startTime.toISOString() : startTime;
66
+ }
67
+ if (endTime) {
68
+ params.end_time = endTime instanceof Date ? endTime.toISOString() : endTime;
69
+ }
70
+ const { data, error } = await client.GET("/v1/projects/{project_identifier}/spans", {
71
+ params: {
72
+ path: {
73
+ project_identifier: projectIdentifier,
74
+ },
75
+ query: params,
76
+ },
77
+ });
78
+ if (error)
79
+ throw error;
80
+ return {
81
+ spans: data?.data ?? [],
82
+ nextCursor: data?.next_cursor ?? null,
83
+ };
84
+ }
85
+ //# sourceMappingURL=getSpans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSpans.js","sourceRoot":"","sources":["../../../src/spans/getSpans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AA4BzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,EAC7B,MAAM,EAAE,OAAO,EACf,OAAO,EACP,MAAM,EACN,KAAK,GAAG,GAAG,EACX,SAAS,EACT,OAAO,GACQ;IACf,MAAM,MAAM,GAAG,OAAO,IAAI,YAAY,EAAE,CAAC;IACzC,MAAM,iBAAiB,GACrB,WAAW,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;IAEnE,MAAM,MAAM,GAA+D;QACzE,KAAK;KACN,CAAC;IAEF,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,CAAC,UAAU;YACf,SAAS,YAAY,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACpE,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,CAAC,QAAQ,GAAG,OAAO,YAAY,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9E,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CACtC,yCAAyC,EACzC;QACE,MAAM,EAAE;YACN,IAAI,EAAE;gBACJ,kBAAkB,EAAE,iBAAiB;aACtC;YACD,KAAK,EAAE,MAAM;SACd;KACF,CACF,CAAC;IAEF,IAAI,KAAK;QAAE,MAAM,KAAK,CAAC;IACvB,OAAO;QACL,KAAK,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE;QACvB,UAAU,EAAE,IAAI,EAAE,WAAW,IAAI,IAAI;KACtC,CAAC;AACJ,CAAC"}
@@ -1,3 +1,5 @@
1
1
  export * from "./addSpanAnnotation.js";
2
2
  export * from "./logSpanAnnotations.js";
3
+ export * from "./getSpans.js";
4
+ export * from "./getSpanAnnotations.js";
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
@@ -1,3 +1,5 @@
1
1
  export * from "./addSpanAnnotation.js";
2
2
  export * from "./logSpanAnnotations.js";
3
+ export * from "./getSpans.js";
4
+ export * from "./getSpanAnnotations.js";
3
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}