mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 20:14:36 +00:00
perf: make runner detailed config form dynamicly hideaway
This commit is contained in:
@@ -8,7 +8,7 @@ import LLMCard from '@/app/home/models/component/llm-card/LLMCard';
|
||||
import LLMForm from '@/app/home/models/component/llm-form/LLMForm';
|
||||
import CreateCardComponent from '@/app/infra/basic-component/create-card-component/CreateCardComponent';
|
||||
import { httpClient } from '@/app/infra/http/HttpClient';
|
||||
import { LLMModel } from '@/app/infra/api/api-types';
|
||||
import { LLMModel } from '@/app/infra/entities/api';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
|
||||
@@ -209,6 +209,40 @@ export default function PipelineFormComponent({
|
||||
}
|
||||
|
||||
function renderDynamicForms(stage: PipelineConfigStage, formName: keyof FormValues) {
|
||||
// 如果是 AI 配置,需要特殊处理
|
||||
if (formName === 'ai') {
|
||||
// 获取当前选择的 runner
|
||||
const currentRunner = form.watch('ai.runner.runner');
|
||||
|
||||
// 如果是 runner 配置项,直接渲染
|
||||
if (stage.name === 'runner') {
|
||||
return (
|
||||
<div key={stage.name} className="space-y-4 mb-6">
|
||||
<div className="text-lg font-medium">{stage.label.zh_CN}</div>
|
||||
{stage.description && (
|
||||
<div className="text-sm text-gray-500">{stage.description.zh_CN}</div>
|
||||
)}
|
||||
<DynamicFormComponent
|
||||
itemConfigList={stage.config}
|
||||
initialValues={(form.watch(formName) as Record<string, any>)?.[stage.name] || {}}
|
||||
onSubmit={(values) => {
|
||||
const currentValues = form.getValues(formName) as Record<string, any> || {};
|
||||
form.setValue(formName, {
|
||||
...currentValues,
|
||||
[stage.name]: values,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 如果不是当前选择的 runner 对应的配置项,则不渲染
|
||||
if (stage.name !== currentRunner) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={stage.name} className="space-y-4 mb-6">
|
||||
<div className="text-lg font-medium">{stage.label.zh_CN}</div>
|
||||
|
||||
Reference in New Issue
Block a user