base

package
v1.209.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package base provides shared utilities for AI provider implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildToolParameterSchema

func BuildToolParameterSchema(toolParams []tools.Parameter) (properties map[string]interface{}, required []string)

BuildToolParameterSchema builds a JSON Schema from tool parameters. This is the common logic used by all providers for tool parameter conversion.

func GetProviderConfig

func GetProviderConfig(atmosConfig *schema.AtmosConfiguration, providerName string) *schema.AIProviderConfig

GetProviderConfig returns the provider-specific configuration from AtmosConfiguration. Returns nil if no provider configuration is found.

func PrependSystemMessages

func PrependSystemMessages(systemPrompt, atmosMemory string, messages []types.Message) []types.Message

PrependSystemMessages prepends system prompt and atmos memory to conversation history. This is the common pattern used by all providers in SendMessageWithSystemPromptAndTools.

Types

type Config

type Config struct {
	Enabled   bool
	Model     string
	APIKey    string //nolint:gosec // G117: not a hardcoded credential, populated from config
	MaxTokens int
	BaseURL   string
}

Config holds common configuration for AI clients.

func ExtractConfig

func ExtractConfig(atmosConfig *schema.AtmosConfiguration, providerName string, defaults ProviderDefaults) *Config

ExtractConfig extracts AI configuration from AtmosConfiguration for a specific provider. It applies the provider-specific defaults and overrides from the configuration.

type ProviderDefaults

type ProviderDefaults struct {
	Model         string
	DefaultAPIKey string
	MaxTokens     int
	BaseURL       string
}

ProviderDefaults contains default values for a provider.

type ToolInfo

type ToolInfo struct {
	Name        string
	Description string
	Properties  map[string]interface{}
	Required    []string
}

ToolInfo contains basic tool information extracted for conversion.

func ExtractAllToolInfo

func ExtractAllToolInfo(availableTools []tools.Tool) []ToolInfo

ExtractAllToolInfo extracts tool information from a slice of tools.

func ExtractToolInfo

func ExtractToolInfo(tool tools.Tool) ToolInfo

ExtractToolInfo extracts common tool information from a Tool interface. This provides a single point of extraction that all providers can use.

type ToolParameterSchema

type ToolParameterSchema struct {
	Type       string                        `json:"type"`
	Properties map[string]ToolPropertySchema `json:"properties"`
	Required   []string                      `json:"required"`
}

ToolParameterSchema represents the full JSON Schema for tool parameters.

type ToolPropertySchema

type ToolPropertySchema struct {
	Type        string `json:"type"`
	Description string `json:"description"`
}

ToolPropertySchema represents a JSON Schema property for a tool parameter.

Directories

Path Synopsis
Package openaicompat provides shared utilities for OpenAI-compatible API providers.
Package openaicompat provides shared utilities for OpenAI-compatible API providers.

Jump to

Keyboard shortcuts

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