harmony

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FunctionNameMap

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

FunctionNameMap maps a user-specified function name to a valid function name for harmony (which look like TypeScript identifiers). This is needed to transform user-specified function names, which might contain characters that are not allowed in TypeScript identifiers

func NewFunctionNameMap

func NewFunctionNameMap() *FunctionNameMap

func (*FunctionNameMap) ConvertAndAdd

func (m *FunctionNameMap) ConvertAndAdd(userFunctionName string) string

func (*FunctionNameMap) OriginalFromConverted

func (m *FunctionNameMap) OriginalFromConverted(harmonyFunctionName string) string

OriginalFromConverted looks up the reverse-mapping of a previously-converted user->harmony function name. To unmap reliably, the mapping must exist, as the conversion process is not reversible without the appropriate state

type HarmonyEvent

type HarmonyEvent interface {
	// contains filtered or unexported methods
}

type HarmonyEventContentEmitted

type HarmonyEventContentEmitted struct {
	Content string
}

type HarmonyEventHeaderComplete

type HarmonyEventHeaderComplete struct {
	Header HarmonyHeader
}

type HarmonyEventMessageEnd

type HarmonyEventMessageEnd struct{}

type HarmonyEventMessageStart

type HarmonyEventMessageStart struct{}

type HarmonyHeader

type HarmonyHeader struct {
	Role      string
	Channel   string
	Recipient string
}

type HarmonyMessageHandler

type HarmonyMessageHandler struct {
	HarmonyParser   *HarmonyParser
	FunctionNameMap *FunctionNameMap
	// contains filtered or unexported fields
}

HarmonyMessageHandler processes harmony events and accumulates content appropriately. This is a higher level interface that maps harmony concepts into ollama concepts

func NewHarmonyMessageHandler

func NewHarmonyMessageHandler() *HarmonyMessageHandler

NewHarmonyMessageHandler creates a new message handler

func (*HarmonyMessageHandler) Add added in v0.12.1

func (h *HarmonyMessageHandler) Add(s string, done bool) (content string, thinking string, calls []api.ToolCall, err error)

Add implements the Parser interface - processes streamed content and extracts content, thinking, and tool calls

func (*HarmonyMessageHandler) AddContent

func (h *HarmonyMessageHandler) AddContent(content string, toolParser *HarmonyToolCallAccumulator) (string, string, string)

AddContent processes the content and returns the content, thinking, and tool content. content and thinking are already fully parsed, but tool content still needs to be passed to the tool parser

func (*HarmonyMessageHandler) CreateToolParser

func (h *HarmonyMessageHandler) CreateToolParser() *HarmonyToolCallAccumulator

func (*HarmonyMessageHandler) HasThinkingSupport added in v0.12.1

func (h *HarmonyMessageHandler) HasThinkingSupport() bool

HasThinkingSupport implements the Parser interface

func (*HarmonyMessageHandler) HasToolSupport added in v0.12.1

func (h *HarmonyMessageHandler) HasToolSupport() bool

HasToolSupport implements the Parser interface

func (*HarmonyMessageHandler) Init added in v0.12.1

func (h *HarmonyMessageHandler) Init(tools []api.Tool, lastMessage *api.Message, thinkValue *api.ThinkValue) []api.Tool

Init initializes the handler with tools, optional last message, and think value Implements the Parser interface

type HarmonyParser

type HarmonyParser struct {
	MessageStartTag string
	MessageEndTag   string
	HeaderEndTag    string
	// contains filtered or unexported fields
}

func (*HarmonyParser) AddContent

func (s *HarmonyParser) AddContent(content string) []HarmonyEvent

func (*HarmonyParser) AddImplicitStart

func (s *HarmonyParser) AddImplicitStart()

func (*HarmonyParser) AddImplicitStartOrPrefill

func (s *HarmonyParser) AddImplicitStartOrPrefill(lastMessage *api.Message)

type HarmonyToolCallAccumulator

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

func (*HarmonyToolCallAccumulator) Add

func (a *HarmonyToolCallAccumulator) Add(content string)

func (*HarmonyToolCallAccumulator) Content

func (a *HarmonyToolCallAccumulator) Content() string

func (*HarmonyToolCallAccumulator) Drain

func (a *HarmonyToolCallAccumulator) Drain() (*string, string)

func (*HarmonyToolCallAccumulator) SetToolName

func (a *HarmonyToolCallAccumulator) SetToolName(toolName string)

Jump to

Keyboard shortcuts

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