Documentation
¶
Overview ¶
Package phoenix provides a Go client for the Arize Phoenix API.
Phoenix is an open-source AI observability platform for experimentation, evaluation, and troubleshooting of LLM applications.
The client wraps the ogen-generated API client with a higher-level interface that handles authentication and provides convenient methods for common operations.
Index ¶
- Constants
- Variables
- func IsForbidden(err error) bool
- func IsNotFound(err error) bool
- func IsRateLimited(err error) bool
- func IsUnauthorized(err error) bool
- type APIError
- type Annotation
- type AnnotationOption
- type AnnotatorKind
- type Client
- func (c *Client) API() *api.Client
- func (c *Client) AddDatasetExamples(ctx context.Context, datasetName string, examples []DatasetExample) error
- func (c *Client) Config() *Config
- func (c *Client) CreateChatPrompt(ctx context.Context, name string, messages []PromptMessage, modelName string, ...) (*PromptVersion, error)
- func (c *Client) CreateDataset(ctx context.Context, name string, examples []DatasetExample, ...) (*Dataset, error)
- func (c *Client) CreateProject(ctx context.Context, name string, opts ...ProjectOption) (*Project, error)
- func (c *Client) CreatePrompt(ctx context.Context, name string, template string, modelName string, ...) (*PromptVersion, error)
- func (c *Client) CreateSpanAnnotation(ctx context.Context, spanID, name string, score float64, ...) error
- func (c *Client) CreateTraceAnnotation(ctx context.Context, traceID, name string, score float64, ...) error
- func (c *Client) DeleteDataset(ctx context.Context, id string) error
- func (c *Client) DeleteExperiment(ctx context.Context, experimentID string) error
- func (c *Client) DeleteProject(ctx context.Context, identifier string) error
- func (c *Client) DeleteSpan(ctx context.Context, spanIdentifier string) error
- func (c *Client) DeleteTrace(ctx context.Context, traceIdentifier string) error
- func (c *Client) GetDataset(ctx context.Context, id string) (*Dataset, error)
- func (c *Client) GetProject(ctx context.Context, identifier string) (*Project, error)
- func (c *Client) GetPromptLatest(ctx context.Context, name string) (*PromptVersion, error)
- func (c *Client) GetPromptVersion(ctx context.Context, versionID string) (*PromptVersion, error)
- func (c *Client) GetPromptVersionByTag(ctx context.Context, promptName, tagName string) (*PromptVersion, error)
- func (c *Client) GetSpans(ctx context.Context, projectIdentifier string, opts ...SpanOption) ([]*Span, string, error)
- func (c *Client) ListDatasets(ctx context.Context, opts ...ListOption) ([]*Dataset, string, error)
- func (c *Client) ListExperiments(ctx context.Context, datasetID string, opts ...ListOption) ([]*Experiment, string, error)
- func (c *Client) ListProjects(ctx context.Context, opts ...ListOption) ([]*Project, string, error)
- func (c *Client) ListPromptVersions(ctx context.Context, promptName string, opts ...ListOption) ([]*PromptVersion, string, error)
- func (c *Client) ListPrompts(ctx context.Context, opts ...ListOption) ([]*Prompt, string, error)
- func (c *Client) ListSpanAnnotations(ctx context.Context, spanIDs []string) ([]*Annotation, error)
- func (c *Client) ListTraceAnnotations(ctx context.Context, traceIDs []string) ([]*Annotation, error)
- func (c *Client) ProjectName() string
- func (c *Client) SetProjectName(name string)
- type Config
- type Dataset
- type DatasetExample
- type DatasetOption
- type Experiment
- type ListOption
- type Option
- type Project
- type ProjectOption
- type Prompt
- type PromptMessage
- type PromptModelProvider
- type PromptOption
- type PromptTemplateType
- type PromptVersion
- type Span
- type SpanOption
Constants ¶
const ( // DefaultURL is the default Phoenix API URL for local instances. DefaultURL = "http://localhost:6006" // DefaultProjectName is the default project name. DefaultProjectName = "default" )
const ( EnvURL = "PHOENIX_URL" EnvAPIKey = "PHOENIX_API_KEY" //nolint:gosec // G101: This is an environment variable name, not a credential EnvProjectName = "PHOENIX_PROJECT_NAME" EnvSpaceID = "PHOENIX_SPACE_ID" )
Environment variable names.
const Version = "0.1.0"
Version is the SDK version.
Variables ¶
var ( // ErrMissingURL is returned when the API URL is not configured. ErrMissingURL = errors.New("phoenix: missing API URL") // ErrMissingAPIKey is returned when the API key is required but not provided. ErrMissingAPIKey = errors.New("phoenix: missing API key") // ErrProjectNotFound is returned when a project cannot be found. ErrProjectNotFound = errors.New("phoenix: project not found") // ErrTraceNotFound is returned when a trace cannot be found. ErrTraceNotFound = errors.New("phoenix: trace not found") // ErrSpanNotFound is returned when a span cannot be found. ErrSpanNotFound = errors.New("phoenix: span not found") // ErrDatasetNotFound is returned when a dataset cannot be found. ErrDatasetNotFound = errors.New("phoenix: dataset not found") // ErrExperimentNotFound is returned when an experiment cannot be found. ErrExperimentNotFound = errors.New("phoenix: experiment not found") // ErrPromptNotFound is returned when a prompt cannot be found. ErrPromptNotFound = errors.New("phoenix: prompt not found") // ErrInvalidInput is returned when input validation fails. ErrInvalidInput = errors.New("phoenix: invalid input") )
Sentinel errors for the Phoenix SDK.
Functions ¶
func IsForbidden ¶
IsForbidden returns true if the error indicates access is forbidden.
func IsNotFound ¶
IsNotFound returns true if the error indicates a resource was not found.
func IsRateLimited ¶
IsRateLimited returns true if the error indicates rate limiting.
func IsUnauthorized ¶
IsUnauthorized returns true if the error indicates an authentication failure.
Types ¶
type Annotation ¶
type Annotation struct {
ID string
SpanID string // Set for span annotations
TraceID string // Set for trace annotations
Name string
Score float64
Label string
Explanation string
Source AnnotatorKind
CreatedAt time.Time
UpdatedAt time.Time
}
Annotation represents a Phoenix annotation on a span or trace.
type AnnotationOption ¶
type AnnotationOption func(*annotationOptions)
AnnotationOption configures annotation creation.
func WithAnnotationExplanation ¶
func WithAnnotationExplanation(explanation string) AnnotationOption
WithAnnotationExplanation sets the explanation for the annotation.
func WithAnnotationLabel ¶
func WithAnnotationLabel(label string) AnnotationOption
WithAnnotationLabel sets the label for the annotation.
func WithAnnotationSource ¶
func WithAnnotationSource(source AnnotatorKind) AnnotationOption
WithAnnotationSource sets the source (annotator kind) for the annotation.
type AnnotatorKind ¶
type AnnotatorKind string
AnnotatorKind indicates who created the annotation.
const ( AnnotatorKindHuman AnnotatorKind = "HUMAN" AnnotatorKindLLM AnnotatorKind = "LLM" AnnotatorKindCode AnnotatorKind = "CODE" )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main Phoenix client for interacting with the API.
func (*Client) API ¶
API returns the underlying ogen-generated API client for advanced usage. Use this when you need access to API endpoints not covered by the high-level wrapper methods.
func (*Client) AddDatasetExamples ¶
func (c *Client) AddDatasetExamples(ctx context.Context, datasetName string, examples []DatasetExample) error
AddDatasetExamples appends examples to an existing dataset.
func (*Client) CreateChatPrompt ¶
func (c *Client) CreateChatPrompt(ctx context.Context, name string, messages []PromptMessage, modelName string, modelProvider PromptModelProvider, opts ...PromptOption) (*PromptVersion, error)
CreateChatPrompt creates a new chat-style prompt with messages.
func (*Client) CreateDataset ¶
func (c *Client) CreateDataset(ctx context.Context, name string, examples []DatasetExample, opts ...DatasetOption) (*Dataset, error)
CreateDataset creates a new dataset with the given examples.
func (*Client) CreateProject ¶
func (c *Client) CreateProject(ctx context.Context, name string, opts ...ProjectOption) (*Project, error)
CreateProject creates a new project.
func (*Client) CreatePrompt ¶
func (c *Client) CreatePrompt(ctx context.Context, name string, template string, modelName string, modelProvider PromptModelProvider, opts ...PromptOption) (*PromptVersion, error)
CreatePrompt creates a new prompt with the given template.
func (*Client) CreateSpanAnnotation ¶
func (c *Client) CreateSpanAnnotation(ctx context.Context, spanID, name string, score float64, opts ...AnnotationOption) error
CreateSpanAnnotation creates an annotation on a span.
func (*Client) CreateTraceAnnotation ¶
func (c *Client) CreateTraceAnnotation(ctx context.Context, traceID, name string, score float64, opts ...AnnotationOption) error
CreateTraceAnnotation creates an annotation on a trace.
func (*Client) DeleteDataset ¶
DeleteDataset deletes a dataset by ID.
func (*Client) DeleteExperiment ¶
DeleteExperiment deletes an experiment.
func (*Client) DeleteProject ¶
DeleteProject deletes a project by identifier.
func (*Client) DeleteSpan ¶
DeleteSpan deletes a span.
func (*Client) DeleteTrace ¶
DeleteTrace deletes a trace.
func (*Client) GetDataset ¶
GetDataset retrieves a dataset by ID.
func (*Client) GetProject ¶
GetProject retrieves a project by identifier (ID or name).
func (*Client) GetPromptLatest ¶
GetPromptLatest retrieves the latest version of a prompt by name.
func (*Client) GetPromptVersion ¶
GetPromptVersion retrieves a specific prompt version by its ID.
func (*Client) GetPromptVersionByTag ¶
func (c *Client) GetPromptVersionByTag(ctx context.Context, promptName, tagName string) (*PromptVersion, error)
GetPromptVersionByTag retrieves a prompt version by its tag name.
func (*Client) GetSpans ¶
func (c *Client) GetSpans(ctx context.Context, projectIdentifier string, opts ...SpanOption) ([]*Span, string, error)
GetSpans retrieves spans for a project.
func (*Client) ListDatasets ¶
ListDatasets lists all datasets.
func (*Client) ListExperiments ¶
func (c *Client) ListExperiments(ctx context.Context, datasetID string, opts ...ListOption) ([]*Experiment, string, error)
ListExperiments lists experiments for a dataset.
func (*Client) ListProjects ¶
ListProjects lists all projects.
func (*Client) ListPromptVersions ¶
func (c *Client) ListPromptVersions(ctx context.Context, promptName string, opts ...ListOption) ([]*PromptVersion, string, error)
ListPromptVersions lists all versions of a prompt.
func (*Client) ListPrompts ¶
ListPrompts lists all prompts.
func (*Client) ListSpanAnnotations ¶
ListSpanAnnotations lists annotations for the given span IDs.
func (*Client) ListTraceAnnotations ¶
func (c *Client) ListTraceAnnotations(ctx context.Context, traceIDs []string) ([]*Annotation, error)
ListTraceAnnotations lists annotations for the given trace IDs.
func (*Client) ProjectName ¶
ProjectName returns the default project name.
func (*Client) SetProjectName ¶
SetProjectName sets the default project name.
type Config ¶
type Config struct {
// URL is the Phoenix API endpoint URL.
// Defaults to DefaultURL (http://localhost:6006).
// For Phoenix Cloud, use https://app.phoenix.arize.com
URL string
// SpaceID is the space identifier for Phoenix Cloud.
// When set, the URL is constructed as {URL}/s/{SpaceID}.
// Not needed for self-hosted Phoenix instances.
SpaceID string
// APIKey is the API key for authentication.
// Optional for local instances, may be required for hosted instances.
APIKey string
// ProjectName is the default project name for operations.
ProjectName string
}
Config holds the configuration for the Phoenix client.
func LoadConfig ¶
func LoadConfig() *Config
LoadConfig loads configuration from environment variables. Priority order (highest to lowest):
- Explicitly set values (via options)
- Environment variables
- Default values
type Dataset ¶
type Dataset struct {
ID string
Name string
Description string
ExampleCount int
CreatedAt time.Time
UpdatedAt time.Time
}
Dataset represents a Phoenix dataset.
type DatasetExample ¶
type DatasetExample struct {
Input any `json:"input,omitempty"`
Output any `json:"output,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
DatasetExample represents an example in a dataset.
type DatasetOption ¶
type DatasetOption func(*datasetOptions)
DatasetOption is a functional option for dataset operations.
func WithDatasetDescription ¶
func WithDatasetDescription(desc string) DatasetOption
WithDatasetDescription sets the dataset description.
type Experiment ¶
type Experiment struct {
ID string
DatasetID string
DatasetVersionID string
ProjectName string
ExampleCount int
SuccessfulRunCount int
FailedRunCount int
MissingRunCount int
Repetitions int
CreatedAt time.Time
UpdatedAt time.Time
}
Experiment represents a Phoenix experiment.
type ListOption ¶
type ListOption func(*listOptions)
ListOption is a functional option for list operations.
func WithLimit ¶
func WithLimit(limit int) ListOption
WithLimit sets the maximum number of items to return.
type Option ¶
type Option func(*clientOptions)
Option is a functional option for configuring the Client.
func WithAPIKey ¶
WithAPIKey sets the API key for authentication.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client.
func WithProjectName ¶
WithProjectName sets the default project name.
func WithSpaceID ¶
WithSpaceID sets the space identifier for Phoenix Cloud. When using Phoenix Cloud (app.phoenix.arize.com), set this to your space ID. The URL will be constructed as {BaseURL}/s/{SpaceID}.
func WithTimeout ¶
WithTimeout sets the request timeout.
type Project ¶
type Project struct {
ID string
Name string
Description string
CreatedAt time.Time
UpdatedAt time.Time
}
Project represents a Phoenix project.
type ProjectOption ¶
type ProjectOption func(*projectOptions)
ProjectOption is a functional option for project operations.
func WithDescription ¶
func WithDescription(desc string) ProjectOption
WithDescription sets the project description.
type PromptMessage ¶
PromptMessage represents a message in a chat prompt.
type PromptModelProvider ¶
type PromptModelProvider string
PromptModelProvider represents the LLM provider for a prompt.
const ( PromptModelProviderOpenAI PromptModelProvider = "OPENAI" PromptModelProviderAzureOpenAI PromptModelProvider = "AZURE_OPENAI" PromptModelProviderAnthropic PromptModelProvider = "ANTHROPIC" PromptModelProviderGoogle PromptModelProvider = "GOOGLE" PromptModelProviderDeepseek PromptModelProvider = "DEEPSEEK" PromptModelProviderXAI PromptModelProvider = "XAI" PromptModelProviderOllama PromptModelProvider = "OLLAMA" PromptModelProviderAWS PromptModelProvider = "AWS" )
type PromptOption ¶
type PromptOption func(*promptOptions)
PromptOption is a functional option for prompt operations.
func WithPromptDescription ¶
func WithPromptDescription(desc string) PromptOption
WithPromptDescription sets the prompt description.
type PromptTemplateType ¶
type PromptTemplateType string
PromptTemplateType represents the type of prompt template.
const ( PromptTemplateTypeChat PromptTemplateType = "CHAT" PromptTemplateTypeString PromptTemplateType = "STRING" )
type PromptVersion ¶
type PromptVersion struct {
ID string
Description string
Template string // The prompt template content
TemplateType PromptTemplateType
ModelName string
ModelProvider PromptModelProvider
}
PromptVersion represents a version of a prompt.
type Span ¶
type Span struct {
ID string
Name string
SpanKind string
StatusCode string
StatusMessage string
ParentID string
TraceID string
SpanID string
StartTime time.Time
EndTime time.Time
}
Span represents a Phoenix span.
type SpanOption ¶
type SpanOption func(*spanOptions)
SpanOption is a functional option for span operations.
func WithSpanCursor ¶
func WithSpanCursor(cursor string) SpanOption
WithSpanCursor sets the pagination cursor for spans.
func WithSpanLimit ¶
func WithSpanLimit(limit int) SpanOption
WithSpanLimit sets the max number of spans to return.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
openapi-convert
command
Command openapi-convert converts OpenAPI 3.1 specs to 3.0.3 for ogen compatibility.
|
Command openapi-convert converts OpenAPI 3.1 specs to 3.0.3 for ogen compatibility. |
|
Package evals provides evaluation capabilities for Phoenix.
|
Package evals provides evaluation capabilities for Phoenix. |
|
internal
|
|
|
api
Code generated by ogen, DO NOT EDIT.
|
Code generated by ogen, DO NOT EDIT. |
|
Package llmops provides an omniobserve/llmops adapter for go-phoenix.
|
Package llmops provides an omniobserve/llmops adapter for go-phoenix. |
|
Package otel provides OpenTelemetry integration for Phoenix.
|
Package otel provides OpenTelemetry integration for Phoenix. |