llm

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

LLM facilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeMarkdownLatex added in v0.4.9

func EscapeMarkdownLatex(markdown string) string

func MustTagExtractor

func MustTagExtractor(tag string) tagContentExtractor

Extract content in <tag>...</tag>.

func ParseLLMJsonAs added in v0.4.3

func ParseLLMJsonAs[T any](s string) (T, error)

func ParseThink added in v0.4.2

func ParseThink(m string) (thought string, answer string)

Parse </think> tag.

thought contains anything before the </think> tag, including the </think> tag itself.

answer contains anything after the </think> tag.

func PrettifyMarkdownDoc added in v0.4.9

func PrettifyMarkdownDoc(markdown string) string

func TagExtractor

func TagExtractor(tag string) (tagContentExtractor, error)

Extract content in <tag>${content}</tag>.

The content between the tags must not include xml closing tags, e.g., </xxx>.

func ToCsvTxt added in v0.4.7

func ToCsvTxt(srcPath string, separator ...string) (string, error)

Rewrite CSV content in text. Filter blank columns and rows. Make the content more readable.

Types

type MsgDelta

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

func NewMsgDelta

func NewMsgDelta() *MsgDelta

func (*MsgDelta) Complete

func (m *MsgDelta) Complete() string

func (*MsgDelta) Delta

func (m *MsgDelta) Delta(s string) string

type SSEAction added in v0.4.11

type SSEAction struct {
	Name  string
	Param string
}

func (SSEAction) UnmarshalParam added in v0.4.11

func (s SSEAction) UnmarshalParam(p any) error

type SSEPiper added in v0.4.11

type SSEPiper[D any] struct {
	// contains filtered or unexported fields
}

func NewSSEPiper added in v0.4.11

func NewSSEPiper[D any]() *SSEPiper[D]

func (*SSEPiper[D]) Listen added in v0.4.11

func (s *SSEPiper[D]) Listen() func(e sse.Event) (stop bool, err error)

func (*SSEPiper[D]) OnAction added in v0.4.11

func (s *SSEPiper[D]) OnAction(f func(s SSEAction) error)

func (*SSEPiper[D]) OnData added in v0.4.11

func (s *SSEPiper[D]) OnData(f func(d D) error)

func (*SSEPiper[D]) OnMessage added in v0.4.11

func (s *SSEPiper[D]) OnMessage(f func(delta string, accumulated string) error)

func (*SSEPiper[D]) PushAction added in v0.4.11

func (s *SSEPiper[D]) PushAction(inb interface {
	WriteSSE(name string, message any)
}, m SSEAction)

func (*SSEPiper[D]) PushData added in v0.4.11

func (s *SSEPiper[D]) PushData(inb interface {
	WriteSSE(name string, message any)
}, m D)

func (*SSEPiper[D]) PushMsg added in v0.4.11

func (s *SSEPiper[D]) PushMsg(inb interface {
	WriteSSE(name string, message any)
}, m string)

Jump to

Keyboard shortcuts

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