mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-21 17:38:10 +00:00
- 所有内置插件 init() 自注册 (plugin.RegisterFactory), 移除 main.go 硬编码 - 新增 .so 动态加载器 (internal/plugin/dynamic.go), 插件可编译为 plugin.so - 新增 plugin.json 元数据 (internal/plugin/manifest.go) - 新增 interceptLoop 独立 goroutine: (a) cancelLLM() 取消进行中的 HTTP 请求 (b) interceptCh → drainInterrupt() 注入 [打断消息] 到 LLM 上下文 (c) InjectInput 空闲时触发新处理循环 - 新增 internal/plugins/all.go 空白导入触发所有内置插件 init() - internal/sdk/ 作为 PluginSDK 正式 Go API - internal/api/ → internal/plugins/webui/ 迁移 - 删除旧 cmd/cli/, 使用 cmd/waiter/ 替代 - 更新 PLAN.md / ARCHITECTURE.md / README.md 文档
43 lines
695 B
Go
43 lines
695 B
Go
package sdk
|
|
|
|
import agentAPI "gitcode.com/JianFeeeee/HomeAgent/internal/agent/api"
|
|
|
|
type LLMAPI interface {
|
|
ListSources() []string
|
|
SetSource(name string) error
|
|
CurrentSource() string
|
|
}
|
|
|
|
type llmImpl struct {
|
|
mgr *agentAPI.ProviderManager
|
|
}
|
|
|
|
func NewLLM(mgr *agentAPI.ProviderManager) LLMAPI {
|
|
return &llmImpl{mgr: mgr}
|
|
}
|
|
|
|
func (l *llmImpl) ListSources() []string {
|
|
if l.mgr == nil {
|
|
return nil
|
|
}
|
|
return l.mgr.List()
|
|
}
|
|
|
|
func (l *llmImpl) SetSource(name string) error {
|
|
if l.mgr == nil {
|
|
return nil
|
|
}
|
|
return l.mgr.SetDefault(name)
|
|
}
|
|
|
|
func (l *llmImpl) CurrentSource() string {
|
|
if l.mgr == nil {
|
|
return ""
|
|
}
|
|
p := l.mgr.Default()
|
|
if p == nil {
|
|
return ""
|
|
}
|
|
return p.Name()
|
|
}
|