修复config 不同步的问题
This commit is contained in:
parent
1115bf18b2
commit
f0984191ae
@ -21,7 +21,7 @@ services:
|
||||
- NEO4J_USERNAME=neo4j
|
||||
- NEO4J_PASSWORD=0123456789
|
||||
- MILVUS_URI=http://milvus:19530
|
||||
command: gunicorn src.main:app --bind 0.0.0.0:5000 --reload --workers 10 --worker-class uvicorn.workers.UvicornWorker
|
||||
command: uvicorn src.main:app --host 0.0.0.0 --port 5000 --reload
|
||||
|
||||
web:
|
||||
build:
|
||||
|
||||
@ -4,7 +4,7 @@ base = APIRouter()
|
||||
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi import Request
|
||||
from fastapi import Request, Body
|
||||
from src.core import HistoryManager
|
||||
from src.utils.logging_config import setup_logger
|
||||
from src.core.startup import startup
|
||||
@ -20,9 +20,8 @@ def get_config():
|
||||
return startup.config
|
||||
|
||||
@base.post("/config")
|
||||
async def update_config(request: Request):
|
||||
request_data = await request.json()
|
||||
startup.config.update(request_data)
|
||||
async def update_config(key = Body(...), value = Body(...)):
|
||||
startup.config[key] = value
|
||||
startup.config.save()
|
||||
return startup.config
|
||||
|
||||
|
||||
@ -33,26 +33,19 @@ const layoutSettings = reactive({
|
||||
})
|
||||
|
||||
const getRemoteConfig = () => {
|
||||
fetch('/api/config').then(res => res.json()).then(data => {
|
||||
console.log(data)
|
||||
configStore.setConfig(data)
|
||||
})
|
||||
configStore.refreshConfig()
|
||||
}
|
||||
|
||||
const getRemoteDatabase = () => {
|
||||
if (!configStore.config.enable_knowledge_base) {
|
||||
return
|
||||
}
|
||||
fetch('/api/data').then(res => res.json()).then(data => {
|
||||
console.log("database", data)
|
||||
databaseStore.setDatabase(data.databases)
|
||||
})
|
||||
databaseStore.refreshDatabase()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getRemoteConfig()
|
||||
getRemoteDatabase()
|
||||
configStore.refreshConfig()
|
||||
})
|
||||
|
||||
// 打印当前页面的路由信息,使用 vue3 的 setup composition API
|
||||
|
||||
@ -22,11 +22,15 @@ export const useConfigStore = defineStore('config', () => {
|
||||
config.value[key] = value
|
||||
fetch('/api/config', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(config.value),
|
||||
body: JSON.stringify({ key, value }),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log('Success:', data)
|
||||
console.debug('Success:', data)
|
||||
setConfig(data)
|
||||
})
|
||||
}
|
||||
|
||||
@ -34,6 +38,7 @@ export const useConfigStore = defineStore('config', () => {
|
||||
fetch('/api/config')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log("config", data)
|
||||
setConfig(data)
|
||||
})
|
||||
}
|
||||
|
||||
@ -7,5 +7,12 @@ export const useDatabaseStore = defineStore('database', () => {
|
||||
db.value = newDatabase
|
||||
}
|
||||
|
||||
return { db, setDatabase }
|
||||
function refreshDatabase() {
|
||||
fetch('/api/data').then(res => res.json()).then(data => {
|
||||
console.log("database", data)
|
||||
setDatabase(data.databases)
|
||||
})
|
||||
}
|
||||
|
||||
return { db, setDatabase, refreshDatabase }
|
||||
})
|
||||
@ -231,8 +231,7 @@ const handleChange = (key, e) => {
|
||||
return
|
||||
}
|
||||
|
||||
console.log('Change', key, e)
|
||||
|
||||
// 这些都是需要重启的配置
|
||||
if (key == 'enable_reranker'
|
||||
|| key == 'enable_knowledge_graph'
|
||||
|| key == 'enable_knowledge_base'
|
||||
@ -283,14 +282,12 @@ const handleAddCustomModel = async () => {
|
||||
|
||||
customModel.visible = false
|
||||
await configStore.setConfigValue('custom_models', configStore.config.custom_models)
|
||||
configStore.refreshConfig()
|
||||
message.success('添加自定义模型成功')
|
||||
}
|
||||
|
||||
const handleDeleteCustomModel = (name) => {
|
||||
configStore.config.custom_models = configStore.config.custom_models.filter(item => item.name != name)
|
||||
configStore.setConfigValue('custom_models', configStore.config.custom_models)
|
||||
configStore.refreshConfig()
|
||||
const updatedModels = configStore.config.custom_models.filter(item => item.name !== name);
|
||||
configStore.setConfigValue('custom_models', updatedModels);
|
||||
}
|
||||
|
||||
const handleEditCustomModel = (item) => {
|
||||
@ -567,4 +564,4 @@ const sendRestart = () => {
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user