ai

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	AIAnthropicProvider  = "anthropic"
	AIClaudeProvider     = "claude"
	AICopilotProvider    = "copilot"
	AIDeepSeekProvider   = "deepseek"
	AIGeminiProvider     = "gemini"
	AIGitHubProvider     = "github"
	AIGoogleProvider     = "google"
	AIGrokProvider       = "grok"
	AIHetznerProvider    = "hetzner"
	AILocalProvider      = "local"
	AIMetaProvider       = "meta"
	AIMuseProvider       = "muse"
	AIOllamaProvider     = "ollama"
	AIOpenAIProvider     = "openai"
	AIOpenRouterProvider = "openrouter"
	AIvLLMProvider       = "vllm"
	AIXAIProvider        = "xai"

	DefaultClaudeModel     = "claude-sonnet-5"
	DefaultCopilotModel    = "gpt-6-luna"
	DefaultDeepSeekModel   = "deepseek-chat"
	DefaultGeminiModel     = "gemini-4-hydrogen"
	DefaultHetznerModel    = "meta-llama/Meta-Llama-3.1-70B-Instruct"
	DefaultLocalModel      = "llama3.2"
	DefaultMuseModel       = "muse-spark-1.3"
	DefaultOpenAIModel     = "gpt-6-luna"
	DefaultOpenRouterModel = "google/gemini-4-hydrogen"
	DefaultXAIModel        = "grok-2"

	DefaultClaudeBaseURL     = "https://api.anthropic.com/v1"
	DefaultDeepSeekBaseURL   = "https://api.deepseek.com"
	DefaultGeminiBaseURL     = "https://generativelanguage.googleapis.com/v1beta"
	DefaultHetznerBaseURL    = "https://inference.hetzner.com/api/v1"
	DefaultMuseBaseURL       = "https://api.meta.ai/v1"
	DefaultOpenAIBaseURL     = "https://api.openai.com/v1"
	DefaultOpenRouterBaseURL = "https://openrouter.ai/api/v1"
	DefaultXAIBaseURL        = "https://api.x.ai/v1"

	AnthropicAPIVersion = "2023-06-01"
)

Variables

This section is empty.

Functions

func GetModel

func GetModel(provider, fallbackModel string, models map[string]string) string

GetModel resolves the AI model to use based on provider, fallback model, and the models map.

func SetLogger

func SetLogger(l *logrus.Entry)

SetLogger sets the logger for the ai package.

Types

type ClaudeClient

type ClaudeClient struct {
	// contains filtered or unexported fields
}

func NewClaudeClient

func NewClaudeClient(token, baseURL, model string) (*ClaudeClient, error)

NewClaudeClient creates a client targeting Anthropic Claude Messages REST API.

func (*ClaudeClient) BaseURL

func (c *ClaudeClient) BaseURL() string

BaseURL returns the configured base URL.

func (*ClaudeClient) Summarize

func (c *ClaudeClient) Summarize(ctx context.Context, prompt string, thinking string) (*SummaryResult, error)

type CopilotClient

type CopilotClient struct {
	// contains filtered or unexported fields
}

func NewCopilotClient

func NewCopilotClient(token, model string) (*CopilotClient, error)

NewCopilotClient creates a client targeting the native GitHub Copilot API.

func (*CopilotClient) Summarize

func (c *CopilotClient) Summarize(ctx context.Context, prompt string, _ string) (*SummaryResult, error)

type GeminiClient

type GeminiClient struct {
	// contains filtered or unexported fields
}

func NewGeminiAPIKeyClient

func NewGeminiAPIKeyClient(apiKey, baseURL, model string) (*GeminiClient, error)

NewGeminiAPIKeyClient creates a new Gemini AI client targeting Google AI Studio authenticated via API key.

func NewGeminiClient

func NewGeminiClient(ctx context.Context, saFile, project, location, model string) (*GeminiClient, error)

NewGeminiClient creates a new Gemini AI client authenticated via service account credentials.

func (*GeminiClient) BaseURL

func (c *GeminiClient) BaseURL() string

BaseURL returns the configured base URL.

func (*GeminiClient) Project

func (c *GeminiClient) Project() string

Project returns the resolved GCP project ID.

func (*GeminiClient) ResolveModel

func (c *GeminiClient) ResolveModel(ctx context.Context, fallbackModel string) string

ResolveModel resolves a Gemini model name or shorthand against available models (cached for 12h), falling back to prefix normalization derived from fallbackModel, and updates the client's active model to the resolved ID.

func (*GeminiClient) Summarize

func (c *GeminiClient) Summarize(ctx context.Context, prompt string, thinking string) (*SummaryResult, error)

type OpenAIClient

type OpenAIClient struct {
	// contains filtered or unexported fields
}

func NewOpenAIClient

func NewOpenAIClient(token, baseURL, model string) (*OpenAIClient, error)

NewOpenAIClient creates a client targeting standard OpenAI or compatible REST endpoints.

func (*OpenAIClient) BaseURL

func (c *OpenAIClient) BaseURL() string

BaseURL returns the configured base URL.

func (*OpenAIClient) Summarize

func (c *OpenAIClient) Summarize(ctx context.Context, prompt string, _ string) (*SummaryResult, error)

type OpenRouterClient

type OpenRouterClient struct {
	// contains filtered or unexported fields
}

func NewOpenRouterClient

func NewOpenRouterClient(token, baseURL, model string) (*OpenRouterClient, error)

NewOpenRouterClient creates a client targeting the OpenRouter Chat Completions API.

func (*OpenRouterClient) BaseURL

func (c *OpenRouterClient) BaseURL() string

BaseURL returns the configured base URL.

func (*OpenRouterClient) Summarize

func (c *OpenRouterClient) Summarize(ctx context.Context, prompt string, thinking string) (*SummaryResult, error)

type Summarizer

type Summarizer interface {
	Summarize(ctx context.Context, prompt string, thinking string) (*SummaryResult, error)
}

type SummaryResult

type SummaryResult struct {
	Content string
	Model   string
	Usage   Usage
}

type Usage

type Usage struct {
	PromptTokens     int
	CacheHitTokens   int
	CacheMissTokens  int
	CompletionTokens int
	TotalTokens      int
	ReasoningTokens  int
	Cost             float64
}

Jump to

Keyboard shortcuts

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