Skip to content

feat(prompts): add prompts module — CRUDL REST API + GraphQL content retrieval#3

Closed
ai-pilo wants to merge 50 commits intoArize-ai:mainfrom
ai-pilo:feat/support-for-prompts
Closed

feat(prompts): add prompts module — CRUDL REST API + GraphQL content retrieval#3
ai-pilo wants to merge 50 commits intoArize-ai:mainfrom
ai-pilo:feat/support-for-prompts

Conversation

@ai-pilo
Copy link
Copy Markdown

@ai-pilo ai-pilo commented Feb 27, 2026

Summary

This PR adds a full prompts module to @arizeai/ax-client, following the same conventions established by datasets, experiments, and annotation_configs.

What's added

REST CRUD (v2 Prompts API):

  • listPrompts — paginated list of prompts, filterable by space
  • createPrompt — create a prompt with initial version (messages, provider, LLM params)
  • getPrompt — fetch prompt metadata by ID
  • updatePrompt — patch description and tags
  • deletePrompt — remove a prompt by ID

GraphQL content retrieval (alpha):

  • getPromptContent — full prompt content including messages, LLM parameters, and version history via GraphQL
  • listPromptsWithContent — paginated list with full content via GraphQL

Internal:

  • src/graphql/ — minimal GraphQL transport layer (graphqlFetch) for authenticated POST requests

Why two transports?

The REST v2 GET /v2/prompts/{id} endpoint returns metadata only (name, tags, timestamps). Full content — messages, LLM parameters, version history — is currently only available via GraphQL. The GraphQL functions are marked alpha and will be consolidated once the REST API is extended.

Design decisions

Decision Rationale
Record<string, unknown> for message/param fields in PromptWithContent LLM message structure varies significantly by provider; the OpenAPI schema is permissive; typed on input via LLMMessage/InvocationParams where we control the shape
GraphQL Relay node IDs (not REST IDs) GraphQL requires base64-encoded Relay Global IDs; documented clearly in README and JSDoc
warnPreRelease() on all prompts functions Entire module is new; marks all functions as subject to change until API stabilizes
No HTTP-level integration tests for REST CRUD Consistent with existing modules (datasets, experiments) which unit-test transforms only

Module structure

Follows the established pattern:

src/prompts/
  index.ts
  listPrompts.ts / createPrompt.ts / getPrompt.ts / updatePrompt.ts / deletePrompt.ts
  getPromptContent.ts / listPromptsWithContent.ts
  transformGraphQL.ts
  utils.ts
  __tests__/
    fixtures.ts
    utils.test.ts
    getPromptContent.test.ts
    listPromptsWithContent.test.ts
    transformGraphQL.test.ts

src/graphql/
  client.ts
  index.ts
  queries/prompts.ts

Tests

  • 60 tests total, all passing
  • GraphQL layer: 100% statement/branch/function coverage
  • New client.ts tests: 48% → 96% coverage
  • Added branch coverage for datasets/utils.ts and experiments/utils.ts

Checklist

  • Follows existing module conventions
  • All public functions documented with JSDoc
  • Types exported from src/types/index.ts
  • pnpm test passes (60/60)
  • pnpm run type:check passes
  • CHANGELOG updated
  • README updated with examples
  • Version bumped 1.2.0 → 1.3.0

🤖 Generated with Claude Code

ai-pilo and others added 30 commits February 25, 2026 21:27
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ions

- Add missing @param docs for 5 optional params in createPrompt
- Add "An optional" prefix to optional params in updatePrompt
- Remove @remarks tags from all 4 files (no reference module uses them)
- Use explicit field enumeration in transformPrompt (match majority convention)
- Use fixture field references in test assertions instead of hardcoded strings
- Remove unused mockDateString variable from fixtures

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…reRelease to all prompts functions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…es in README

- promptId → promptNodeId (GraphQL Relay Global ID, not REST ID)
- content.promptVersions → content.versions (correct property name)
- spaceId → spaceNodeId in listPromptsWithContent example
- Add by-name lookup example and Relay ID clarification note

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…throwing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…kup in pushPrompt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…unctions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ures.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ai-pilo and others added 20 commits February 28, 2026 09:54
…elegating to findPromptByName

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…l.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ionId support

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fjcasti1
Copy link
Copy Markdown
Collaborator

Hey @ai-pilo , thanks for the PR. We actually support it now. Thank you!

@fjcasti1 fjcasti1 closed this Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants