fix: 修复模型加载的时候的权限验证问题
This commit is contained in:
parent
bae91176f3
commit
70fef8df7e
@ -100,6 +100,35 @@ export const chatApi = {
|
|||||||
*/
|
*/
|
||||||
getTools: () => apiGet('/api/chat/tools', {}, true),
|
getTools: () => apiGet('/api/chat/tools', {}, true),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模型提供商的模型列表
|
||||||
|
* @param {string} provider - 模型提供商
|
||||||
|
* @returns {Promise} - 模型列表
|
||||||
|
*/
|
||||||
|
getProviderModels: (provider) => {
|
||||||
|
return fetch(`/api/chat/models?model_provider=${provider}`, {
|
||||||
|
headers: {
|
||||||
|
...useUserStore().getAuthHeaders()
|
||||||
|
}
|
||||||
|
}).then(response => response.json())
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新模型提供商的模型列表
|
||||||
|
* @param {string} provider - 模型提供商
|
||||||
|
* @param {Array} models - 选中的模型列表
|
||||||
|
* @returns {Promise} - 更新结果
|
||||||
|
*/
|
||||||
|
updateProviderModels: (provider, models) => {
|
||||||
|
return fetch(`/api/chat/models/update?model_provider=${provider}`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...useUserStore().getAuthHeaders()
|
||||||
|
},
|
||||||
|
body: JSON.stringify(models)
|
||||||
|
}).then(response => response.json())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户设置API
|
// 用户设置API
|
||||||
|
|||||||
@ -380,6 +380,7 @@ import TableConfigComponent from '@/components/TableConfigComponent.vue';
|
|||||||
import { notification, Button } from 'ant-design-vue';
|
import { notification, Button } from 'ant-design-vue';
|
||||||
import { modelIcons } from '@/utils/modelIcon'
|
import { modelIcons } from '@/utils/modelIcon'
|
||||||
import { systemConfigApi } from '@/apis/admin_api'
|
import { systemConfigApi } from '@/apis/admin_api'
|
||||||
|
import { chatApi } from '@/apis/auth_api'
|
||||||
|
|
||||||
|
|
||||||
const configStore = useConfigStore()
|
const configStore = useConfigStore()
|
||||||
@ -623,8 +624,7 @@ const sendRestart = () => {
|
|||||||
// 获取模型提供商的模型列表
|
// 获取模型提供商的模型列表
|
||||||
const fetchProviderModels = (provider) => {
|
const fetchProviderModels = (provider) => {
|
||||||
providerConfig.loading = true;
|
providerConfig.loading = true;
|
||||||
fetch(`/api/chat/models?model_provider=${provider}`)
|
chatApi.getProviderModels(provider)
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(`${provider} 模型列表:`, data);
|
console.log(`${provider} 模型列表:`, data);
|
||||||
|
|
||||||
@ -680,19 +680,7 @@ const saveProviderConfig = async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 发送选择的模型列表到后端
|
// 发送选择的模型列表到后端
|
||||||
const response = await fetch(`/api/chat/models/update?model_provider=${providerConfig.provider}`, {
|
const data = await chatApi.updateProviderModels(providerConfig.provider, providerConfig.selectedModels);
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify(providerConfig.selectedModels),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('保存模型配置失败');
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
console.log('更新后的模型列表:', data.models);
|
console.log('更新后的模型列表:', data.models);
|
||||||
|
|
||||||
message.success({ content: '模型配置已保存!', key: 'save-config', duration: 2 });
|
message.success({ content: '模型配置已保存!', key: 'save-config', duration: 2 });
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user