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