openai

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package openai provides OpenAI-based LLM (and optionally STT/TTS) for Voxray.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service implements services.LLMService and optionally services.LLMServiceWithTools.

func NewService

func NewService(apiKey, model string) *Service

NewService creates an OpenAI LLM service. API key is read from config.GetEnv("OPENAI_API_KEY", "").

func (*Service) Chat

func (s *Service) Chat(ctx context.Context, messages []map[string]any, onToken func(*frames.LLMTextFrame)) error

Chat runs a completion and calls onToken for each streamed content delta (as LLMTextFrame). When tools are registered, tool_calls in the stream are executed and Chat is invoked again with the tool results.

func (*Service) RegisterTool

func (s *Service) RegisterTool(schema schemas.FunctionSchema, handler llmapi.ToolHandler)

RegisterTool implements llmapi.LLMServiceWithTools.

func (*Service) ToolsSchema

func (s *Service) ToolsSchema() *schemas.ToolsSchema

ToolsSchema implements llmapi.LLMServiceWithTools.

Jump to

Keyboard shortcuts

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