Documentation
¶
Index ¶
- type FunctionNameMap
- type HarmonyEvent
- type HarmonyEventContentEmitted
- type HarmonyEventHeaderComplete
- type HarmonyEventMessageEnd
- type HarmonyEventMessageStart
- type HarmonyHeader
- type HarmonyMessageHandler
- func (h *HarmonyMessageHandler) Add(s string, done bool) (content string, thinking string, calls []api.ToolCall, err error)
- func (h *HarmonyMessageHandler) AddContent(content string, toolParser *HarmonyToolCallAccumulator) (string, string, string)
- func (h *HarmonyMessageHandler) CreateToolParser() *HarmonyToolCallAccumulator
- func (h *HarmonyMessageHandler) HasThinkingSupport() bool
- func (h *HarmonyMessageHandler) HasToolSupport() bool
- func (h *HarmonyMessageHandler) Init(tools []api.Tool, lastMessage *api.Message) []api.Tool
- type HarmonyParser
- type HarmonyToolCallAccumulator
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 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 llama.go concepts
func NewHarmonyMessageHandler ¶
func NewHarmonyMessageHandler() *HarmonyMessageHandler
NewHarmonyMessageHandler creates a new message handler
func (*HarmonyMessageHandler) Add ¶
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 ¶
func (h *HarmonyMessageHandler) HasThinkingSupport() bool
HasThinkingSupport implements the Parser interface
func (*HarmonyMessageHandler) HasToolSupport ¶
func (h *HarmonyMessageHandler) HasToolSupport() bool
HasToolSupport 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)