Documentation
¶
Overview ¶
Package backendtypes defines types for backend server configuration and API communication.
This package provides shared type definitions used by the backend package and applications built on ai-provider-kit. It separates type definitions from implementation to allow clean imports without circular dependencies.
Type Categories ¶
The package defines several categories of types:
Configuration Types ¶
BackendConfig and related types define how the backend server is configured:
- ServerConfig: HTTP server settings (host, port, timeouts)
- AuthConfig: Authentication configuration
- LoggingConfig: Logging settings
- CORSConfig: Cross-origin resource sharing settings
- ExtensionConfig: Per-extension configuration
Request Types ¶
Request types define the structure of incoming API requests:
- ChatRequest: Chat completion requests
- StreamRequest: Streaming requests
Response Types ¶
Response types define the structure of API responses:
- ChatResponse: Chat completion responses
- ErrorResponse: Standard error format
- HealthResponse: Health check responses
Usage ¶
Import this package to use backend types without importing the full backend implementation:
import "github.com/cecil-the-coder/ai-provider-kit/pkg/backendtypes"
config := backendtypes.BackendConfig{
Server: backendtypes.ServerConfig{Port: 8080},
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
type APIResponse struct {
Success bool `json:"success"`
Data interface{} `json:"data,omitempty"`
Error *APIError `json:"error,omitempty"`
RequestID string `json:"request_id,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
APIResponse is the standard response wrapper
type AuthConfig ¶
type BackendConfig ¶
type BackendConfig struct {
Server ServerConfig `yaml:"server"`
Auth AuthConfig `yaml:"auth"`
Logging LoggingConfig `yaml:"logging"`
CORS CORSConfig `yaml:"cors"`
Providers map[string]*types.ProviderConfig `yaml:"providers"`
Extensions map[string]ExtensionConfig `yaml:"extensions"`
}
BackendConfig defines the configuration for the backend server
type CORSConfig ¶
type ExtensionConfig ¶
type GenerateRequest ¶
type GenerateRequest struct {
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Prompt string `json:"prompt"`
Messages []types.ChatMessage `json:"messages,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
Stream bool `json:"stream,omitempty"`
Tools []types.Tool `json:"tools,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
GenerateRequest represents a code/chat generation request
type GenerateResponse ¶
type GenerateResponse struct {
Content string `json:"content"`
Model string `json:"model"`
Provider string `json:"provider"`
Usage *UsageInfo `json:"usage,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
GenerateResponse for code/chat generation
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
Version string `json:"version"`
Uptime string `json:"uptime"`
Providers map[string]ProviderHealth `json:"providers,omitempty"`
}
HealthResponse for health endpoints
type LoggingConfig ¶
type ProviderConfigRequest ¶
type ProviderConfigRequest struct {
Type string `json:"type"`
APIKey string `json:"api_key,omitempty"`
APIKeys []string `json:"api_keys,omitempty"`
DefaultModel string `json:"default_model,omitempty"`
BaseURL string `json:"base_url,omitempty"`
Enabled bool `json:"enabled"`
}
ProviderConfigRequest for updating provider configuration
type ProviderHealth ¶
type ProviderInfo ¶
type ProviderInfo struct {
Name string `json:"name"`
Type string `json:"type"`
Enabled bool `json:"enabled"`
Healthy bool `json:"healthy"`
Models []string `json:"models,omitempty"`
Description string `json:"description,omitempty"`
}
ProviderInfo for provider listing