common

package
v1.0.65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package common provides shared utilities and infrastructure for AI provider implementations. This includes standardized error handling, authentication helpers, configuration management, health checking, metrics collection, and other common functionality across providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError added in v1.0.4

type APIError struct {
	StatusCode int
	Type       APIErrorType
	Message    string
	RawBody    string
	Retryable  bool
}

APIError represents a standardized provider error

func (*APIError) Error added in v1.0.4

func (e *APIError) Error() string

Error implements the error interface

func (*APIError) IsRateLimit added in v1.0.4

func (e *APIError) IsRateLimit() bool

IsRateLimit checks if the error is a rate limit error

func (*APIError) IsRetryable added in v1.0.4

func (e *APIError) IsRetryable() bool

IsRetryable checks if the error is retryable

type APIErrorType added in v1.0.4

type APIErrorType string

APIErrorType classifies API errors

const (
	APIErrorTypeRateLimit      APIErrorType = "rate_limit"
	APIErrorTypeAuth           APIErrorType = "auth"
	APIErrorTypeNotFound       APIErrorType = "not_found"
	APIErrorTypeInvalidRequest APIErrorType = "invalid_request"
	APIErrorTypeServer         APIErrorType = "server_error"
	APIErrorTypeUnknown        APIErrorType = "unknown"
)

type ErrorClassifier added in v1.0.4

type ErrorClassifier interface {
	Classify(statusCode int, body []byte) *APIError
}

ErrorClassifier interface for provider-specific error parsing Providers can implement this to provide more detailed error classification based on their specific API error response formats

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL