mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-03 20:13:03 +00:00
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
// Package ai provides AI integration for embeddings and context injection.
|
|
package ai
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// Config holds AI configuration.
|
|
type Config struct {
|
|
Provider string `yaml:"provider"`
|
|
Model string `yaml:"model"`
|
|
Dimensions int `yaml:"dimensions"`
|
|
APIKey string `yaml:"api_key"`
|
|
BatchSize int `yaml:"batch_size"`
|
|
BaseURL string `yaml:"base_url"`
|
|
Temperature float64 `yaml:"temperature"`
|
|
}
|
|
|
|
// Client provides AI operations.
|
|
type Client interface {
|
|
// Embed generates embeddings for texts.
|
|
Embed(ctx context.Context, texts []string) ([][]float32, error)
|
|
|
|
// QueryWithContext generates a response with context injection.
|
|
QueryWithContext(ctx context.Context, query string, context []string) (string, error)
|
|
}
|
|
|
|
// NewClient creates a new AI client based on provider.
|
|
func NewClient(config *Config) Client {
|
|
switch config.Provider {
|
|
case "openai":
|
|
return NewOpenAIClient(config)
|
|
case "mock":
|
|
return NewMockClient(config.Dimensions)
|
|
default:
|
|
return NewMockClient(1536)
|
|
}
|
|
}
|