providerformat

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package providerformat converts LiveKit chat contexts into the wire-neutral request shapes consumed by OpenAI-compatible, Google Gemini, and Mistral APIs. It mirrors the provider_format namespace in agents-js while keeping provider client dependencies out of the core SDK.

The returned values contain only maps, slices, strings, booleans, and numbers, so callers can marshal them with encoding/json or pass them to a provider SDK without another LiveKit-specific dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertMidConversationInstructions

func ConvertMidConversationInstructions(chat *llm.ChatContext, options ...InstructionConversionOptions) *llm.ChatContext

ConvertMidConversationInstructions converts every system/developer message after the first such message into a normal message. This is required by providers that accept system instructions only at the beginning.

func OpenAIChatContext

func OpenAIChatContext(chat *llm.ChatContext, injectDummyUserMessage bool) ([]map[string]any, error)

OpenAIChatContext converts a ChatContext to OpenAI Chat Completions message objects. injectDummyUserMessage is retained for API parity; OpenAI does not require a synthetic trailing user turn.

func OpenAIResponsesChatContext

func OpenAIResponsesChatContext(chat *llm.ChatContext, injectDummyUserMessage bool) ([]map[string]any, error)

OpenAIResponsesChatContext converts a ChatContext to OpenAI Responses API input objects.

func ToOpenAIChatContext

func ToOpenAIChatContext(chat *llm.ChatContext, injectDummyUserMessage bool) ([]map[string]any, error)

ToOpenAIChatContext is a compatibility alias for OpenAIChatContext.

func ToOpenAIResponsesChatContext

func ToOpenAIResponsesChatContext(chat *llm.ChatContext, injectDummyUserMessage bool) ([]map[string]any, error)

ToOpenAIResponsesChatContext is a compatibility alias.

Types

type ChatItemGroup

type ChatItemGroup struct {
	Message     *llm.ChatMessage
	ToolCalls   []*llm.FunctionCall
	ToolOutputs []*llm.FunctionCallOutput
}

ChatItemGroup is one coherent provider turn. An assistant message may share a group with parallel function calls and their corresponding outputs.

func GroupToolCalls

func GroupToolCalls(chat *llm.ChatContext) ([]ChatItemGroup, error)

GroupToolCalls groups assistant messages, parallel function calls, and matching outputs using GroupID (or the ID prefix before '/'). Unpaired calls and outputs are omitted, matching agents-js provider behavior.

func (ChatItemGroup) Empty

func (g ChatItemGroup) Empty() bool

Empty reports whether the group contains no provider-visible item.

func (ChatItemGroup) Flatten

func (g ChatItemGroup) Flatten() []llm.ChatItem

Flatten returns the group's provider-visible items in upstream order.

type GoogleFormatData

type GoogleFormatData struct {
	SystemMessages []string `json:"systemMessages"`
}

GoogleFormatData carries system instructions that Gemini accepts separately from conversation turns.

func GoogleChatContext

func GoogleChatContext(chat *llm.ChatContext, injectDummyUserMessage bool) ([]map[string]any, GoogleFormatData, error)

GoogleChatContext converts a ChatContext to Gemini turns and separately returned system messages.

func ToGoogleChatContext

func ToGoogleChatContext(chat *llm.ChatContext, injectDummyUserMessage bool) ([]map[string]any, GoogleFormatData, error)

ToGoogleChatContext is a compatibility alias for GoogleChatContext.

type InstructionConversionOptions

type InstructionConversionOptions struct {
	Role     llm.ChatRole
	Template string
}

InstructionConversionOptions controls conversion of system/developer messages that appear after the conversation's initial instructions.

type MistralFormatData

type MistralFormatData struct {
	Instructions string `json:"instructions"`
}

MistralFormatData carries Mistral Conversations API instructions.

func MistralChatContext

func MistralChatContext(chat *llm.ChatContext, injectDummyUserMessage bool) ([]map[string]any, MistralFormatData, error)

MistralChatContext converts a ChatContext into Mistral Conversations API entries and separately returned instructions.

func ToMistralChatContext

func ToMistralChatContext(chat *llm.ChatContext, injectDummyUserMessage bool) ([]map[string]any, MistralFormatData, error)

ToMistralChatContext is a compatibility alias for MistralChatContext.

Jump to

Keyboard shortcuts

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