providers

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnthropicClient

type AnthropicClient[R any] struct {
	// contains filtered or unexported fields
}

AnthropicClient implements the Client interface for Anthropic API

func (*AnthropicClient[R]) Complete

func (c *AnthropicClient[R]) Complete(ctx context.Context, req *Request) (*R, Usage, error)

Complete sends a completion request to Anthropic API

func (*AnthropicClient[R]) Name

func (c *AnthropicClient[R]) Name() string

Name returns the provider name

func (*AnthropicClient[R]) Validate

func (c *AnthropicClient[R]) Validate() error

Validate checks if the client configuration is valid

type CerebrasChoice

type CerebrasChoice struct {
	Message struct {
		Role    string `json:"role"`
		Content string `json:"content"`
	} `json:"message"`
}

CerebrasChoice represents a choice in the API response

type CerebrasClient

type CerebrasClient[R any] struct {
	// contains filtered or unexported fields
}

CerebrasClient implements the Client interface for Cerebras API

func (*CerebrasClient[R]) Complete

func (c *CerebrasClient[R]) Complete(ctx context.Context, req *Request) (*R, Usage, error)

Complete sends a completion request to Cerebras API

func (*CerebrasClient[R]) Name

func (c *CerebrasClient[R]) Name() string

Name returns the provider name

func (*CerebrasClient[R]) Validate

func (c *CerebrasClient[R]) Validate() error

Validate checks if the client configuration is valid

type CerebrasJsonSchema

type CerebrasJsonSchema struct {
	Name   string `json:"name"`
	Strict bool   `json:"strict"`
	Schema any    `json:"schema"`
}

type CerebrasMessage

type CerebrasMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

CerebrasMessage represents a message in the chat completion request

type CerebrasRequest

type CerebrasRequest struct {
	Model          string                  `json:"model"`
	Messages       []CerebrasMessage       `json:"messages"`
	Temperature    *float64                `json:"temperature,omitempty"`
	MaxTokens      *int                    `json:"max_completion_tokens,omitempty"`
	ResponseFormat *CerebrasResponseFormat `json:"response_format,omitempty"`
}

CerebrasRequest represents the request payload for Cerebras API

type CerebrasResponse

type CerebrasResponse struct {
	ID      string           `json:"id"`
	Choices []CerebrasChoice `json:"choices"`
	Usage   CerebrasUsage    `json:"usage"`
	Created int64            `json:"created"`
	Model   string           `json:"model"`
}

CerebrasResponse represents the response from Cerebras API

type CerebrasResponseFormat

type CerebrasResponseFormat struct {
	Type       string             `json:"type"`
	JsonSchema CerebrasJsonSchema `json:"json_schema"`
}

type CerebrasUsage

type CerebrasUsage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

CerebrasUsage represents token usage in the API response

type Client

type Client[R any] interface {
	// Complete sends a completion request to the AI provider
	Complete(ctx context.Context, req *Request) (*R, Usage, error)

	// Name returns the name of the provider
	Name() string

	// Validate checks if the client configuration is valid
	Validate() error
}

Client defines the generic interface for AI providers

func CreateAIClient

func CreateAIClient(cfg *config.Config) (Client[IssueResponse], error)

func NewAnthropicClient

func NewAnthropicClient[R any](config *Config) (Client[R], error)

NewAnthropicClient creates a new Anthropic client

func NewCerebrasClient

func NewCerebrasClient[R any](config *Config) (Client[R], error)

NewCerebrasClient creates a new Cerebras client

func NewGeminiClient

func NewGeminiClient[R any](config *Config) (Client[R], error)

NewGeminiClient creates a new Gemini client

func NewOllamaClient

func NewOllamaClient[R any](config *Config) (Client[R], error)

NewOllamaClient creates a new Ollama client

func NewOpenAIClient

func NewOpenAIClient[R any](config *Config) (Client[R], error)

NewOpenAIClient creates a new OpenAI client

type Config

type Config struct {
	Provider    Provider
	Model       string
	APIKey      string
	BaseURL     string
	Temperature float64
	MaxTokens   int
}

Config holds common configuration for AI providers

type GeminiClient

type GeminiClient[R any] struct {
	// contains filtered or unexported fields
}

GeminiClient implements the Client interface for Google Gemini API

func (*GeminiClient[R]) Complete

func (c *GeminiClient[R]) Complete(ctx context.Context, req *Request) (*R, Usage, error)

Complete sends a completion request to Gemini API

func (*GeminiClient[R]) Name

func (c *GeminiClient[R]) Name() string

Name returns the provider name

func (*GeminiClient[R]) Validate

func (c *GeminiClient[R]) Validate() error

Validate checks if the client configuration is valid

type IssueResponse

type IssueResponse struct {
	Issues []SemanticIssue
}

IssueResponse represents the response from an AI provider for semantic issues

type OllamaClient

type OllamaClient[R any] struct {
	// contains filtered or unexported fields
}

func (*OllamaClient[R]) Complete

func (c *OllamaClient[R]) Complete(ctx context.Context, req *Request) (*R, Usage, error)

Complete sends a completion request to Ollama API

func (*OllamaClient[R]) Name

func (c *OllamaClient[R]) Name() string

Name returns the provider name

func (*OllamaClient[R]) Validate

func (c *OllamaClient[R]) Validate() error

Validate checks if the client configuration is valid

type OpenAIClient

type OpenAIClient[R any] struct {
	// contains filtered or unexported fields
}

OpenAIClient implements the Client interface for OpenAI API

func (*OpenAIClient[R]) Complete

func (c *OpenAIClient[R]) Complete(ctx context.Context, req *Request) (*R, Usage, error)

Complete sends a completion request to OpenAI API

func (*OpenAIClient[R]) Name

func (c *OpenAIClient[R]) Name() string

Name returns the provider name

func (*OpenAIClient[R]) Validate

func (c *OpenAIClient[R]) Validate() error

Validate checks if the client configuration is valid

type Provider

type Provider string
const (
	ProviderOpenAI    Provider = "openai"
	ProviderAnthropic Provider = "anthropic"
	ProviderGemini    Provider = "gemini"
	ProviderOllama    Provider = "ollama"
	ProviderCerebras  Provider = "cerebras"
)

func GetAllProviders

func GetAllProviders() []Provider

func ToProvider

func ToProvider(provider string) (Provider, error)

type ProviderDefaults

type ProviderDefaults struct {
	Model     string
	ApiKeyVar string
}

func GetProviderDefaults

func GetProviderDefaults(provider Provider) ProviderDefaults

type Request

type Request struct {
	SystemPrompt string
	UserPrompt   string
}

Request represents a request to an AI provider

type SemanticIssue

type SemanticIssue struct {
	Reasoning  string `json:"reasoning" jsonschema_description:"Reasoning why the found issue has it's severity level"`
	Level      string `json:"level" jsonschema_description:"Severity level of the issue"`
	Message    string `json:"message" jsonschema_description:"Description of the issue"`
	Suggestion string `json:"suggestion" jsonschema_description:"Suggestion for fixing the issue (optional)"`
	File       string `json:"file" jsonschema_description:"The file that the issue is in"`
}

SemanticIssue represents a single issue found during semantic analysis

type Usage

type Usage struct {
	InputTokens  int
	OutputTokens int
	TotalTokens  int
}

Usage represents token usage information

Jump to

Keyboard shortcuts

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