toolobj

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package toolobj 提供工具调用结果对象的封装与序列化

该包定义工具执行结果的数据结构及其 JSON 编解码

Index

Constants

This section is empty.

Variables

View Source
var Scopes map[string]string = make(map[string]string)

Scopes 工具命名空间

View Source
var ScopesMu sync.RWMutex

ScopesMu 保护 Scopes 的并发读写

View Source
var ToolsList map[string]*Tools = make(map[string]*Tools)

ToolsList 工具列表

View Source
var ToolsMu sync.RWMutex

ToolsMu 保护 ToolsList 的并发读写

Functions

func AppendToolHook added in v0.2.2

func AppendToolHook(name string, hook Hook) bool

AppendToolHook 线程安全为工具追加钩子

func GetScope added in v0.2.2

func GetScope(name string) (string, bool)

GetScope 线程安全读取 Scope

func SetScope added in v0.2.2

func SetScope(name, prompt string)

SetScope 线程安全设置 Scope

func SetTool added in v0.2.2

func SetTool(tool *Tools)

SetTool 线程安全注册工具

Types

type Hook

type Hook struct {
	Scope      string
	Parameters *map[string]parser.ToolParameters
	// 注入提示词
	PreHook PreHookFunction
	// UI 渲染(bool:是否传递)
	OnHook OnHookFunction
	// 执行操作(bool:是否传递)
	PostHook PostHookFunction
}

Hook 钩子对象

func GetToolHooks added in v0.2.2

func GetToolHooks(name string) []Hook

GetToolHooks 线程安全获取工具的钩子列表(返回副本以避免竞态)

type OnHookFunction

type OnHookFunction struct {
	Func     func(*structs.Chats, map[string]*any, []*any, string) (bool, []*any, error)
	Priority int32
}

OnHookFunction 钩子函数

type PostHookFunction

type PostHookFunction struct {
	Func     func(*structs.Chats, map[string]*any, []*any) (bool, []*any, map[string]*any, error)
	Priority int32
}

PostHookFunction 钩子函数

type PreHookFunction

type PreHookFunction struct {
	Func     func(*structs.Chats) (string, error)
	Priority int32
}

PreHookFunction 钩子函数

type Tools

type Tools struct {
	Scope           string
	Name            string
	ID              string
	UserDescription string
	Parameters      map[string]parser.ToolParameters
	Hooks           []Hook
	Enable          func(session *structs.Chats) bool
}

Tools 工具调用

func GetTool added in v0.2.2

func GetTool(name string) *Tools

GetTool 线程安全读取工具

Jump to

Keyboard shortcuts

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