generic

package
v0.3.66 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 7 Imported by: 0 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

Overview

Package generic provides an AIProvider implementation for any OpenAI-compatible API. This can be used with providers like Ollama, Together AI, Fireworks, vLLM, or any other service that implements the OpenAI chat completions API format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Name is the unique provider name (e.g., "ollama", "together", "fireworks").
	Name string

	// BaseURL is the base URL for the API (e.g., "http://localhost:11434/v1").
	BaseURL string

	// APIKey is the bearer token for authentication (optional for local providers).
	APIKey string //nolint:gosec // G117: config field

	// Models lists the models available from this provider.
	Models []ai.ModelInfo

	// Headers adds extra HTTP headers to every request.
	Headers map[string]string

	// SupportsTools indicates whether this provider supports function/tool calling.
	SupportsTools bool
}

Config holds configuration for a generic OpenAI-compatible provider.

type Provider

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

Provider implements ai.AIProvider for any OpenAI-compatible API.

func New

func New(cfg Config) (*Provider, error)

New creates a new generic OpenAI-compatible provider.

func (*Provider) Complete

func (*Provider) CompleteStream

func (p *Provider) CompleteStream(_ context.Context, _ ai.CompletionRequest) (<-chan ai.StreamChunk, error)

func (*Provider) Models

func (p *Provider) Models() []ai.ModelInfo

func (*Provider) Name

func (p *Provider) Name() string

func (*Provider) SupportsToolUse

func (p *Provider) SupportsToolUse() bool

func (*Provider) ToolComplete

Jump to

Keyboard shortcuts

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