oaistream

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertMessages added in v1.8.2

func ConvertMessages(messages []chat.Message) []openai.ChatCompletionMessageParamUnion

ConvertMessages converts chat.Message slices to OpenAI message params. This is the base conversion without any provider-specific post-processing.

func ConvertMultiContent added in v1.8.2

func ConvertMultiContent(multiContent []chat.MessagePart) []openai.ChatCompletionContentPartUnionParam

ConvertMultiContent converts chat.MessagePart slices to OpenAI content parts.

func MergeConsecutiveMessages added in v1.8.2

func MergeConsecutiveMessages(openaiMessages []openai.ChatCompletionMessageParamUnion) []openai.ChatCompletionMessageParamUnion

MergeConsecutiveMessages merges consecutive system or user messages into single messages. This is needed by some local models (like those run by DMR) that don't handle consecutive same-role messages well.

Types

type JSONSchema added in v1.8.2

type JSONSchema map[string]any

JSONSchema is a helper type that implements json.Marshaler for map[string]any. This allows us to pass schema maps to the OpenAI library which expects json.Marshaler.

func (JSONSchema) MarshalJSON added in v1.8.2

func (j JSONSchema) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for JSONSchema.

type StreamAdapter

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

StreamAdapter adapts the OpenAI stream to our interface

func NewStreamAdapter

func NewStreamAdapter(stream *ssestream.Stream[openai.ChatCompletionChunk], trackUsage bool) *StreamAdapter

func (*StreamAdapter) Close

func (a *StreamAdapter) Close()

Close closes the stream

func (*StreamAdapter) Recv

Recv gets the next completion chunk

Jump to

Keyboard shortcuts

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