- plugins: calculator, datetime, crypto, random, text, json, markdown - plugins: web-search (SearXNG stub), web-fetch, file, http (stubs) - main.go: full wiring — config→db→nats→plugins→voice→memory→ persona→llm→context→subsession→orchestrator→gateway→ws - 15 packages passing, 11 plugins loaded at startup
26 lines
1.2 KiB
Go
26 lines
1.2 KiB
Go
package text
|
|
import (
|
|
"context"; "fmt"; "strings"; "unicode/utf8"
|
|
"git.yeij.top/AskaEth/Cyrene_v2/internal/plugin"
|
|
)
|
|
type Plugin struct{}
|
|
func New() *Plugin { return &Plugin{} }
|
|
func (p *Plugin) Name() string { return "text" }
|
|
func (p *Plugin) Version() string { return "1.0.0" }
|
|
func (p *Plugin) Description() string { return "文本处理" }
|
|
func (p *Plugin) Init(_ context.Context, _ plugin.PluginConfig) error { return nil }
|
|
func (p *Plugin) Close() error { return nil }
|
|
func (p *Plugin) Enabled() bool { return true }
|
|
func (p *Plugin) Tools() []plugin.ToolDefinition {
|
|
return []plugin.ToolDefinition{{Name:"text", Description:"统计/翻转/大小写", Parameters:map[string]any{"text": map[string]string{"type":"string"},"action":map[string]string{"type":"string"}}}}
|
|
}
|
|
func (p *Plugin) Execute(_ context.Context, _ string, params map[string]any) (string, error) {
|
|
t,_ := params["text"].(string)
|
|
switch params["action"].(string) {
|
|
case "count": return fmt.Sprintf("%d chars, %d words", utf8.RuneCountInString(t), len(strings.Fields(t))), nil
|
|
case "upper": return strings.ToUpper(t), nil
|
|
case "lower": return strings.ToLower(t), nil
|
|
default: return t, nil
|
|
}
|
|
}
|