mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-09-04 16:47:15 +00:00
bugfix: fix bot page form bug
This commit is contained in:
@@ -69,8 +69,8 @@ export default function BotForm({
|
|||||||
if (initBotId) {
|
if (initBotId) {
|
||||||
getBotFieldById(initBotId).then(val => {
|
getBotFieldById(initBotId).then(val => {
|
||||||
form.setFieldsValue(val)
|
form.setFieldsValue(val)
|
||||||
// TODO 这里有个bug,adapter config 并没有被设置到表单中,表单一直都只显示默认值
|
|
||||||
handleAdapterSelect(val.adapter)
|
handleAdapterSelect(val.adapter)
|
||||||
|
dynamicForm.setFieldsValue(val.adapter_config)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
form.resetFields()
|
form.resetFields()
|
||||||
@@ -98,8 +98,10 @@ export default function BotForm({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleAdapterSelect(adapterName: string) {
|
function handleAdapterSelect(adapterName: string) {
|
||||||
|
console.log("Select adapter: ", adapterName)
|
||||||
if (adapterName) {
|
if (adapterName) {
|
||||||
const dynamicFormConfigList = adapterNameToDynamicConfigMap.get(adapterName)
|
const dynamicFormConfigList = adapterNameToDynamicConfigMap.get(adapterName)
|
||||||
|
console.log(dynamicFormConfigList)
|
||||||
if (dynamicFormConfigList) {
|
if (dynamicFormConfigList) {
|
||||||
setDynamicFormConfigList(dynamicFormConfigList)
|
setDynamicFormConfigList(dynamicFormConfigList)
|
||||||
}
|
}
|
||||||
@@ -153,12 +155,10 @@ export default function BotForm({
|
|||||||
console.log(err)
|
console.log(err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
onFormSubmit(form.getFieldsValue())
|
|
||||||
setShowDynamicForm(false)
|
setShowDynamicForm(false)
|
||||||
|
onFormSubmit(form.getFieldsValue())
|
||||||
form.resetFields()
|
form.resetFields()
|
||||||
dynamicForm.resetFields()
|
dynamicForm.resetFields()
|
||||||
// TODO 刷新bot列表
|
|
||||||
// TODO 关闭当前弹窗
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSaveButton() {
|
function handleSaveButton() {
|
||||||
|
|||||||
@@ -24,17 +24,7 @@ export default function BotConfigPage() {
|
|||||||
// TODO:补齐加载转圈逻辑
|
// TODO:补齐加载转圈逻辑
|
||||||
checkHasLLM().then((hasLLM) => {
|
checkHasLLM().then((hasLLM) => {
|
||||||
if (hasLLM) {
|
if (hasLLM) {
|
||||||
getBotList().then((botList) => {
|
getBotList()
|
||||||
if (botList.length === 0) {
|
|
||||||
setPageShowRule(BotConfigPageShowRule.NO_BOT)
|
|
||||||
} else {
|
|
||||||
setPageShowRule(BotConfigPageShowRule.HAVE_BOT)
|
|
||||||
}
|
|
||||||
setBotList(botList)
|
|
||||||
}).catch((err) => {
|
|
||||||
// TODO error toast
|
|
||||||
console.error("get bot list error (useEffect)", err)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
setPageShowRule(BotConfigPageShowRule.NO_LLM)
|
setPageShowRule(BotConfigPageShowRule.NO_LLM)
|
||||||
}
|
}
|
||||||
@@ -46,26 +36,27 @@ export default function BotConfigPage() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBotList(): Promise<BotCardVO[]> {
|
function getBotList() {
|
||||||
|
httpClient.getBots().then((resp) => {
|
||||||
return new Promise((resolve) => {
|
const botList: BotCardVO[] = resp.bots.map((bot: Bot) => {
|
||||||
httpClient.getBots().then((resp) => {
|
return new BotCardVO({
|
||||||
const botList: BotCardVO[] = resp.bots.map((bot: Bot) => {
|
adapter: bot.adapter,
|
||||||
return new BotCardVO({
|
description: bot.description,
|
||||||
adapter: bot.adapter,
|
id: bot.uuid || "",
|
||||||
description: bot.description,
|
name: bot.name,
|
||||||
id: bot.uuid || "",
|
updateTime: bot.updated_at || "",
|
||||||
name: bot.name,
|
pipelineName: bot.use_pipeline_name || "",
|
||||||
updateTime: bot.updated_at || "",
|
|
||||||
pipelineName: bot.use_pipeline_name || "",
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
resolve(botList)
|
|
||||||
}).catch((err) => {
|
|
||||||
// TODO error toast
|
|
||||||
console.error("get bot list error", err)
|
|
||||||
resolve([])
|
|
||||||
})
|
})
|
||||||
|
if (botList.length === 0) {
|
||||||
|
setPageShowRule(BotConfigPageShowRule.NO_BOT)
|
||||||
|
} else {
|
||||||
|
setPageShowRule(BotConfigPageShowRule.HAVE_BOT)
|
||||||
|
}
|
||||||
|
setBotList(botList)
|
||||||
|
}).catch((err) => {
|
||||||
|
// TODO error toast
|
||||||
|
console.error("get bot list error", err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +91,10 @@ export default function BotConfigPage() {
|
|||||||
>
|
>
|
||||||
<BotForm
|
<BotForm
|
||||||
initBotId={nowSelectedBotCard?.id}
|
initBotId={nowSelectedBotCard?.id}
|
||||||
onFormSubmit={() => setIsEditForm(false)}
|
onFormSubmit={() => {
|
||||||
|
getBotList()
|
||||||
|
setModalOpen(false)
|
||||||
|
}}
|
||||||
onFormCancel={() => setModalOpen(false)}
|
onFormCancel={() => setModalOpen(false)}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import styles from "@/app/home/models/LLMConfig.module.css";
|
import styles from "@/app/home/models/LLMConfig.module.css";
|
||||||
import {Button, Form, Input, Select, SelectProps, Space, Popconfirm, Modal} from "antd";
|
import {Button, Form, Input, Select, SelectProps, Space, Modal} from "antd";
|
||||||
import {ICreateLLMField} from "@/app/home/models/ICreateLLMField";
|
import {ICreateLLMField} from "@/app/home/models/ICreateLLMField";
|
||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import {IChooseRequesterEntity} from "@/app/home/models/component/llm-form/ChooseAdapterEntity";
|
import {IChooseRequesterEntity} from "@/app/home/models/component/llm-form/ChooseAdapterEntity";
|
||||||
|
|||||||
Reference in New Issue
Block a user