Documentation
¶
Index ¶
- Variables
- func Completion(prompt string) (string, error)
- func CompletionByParams(args ...AllowedParam) (openai.ChatCompletionMessage, error)
- func CompletionBySystem(prompt string) (string, error)
- func Embedding(text string) ([]float32, error)
- func EmbeddingWithDim(text string, dimensions int) ([]float32, error)
- func Vision(img image.Image) (string, error)
- func VisionWithPrompt(img image.Image, prompt string) (string, error)
- type AllowedParam
- type Config
- type LLMClient
- type MessageFunc
- type ToolFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrUnexpectedResponse = errors.New("llm: unexpected API response")
)
Functions ¶
func Completion ¶
Completion generates text from a text prompt.
func CompletionByParams ¶
func CompletionByParams(args ...AllowedParam) (openai.ChatCompletionMessage, error)
func CompletionBySystem ¶
Completion generates text from a text prompt.
func EmbeddingWithDim ¶
EmbeddingWithDim returns embedding vector with specified dimension.
Types ¶
type AllowedParam ¶
type AllowedParam interface {
Allowed()
}
type Config ¶
type Config struct {
APIKey string
BaseURL string // 支持兼容 API(如 Ollama)
Model string // 默认文本模型
VisionModel string // 默认视觉模型
EmbedModel string // 默认 embedding 模型
EmbedDim int
Temperature float64
TopP float64
}
func LoadConfig ¶
type MessageFunc ¶
type MessageFunc func() openai.ChatCompletionMessageParamUnion
func SystemMessage ¶
func SystemMessage(prompt string) MessageFunc
func ToolMessage ¶
func ToolMessage(prompt string, toolCallID string) MessageFunc
func UserMessage ¶
func UserMessage(prompt string) MessageFunc
func (MessageFunc) Allowed ¶
func (MessageFunc) Allowed()
Click to show internal directories.
Click to hide internal directories.