base

package
v1.214.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package base provides shared utilities for AI provider implementations.

Index

Constants

View Source
const DefaultRequestTimeout = 60 * time.Second

DefaultRequestTimeout is the default HTTP request timeout for AI provider API calls.

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 FormatMessagesAsPrompt added in v1.214.0

func FormatMessagesAsPrompt(messages []types.Message) string

FormatMessagesAsPrompt concatenates conversation messages into a single prompt string. User messages are included as-is; assistant messages are prefixed with "Assistant: ". Used by CLI providers that pass the entire conversation as a single text prompt.

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.

func ResolveToolchainPATH added in v1.214.0

func ResolveToolchainPATH(atmosConfig *schema.AtmosConfiguration) string

ResolveToolchainPATH extracts the toolchain bin PATH for MCP server subprocesses. Returns the PATH string from the toolchain environment, or empty if no toolchain is configured.

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