feat(studio): 完善编排 —— 检索接本人知识库 + 真实模型下拉 + 模板/示例
把编排从"演示桩"接到真实平台:检索节点查本人 owner 隔离的知识库,节点下拉用真实数据。 - dispatcher:makeToolNode 用 task user_id 给检索类工具的 kb 加 owner 前缀("uid/kb"), 编排里的「检索(RAG)」节点真正命中本人知识库(与隔离对齐)。 - 前端 StudioView:加 identity,载入 /kb/list 与 chat 模型作为「检索.kb」「Agent.model」下拉真值; Inspector 支持 dynamicOptions(无真值时提示去创建)。 - 编辑体验:示例(一键加载 输入→检索→Agent→输出 可运行图)/ 清空 / 模板名+保存(localStorage, 含布局)/ 载入下拉;ReactFlow deleteKeyCode 支持 Del/Backspace 删节点。 验证:示例图运行 → gateway 发布任务 → dispatcher 编译 → mcp-go 日志 `tool=wiki_search args=[kb:wt/default ...]`(kb 已按 owner 作用域)→ 命中本人库 → DeepSeek 流式作答; 底部抽屉 完成 ✓ · 工具调用 1。tsc+vite+dispatcher build 通过;重建 .app。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -69,7 +69,8 @@ func (o *Orchestrator) compileFlow(ctx context.Context, t *contract.Task, tr *ex
|
||||
}
|
||||
key := fmt.Sprintf("tool_%d", idx)
|
||||
idx++
|
||||
if err := g.AddLambdaNode(key, compose.InvokableLambda(o.makeToolNode(t.ID, tool, args, tr))); err != nil {
|
||||
uid, _ := t.Meta[contract.MetaUserID].(string)
|
||||
if err := g.AddLambdaNode(key, compose.InvokableLambda(o.makeToolNode(t.ID, tool, args, tr, uid))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := g.AddEdge(prev, key); err != nil {
|
||||
@@ -111,7 +112,8 @@ func (o *Orchestrator) compileFlow(ctx context.Context, t *contract.Task, tr *ex
|
||||
}
|
||||
|
||||
// makeToolNode 返回一个真实调用 MCP 工具的图节点:把结果增补进黑板,失败降级不阻断。
|
||||
func (o *Orchestrator) makeToolNode(taskID, tool string, args map[string]any, tr *execTracer) func(context.Context, *RunCtx) (*RunCtx, error) {
|
||||
// uid 非空时把检索类工具的 kb 锁进 owner 作用域("uid/kb"),使编排检索命中本人知识库。
|
||||
func (o *Orchestrator) makeToolNode(taskID, tool string, args map[string]any, tr *execTracer, uid string) func(context.Context, *RunCtx) (*RunCtx, error) {
|
||||
node := "tool:" + tool
|
||||
return func(ctx context.Context, rc *RunCtx) (*RunCtx, error) {
|
||||
if o.tools == nil {
|
||||
@@ -126,6 +128,12 @@ func (o *Orchestrator) makeToolNode(taskID, tool string, args map[string]any, tr
|
||||
if call["q"] == nil && call["query"] == nil {
|
||||
call["q"] = rc.Query
|
||||
}
|
||||
// 检索类工具的 kb 按 owner 作用域,对齐知识库隔离(前端只发库名)。
|
||||
if uid != "" {
|
||||
if kbv, ok := call["kb"].(string); ok && kbv != "" && !strings.Contains(kbv, "/") {
|
||||
call["kb"] = uid + "/" + kbv
|
||||
}
|
||||
}
|
||||
end := tr.span(node, "tool", "调用工具 "+tool)
|
||||
cctx, cancel := context.WithTimeout(ctx, toolCallTimeout)
|
||||
defer cancel()
|
||||
|
||||
Reference in New Issue
Block a user