ai

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderOpenRouter = "OpenRouter.ai"
	ProviderOpenAI     = "OpenAI"
	ProviderCustom     = "Custom (e.g. Local)"
)

Variables

Functions

func EndpointForProvider

func EndpointForProvider(provider string, customURL string) (string, error)

Types

type Client

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

func NewClient

func NewClient(httpClient *http.Client) *Client

func (*Client) ListModels

func (c *Client) ListModels(config ProviderConfig) ([]string, error)

func (*Client) RunPrompt

func (c *Client) RunPrompt(config ProviderConfig, prompt Prompt) (string, error)

type Message

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

type Model

type Model struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Pricing *struct {
		Prompt     any `json:"prompt"`
		Completion any `json:"completion"`
	} `json:"pricing,omitempty"`
	ContextLength    int `json:"context_length"`
	PerRequestLimits *struct {
		PromptTokens     any `json:"prompt_tokens"`
		CompletionTokens any `json:"completion_tokens"`
	} `json:"per_request_limits"`
}

type ModelsList

type ModelsList struct {
	Data []Model `json:"data"`
}

type Prompt

type Prompt struct {
	Model     string
	MaxTokens int
	System    string
	User      string
}

type PromptRequest

type PromptRequest struct {
	Model     string    `json:"model"`
	MaxTokens int       `json:"max_tokens"`
	Messages  []Message `json:"messages"`
}

type PromptResponse

type PromptResponse struct {
	ID      string `json:"id"`
	Model   string `json:"model"`
	Choices []struct {
		Message Message `json:"message"`
	} `json:"choices"`
}

type ProviderConfig

type ProviderConfig struct {
	Provider string
	Endpoint string
	APIKey   string
}

Jump to

Keyboard shortcuts

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