Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ onBeforeUnmount(() => {
/>

<!-- 打开更多参数 -->
<el-button v-if="showMoreButton" ref="moreButtonRef" class="size-8! min-w-0! px-0!" @click="popoverVisible = !popoverVisible">
<MkIcon name="icon_setting" :size="16" />
<el-button plain v-if="showMoreButton" ref="moreButtonRef" class="w-8! min-w-8!" @click="popoverVisible = !popoverVisible">
<MkIcon name="icon_card_outlined" />
</el-button>

<el-popover
Expand All @@ -241,26 +241,27 @@ onBeforeUnmount(() => {
virtual-triggering
trigger="manual"
placement="top-start"
:width="400"
:popper-style="{ padding: '16px 8px' }"
:width="420"
@show="userForm.saveSnapshot"
>
<div class="mb-4 truncate break-all font-medium" :title="menuTitle">{{ menuTitle }}</div>
<el-scrollbar max-height="450px">
<MkDynamicsForm :key="`popover-${formRefreshKey}`" ref="popoverFormRef" v-model="formData" :render-data="popoverFields" />
<MkDynamicsForm
v-if="apiInputEditable"
:key="`api-${formRefreshKey}`"
ref="apiFormRef"
v-model="apiFormData"
:render-data="apiInputFields"
/>
</el-scrollbar>
<div class="mt-2 text-right">
<!-- 取消修改 -->
<el-button @click="cancelHandle">取消</el-button>
<!-- 确认参数 -->
<el-button type="primary" @click="confirmHandle">确认</el-button>
<div class="p-4">
<h4 class="mb-4 truncate break-all" :title="menuTitle">{{ menuTitle }}</h4>
<el-scrollbar max-height="360px" class="-mr-4" view-class="pr-4">
<MkDynamicsForm :key="`popover-${formRefreshKey}`" ref="popoverFormRef" v-model="formData" :render-data="popoverFields" />
<MkDynamicsForm
v-if="apiInputEditable"
:key="`api-${formRefreshKey}`"
ref="apiFormRef"
v-model="apiFormData"
:render-data="apiInputFields"
/>
</el-scrollbar>
<div class="mt-4">
<!-- 确认参数 -->
<el-button type="primary" @click="confirmHandle">确认</el-button>
<!-- 取消修改 -->
<el-button plain @click="cancelHandle">取消</el-button>
</div>
</div>
</el-popover>
</template>
Expand All @@ -271,7 +272,7 @@ onBeforeUnmount(() => {
/* 行内开关与下拉框同高同边框(主题将开关高度改为 22px),标签固定为常规文字色,不随开关状态高亮。 */
:deep(.mk-conversation-user-form__switch) {
box-sizing: border-box;
height: var(--el-component-size);
height: 32px;
justify-content: space-between;
padding: 0 12px;
border: 1px solid var(--el-border-color);
Expand All @@ -281,7 +282,7 @@ onBeforeUnmount(() => {
min-width: 0;
max-width: 56px;
margin-right: 8px;
color: var(--el-text-color-regular);
color: var(--mk-N900);

span {
display: block;
Expand Down
2 changes: 2 additions & 0 deletions ui/src/workflow-canvas/WORKFLOW_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ MkFormList 的排序、增删均以 `cloneDeep` 回写;MkTable 保留普通行

当前用于应用工作流及循环体,根据用户需求规划、创建节点、连线与配置字段。
页面通过 WorkflowCanvas.getLogicFlow() 提供画布,生成结果只改图,不自动保存。
模型选择支持参数设置,不提供添加模型入口;优先沿用默认 LLM 的参数,切换模型加载对应默认参数。
首轮生成时固定模型及参数,父 agent 和委派的子 agent 共用,并通过 `model_params_setting` 传入补全请求;新建会话后可重新配置。

| 位置 | 职责 |
| --------------- | -------------------------------------------------------- |
Expand Down
1 change: 1 addition & 0 deletions ui/src/workflow-canvas/ai-generate/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function useAgentConfig(config: AgentConfig, bindings: AgentBindings): Ru
messages,
tools: config.tools,
modelId: bindings.modelId,
modelParams: bindings.modelParams,
resourceScope: bindings.resourceScope,
call: bindings.call,
position: bindings.position ?? [],
Expand Down
7 changes: 4 additions & 3 deletions ui/src/workflow-canvas/ai-generate/create-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function toExecutor(value: unknown): Executor {
* 某工具返回 AgentSuccessResult / AgentErrorResult 结束、被停止或超过轮次。工具返回 ErrorResult 或抛错时把错误回喂模型自愈。
*/
export function createAgent(agent: RunnableAgent): AgentHandle {
const { tools, modelId, resourceScope, call, position, maxIterations } = agent
const { tools, modelId, modelParams, resourceScope, call, position, maxIterations } = agent
const controller = new AbortController()
const stopCallbacks: Array<() => void> = []
const messages: AgentMessage[] = agent.messages
Expand Down Expand Up @@ -72,7 +72,7 @@ export function createAgent(agent: RunnableAgent): AgentHandle {
if (controller.signal.aborted) return finish({ status: 'stopped' })
if (iteration > maxIterations) return finish({ status: 'error', data: `超过最大轮次 ${maxIterations}` })

const response = await runTurn(resourceScope, modelId, messages, tools, emit, controller.signal)
const response = await runTurn(resourceScope, modelId, modelParams, messages, tools, emit, controller.signal)
const toolCalls = response.toolCalls ?? []
const assistantMessage: AgentMessage = { role: 'assistant', content: response.content || '' }
// thinking 模型要求思考内容按原字段名回传,否则下一轮请求会被拒绝
Expand Down Expand Up @@ -124,6 +124,7 @@ export function createAgent(agent: RunnableAgent): AgentHandle {
function runTurn(
resourceScope: string,
modelId: string,
modelParams: Record<string, unknown> | undefined,
messages: AgentMessage[],
tools: AgentTool[],
emit: (payload: AgentPayload) => void,
Expand Down Expand Up @@ -154,7 +155,7 @@ function runTurn(
else reject(new Error('本轮结束但未收到完整结果'))
},
}
chatCompletion(resourceScope, modelId, { messages, tools: toToolSchemas(tools) }, sink, signal)
chatCompletion(resourceScope, modelId, { messages, tools: toToolSchemas(tools), model_params_setting: modelParams }, sink, signal)
})
}

Expand Down
7 changes: 7 additions & 0 deletions ui/src/workflow-canvas/ai-generate/panel/AiGeneratePanel.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { computed, inject, nextTick, onBeforeUnmount, ref, useTemplateRef } from 'vue'
import { useRoute } from 'vue-router'
import { cloneDeep } from 'lodash'
import type LogicFlow from '@logicflow/core'
import type { ScrollbarInstance } from 'element-plus'
import type { DefaultModelSettingPayload, ModelItem, ModelProviderItem } from '@/api/types'
Expand Down Expand Up @@ -38,6 +39,7 @@ const visible = ref(false)
const status = ref<GenerateStatus>('idle')
const requirement = ref('')
const modelId = ref('')
const modelParams = ref<Record<string, unknown>>({})
const modelOptions = ref<ModelItem[]>([])
const providerOptions = ref<ModelProviderItem[]>([])
const scrollbarRef = useTemplateRef<ScrollbarInstance>('scrollbarRef')
Expand All @@ -55,6 +57,7 @@ function loadModels() {
if (!modelId.value) {
const defaultModelId = props.defaultModelSettings?.LLM?.model_id
modelId.value = models.find((model) => model.id === defaultModelId)?.id ?? models[0]?.id ?? ''
modelParams.value = modelId.value === defaultModelId ? cloneDeep(props.defaultModelSettings?.LLM?.model_params_setting ?? {}) : {}
}
})
.catch(() => MsgError('获取模型列表失败'))
Expand Down Expand Up @@ -89,6 +92,7 @@ async function run(text: string) {
useApplicationAgent({
rootLf: lf,
modelId: modelId.value,
modelParams: cloneDeep(modelParams.value),
call: { onNext: onEvent },
workflowMode: props.workflowMode,
resourceScope,
Expand Down Expand Up @@ -200,6 +204,9 @@ defineExpose({ open, close })
<SelectModel
class="w-50!"
v-model="modelId"
v-model:model-params="modelParams"
can-edit-params
:can-add="false"
:options="modelOptions"
:provider-options="providerOptions"
:disabled="started"
Expand Down
4 changes: 4 additions & 0 deletions ui/src/workflow-canvas/ai-generate/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export interface AgentBindings {
rootLf: LogicFlow
/** 模型 id(委派的子 agent 复用同一模型) */
modelId: string
/** 生成及委派补全共用的模型参数 */
modelParams?: Record<string, unknown>
/** 对外事件出口 */
call: Call<AgentEvent>
/** 主画布模式 */
Expand Down Expand Up @@ -134,6 +136,8 @@ export interface RunnableAgent {
messages: AgentMessage[]
tools: AgentTool[]
modelId: string
/** 生成及委派补全共用的模型参数 */
modelParams?: Record<string, unknown>
/** 画布资源范围,补全请求经 useWorkflowStore(resourceScope) 发起 */
resourceScope: string
call: Call<AgentEvent>
Expand Down
Loading