-
Notifications
You must be signed in to change notification settings - Fork 7.3k
feat(workflow): allow more nodes in tool call #7496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Nixieboluo
wants to merge
12
commits into
labring:main
Choose a base branch
from
Nixieboluo:feat/node-deprecation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,028
−204
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5f19654
refactor(workflow): deprecate queryExtension node
Nixieboluo 4167a6d
refactor(workflow): deprecate custom vars in http node
Nixieboluo 36972be
feat(workflow): show nodes depends on the context
Nixieboluo 56dab35
feat(workflow): disallow connections to nodes not allowed in the context
Nixieboluo 822397e
fix(workflow): tool call params for http/sandbox node
Nixieboluo a008571
feat(workflow): allow more nodes as tools
Nixieboluo 1ab6021
Merge branch 'main' into feat/node-deprecation
Nixieboluo 2960c2a
fix: schema type
Nixieboluo 1bc96c7
docs(workflow): queryExtension deprecation note
Nixieboluo ac63bd9
feat(workflow): sidebar node panel filtering
Nixieboluo bcb39eb
refactor(workflow): control tool param precisely
Nixieboluo 3e788ad
test(workflow): update tool input expectations
Nixieboluo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ title: 问题优化 | |
| description: 问题优化模块介绍和使用 | ||
| --- | ||
|
|
||
| > **已弃用**:问题优化节点已停止新增。已存在于画布中的节点仍可继续运行。 | ||
|
|
||
| ## 特点 | ||
|
|
||
| - 可重复添加 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import type { FlowNodeTypeEnum } from '../node/constant'; | ||
| import { NodeOutputKeyEnum } from '../constants'; | ||
| import type { | ||
| FlowNodeTemplateType, | ||
| FlowNodeItemType, | ||
| NodeTemplateContext, | ||
| NodeTemplateContextPredicate | ||
| } from '../type/node'; | ||
|
|
||
| /** | ||
| * 模板展示上下文规则:规则字段全部为空时匹配任何上下文。 | ||
| */ | ||
| export type NodeTemplateContextRule = { | ||
| sourceType?: FlowNodeTypeEnum; | ||
| handleId?: string; | ||
| parentType?: FlowNodeTypeEnum; | ||
| }; | ||
|
|
||
| const matchRule = (rule: NodeTemplateContextRule, ctx: NodeTemplateContext): boolean => { | ||
| if (rule.sourceType !== undefined && rule.sourceType !== ctx.sourceType) return false; | ||
| if (rule.handleId !== undefined && rule.handleId !== ctx.handleId) return false; | ||
| if (rule.parentType !== undefined && rule.parentType !== ctx.parentType) return false; | ||
| return true; | ||
| }; | ||
|
|
||
| /** | ||
| * 白名单工厂:上下文存在且匹配任一规则时展示。 | ||
| */ | ||
| export const createShowInContext = ( | ||
| rules: NodeTemplateContextRule[] | ||
| ): NodeTemplateContextPredicate => { | ||
| return (ctx) => !!ctx && rules.some((rule) => matchRule(rule, ctx)); | ||
| }; | ||
|
|
||
| /** | ||
| * 黑名单工厂:匹配任一规则时隐藏;无上下文时展示。 | ||
| */ | ||
| export const createHideInContext = ( | ||
| rules: NodeTemplateContextRule[] | ||
| ): NodeTemplateContextPredicate => { | ||
| return (ctx) => !ctx || !rules.some((rule) => matchRule(rule, ctx)); | ||
| }; | ||
|
|
||
| /** | ||
| * 模板在给定上下文中是否可见:未声明谓词的模板为顶级节点,处处可见。 | ||
| */ | ||
| export const isTemplateVisible = ( | ||
| template: Pick<FlowNodeTemplateType, 'isShowInContext'>, | ||
| ctx: NodeTemplateContext | null | ||
| ): boolean => { | ||
| return !template.isShowInContext || template.isShowInContext(ctx); | ||
| }; | ||
|
|
||
| /** | ||
| * 由源节点信息构建快捷添加/连线共用的展示上下文;sourceNode 不存在时返回 null。 | ||
| */ | ||
| export const buildNodeTemplateContext = ({ | ||
| sourceNode, | ||
| edges, | ||
| handleId, | ||
| getNodeById, | ||
| isSidebar = false, | ||
| hasToolNode = false, | ||
| hasLoopRunNode = false | ||
| }: { | ||
| sourceNode: | ||
| | Pick<FlowNodeItemType, 'nodeId' | 'flowNodeType' | 'isTool' | 'parentNodeId'> | ||
| | undefined; | ||
| edges: { target: string; targetHandle?: string | null }[]; | ||
| handleId?: string | null; | ||
| getNodeById: (nodeId: string | undefined | null) => FlowNodeItemType | undefined; | ||
| isSidebar?: boolean; | ||
| hasToolNode?: boolean; | ||
| hasLoopRunNode?: boolean; | ||
| }): NodeTemplateContext | null => { | ||
| if (!sourceNode && !isSidebar) return null; | ||
| const parentNode = sourceNode?.parentNodeId ? getNodeById(sourceNode.parentNodeId) : undefined; | ||
| return { | ||
| isSidebar, | ||
| sourceNodeId: sourceNode?.nodeId ?? null, | ||
| sourceType: sourceNode?.flowNodeType ?? null, | ||
| sourceIsTool: !!sourceNode?.isTool, | ||
| isConnectedTool: edges.some( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里的 |
||
| (edge) => | ||
| edge.target === sourceNode?.nodeId && edge.targetHandle === NodeOutputKeyEnum.selectedTools | ||
| ), | ||
| handleId: handleId ?? null, | ||
| parentType: parentNode?.flowNodeType ?? null, | ||
| hasToolNode, | ||
| hasLoopRunNode | ||
| }; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的
input.canEdit !== true会把本 PR 新增的 HTTP/Code 工具参数排除出模型 Schema。EditFieldModal创建的工具参数是{ canEdit: true, isToolParam: true },旧 HTTP 字段迁移为工具参数后也仍保留canEdit: true。按当前约定,旧自定义输入可以继续保留,但只有isToolParam的那部分传给 AI,因此canEdit不应作为禁止 AI 生成的条件;否则这些参数既不进入模型参数,通常也没有固定value可注入。建议以isToolParam && canInputBeAgentGenerated判定,并补测“未标工具参数的旧自定义输入不进入 Schema、已标工具参数的输入进入 Schema”。