@arizeai/phoenix-client 6.11.1 → 6.12.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 (40) hide show
  1. package/README.md +26 -0
  2. package/dist/esm/__generated__/api/v1.d.ts +18 -1
  3. package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
  4. package/dist/esm/spans/index.d.ts +1 -0
  5. package/dist/esm/spans/index.d.ts.map +1 -1
  6. package/dist/esm/spans/index.js +1 -0
  7. package/dist/esm/spans/index.js.map +1 -1
  8. package/dist/esm/spans/logSpans.d.ts +94 -0
  9. package/dist/esm/spans/logSpans.d.ts.map +1 -0
  10. package/dist/esm/spans/logSpans.js +216 -0
  11. package/dist/esm/spans/logSpans.js.map +1 -0
  12. package/dist/esm/testing/phoenix-test-tracking.d.ts +14 -0
  13. package/dist/esm/testing/phoenix-test-tracking.d.ts.map +1 -1
  14. package/dist/esm/testing/phoenix-test-tracking.js +49 -4
  15. package/dist/esm/testing/phoenix-test-tracking.js.map +1 -1
  16. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  17. package/dist/esm/utils/formatPromptMessages.d.ts.map +1 -1
  18. package/dist/esm/utils/getPromptBySelector.d.ts.map +1 -1
  19. package/dist/src/__generated__/api/v1.d.ts +18 -1
  20. package/dist/src/__generated__/api/v1.d.ts.map +1 -1
  21. package/dist/src/spans/index.d.ts +1 -0
  22. package/dist/src/spans/index.d.ts.map +1 -1
  23. package/dist/src/spans/index.js +1 -0
  24. package/dist/src/spans/index.js.map +1 -1
  25. package/dist/src/spans/logSpans.d.ts +94 -0
  26. package/dist/src/spans/logSpans.d.ts.map +1 -0
  27. package/dist/src/spans/logSpans.js +214 -0
  28. package/dist/src/spans/logSpans.js.map +1 -0
  29. package/dist/src/testing/phoenix-test-tracking.d.ts +14 -0
  30. package/dist/src/testing/phoenix-test-tracking.d.ts.map +1 -1
  31. package/dist/src/testing/phoenix-test-tracking.js +50 -3
  32. package/dist/src/testing/phoenix-test-tracking.js.map +1 -1
  33. package/dist/src/utils/formatPromptMessages.d.ts.map +1 -1
  34. package/dist/src/utils/getPromptBySelector.d.ts.map +1 -1
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +8 -8
  37. package/src/__generated__/api/v1.ts +18 -1
  38. package/src/spans/index.ts +1 -0
  39. package/src/spans/logSpans.ts +328 -0
  40. package/src/testing/phoenix-test-tracking.ts +55 -4
package/README.md CHANGED
@@ -544,6 +544,32 @@ const rootSpans = await getSpans({
544
544
  | `spanKind` | `SpanKindFilter \| SpanKindFilter[]` | Filter by span kind (`LLM`, `CHAIN`, `TOOL`, `RETRIEVER`, etc.) |
545
545
  | `statusCode` | `SpanStatusCode \| SpanStatusCode[]` | Filter by status code (`OK`, `ERROR`, `UNSET`) |
546
546
 
547
+ ### Logging Spans
548
+
549
+ Use `logSpans` to submit spans directly to a project using Phoenix's simplified span structure — the same shape returned by `getSpans`. This is useful for backfilling or migrating spans without going through OpenTelemetry. If your application is already instrumented with OpenTelemetry, export spans via `@arizeai/phoenix-otel` instead.
550
+
551
+ ```ts
552
+ import { logSpans } from "@arizeai/phoenix-client/spans";
553
+
554
+ const result = await logSpans({
555
+ project: { projectName: "my-project" },
556
+ spans: [
557
+ {
558
+ name: "chat_completion",
559
+ context: { trace_id: "abc123", span_id: "def456" },
560
+ span_kind: "LLM",
561
+ start_time: "2024-01-01T00:00:00Z",
562
+ end_time: "2024-01-01T00:00:01Z",
563
+ status_code: "OK",
564
+ attributes: { "llm.model_name": "gpt-4" },
565
+ },
566
+ ],
567
+ });
568
+ console.log(`Queued ${result.totalQueued} of ${result.totalReceived} spans`);
569
+ ```
570
+
571
+ If any span in the request is invalid or a duplicate of a span that already exists, none of the spans are queued and `logSpans` throws a `SpanCreationError` with `invalidSpans` and `duplicateSpans` details.
572
+
547
573
  ## Span Annotations
548
574
 
549
575
  The `spans` export also provides functions for managing span annotations — adding evaluations, feedback, and labels to spans.
@@ -1306,7 +1306,24 @@ export interface paths {
1306
1306
  };
1307
1307
  get?: never;
1308
1308
  put?: never;
1309
- /** Run Server Agent */
1309
+ /**
1310
+ * Run Server Agent
1311
+ * @description Stream a chat turn from the GraphQL server agent.
1312
+ *
1313
+ * This is the endpoint the PXI CLI talks to directly (no pre-configured
1314
+ * agent record): it builds a fresh server agent per request from the
1315
+ * caller-supplied model and contexts, then streams the reply back as
1316
+ * Vercel-AI chunks.
1317
+ *
1318
+ * The request contexts gate capabilities — GraphQL mutations, web access,
1319
+ * and subagents — and mutations are refused for viewer users. When trace
1320
+ * recording is enabled (and permitted by system settings), the run is
1321
+ * traced; locally ingested traces are persisted to the agent's project
1322
+ * once the stream completes.
1323
+ *
1324
+ * Returns ``403`` if agents or the server agent are disabled, or if a
1325
+ * viewer requests mutations.
1326
+ */
1310
1327
  post: operations["run_server_agent_agents_server_sessions__session_id__chat_post"];
1311
1328
  delete?: never;
1312
1329
  options?: never;