Documentation
¶
Overview ¶
Package ai provides a unified interface for AI provider integrations. It supports OpenAI and Anthropic providers with a common Chat interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatRequest ¶
type ChatRequest struct {
Provider string
Model string
Messages []Message
MaxTokens int
Temperature float64
Endpoint string // Optional custom endpoint URL (overrides env)
}
ChatRequest represents a unified chat request
type ChatResponse ¶
type ChatResponse struct {
Content string
Model string
Usage Usage
// Tracking info for logging/debugging
Endpoint string // Full URL used for the request
RequestJSON string // Raw request body JSON
ResponseJSON string // Raw response body JSON
}
ChatResponse represents the unified response from AI providers
type Client ¶
type Client interface {
Chat(functionID string, req ChatRequest) (*ChatResponse, error)
}
Client is an interface for making AI chat requests
type DefaultClient ¶
type DefaultClient struct {
// contains filtered or unexported fields
}
DefaultClient is the default implementation of Client
func NewDefaultClient ¶
func NewDefaultClient(httpClient internalhttp.Client, envStore env.Store) *DefaultClient
NewDefaultClient creates a new AI client
func (*DefaultClient) Chat ¶
func (c *DefaultClient) Chat(functionID string, req ChatRequest) (*ChatResponse, error)
Chat executes a chat request using the specified provider
type MemoryTracker ¶
type MemoryTracker struct {
// contains filtered or unexported fields
}
MemoryTracker is an in-memory implementation of Tracker
func NewMemoryTracker ¶
func NewMemoryTracker() *MemoryTracker
NewMemoryTracker creates a new in-memory tracker
func (*MemoryTracker) Requests ¶
func (m *MemoryTracker) Requests(executionID string) []store.AIRequest
Requests returns all AI requests for the specified executionID
func (*MemoryTracker) RequestsPaginated ¶
func (m *MemoryTracker) RequestsPaginated(executionID string, limit, offset int) ([]store.AIRequest, int64)
RequestsPaginated returns paginated AI requests for the specified executionID
func (*MemoryTracker) Track ¶
func (m *MemoryTracker) Track(executionID string, req TrackRequest)
Track records an AI request
type SQLiteTracker ¶
type SQLiteTracker struct {
// contains filtered or unexported fields
}
SQLiteTracker is a SQLite-backed implementation of Tracker
func NewSQLiteTracker ¶
func NewSQLiteTracker(db *sql.DB) *SQLiteTracker
NewSQLiteTracker creates a new SQLite-backed tracker
func (*SQLiteTracker) Requests ¶
func (s *SQLiteTracker) Requests(executionID string) []store.AIRequest
Requests returns all AI requests for the specified executionID
func (*SQLiteTracker) RequestsPaginated ¶
func (s *SQLiteTracker) RequestsPaginated(executionID string, limit, offset int) ([]store.AIRequest, int64)
RequestsPaginated returns paginated AI requests for the specified executionID
func (*SQLiteTracker) Track ¶
func (s *SQLiteTracker) Track(executionID string, req TrackRequest)
Track records an AI request
type TrackRequest ¶
type TrackRequest struct {
Provider string
Model string
Endpoint string
RequestJSON string
ResponseJSON *string
Status store.AIRequestStatus
ErrorMessage *string
InputTokens *int
OutputTokens *int
DurationMs int64
}
TrackRequest contains the data needed to track an AI request
type Tracker ¶
type Tracker interface {
Track(executionID string, req TrackRequest)
Requests(executionID string) []store.AIRequest
RequestsPaginated(executionID string, limit, offset int) ([]store.AIRequest, int64)
}
Tracker is an interface for tracking AI requests executionID is used to isolate requests for each function execution