修复AI工具调用报错
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
// API配置
|
||||
window.API_CONFIG = {
|
||||
baseUrl: 'http://127.0.0.1:5002',
|
||||
baseUrl: window.parent.ENV_CONFIG.API_URL,
|
||||
endpoints: {
|
||||
classicalConversion: '/api/aimodelapp/classical_conversion'
|
||||
}
|
||||
|
||||
@@ -12,18 +12,19 @@ const conversionResultContainer = document.getElementById('conversionResult');
|
||||
// 调用后端API
|
||||
async function callBackendAPI(modernText, style, articleType) {
|
||||
try {
|
||||
const token = AUTH_CONFIG.getToken();
|
||||
const headers = {
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
// 获取JWT token
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
if (!token) {
|
||||
throw new Error('未登录,请先登录后使用AI功能');
|
||||
}
|
||||
|
||||
const response = await fetch(`${API_CONFIG.baseUrl}${API_CONFIG.endpoints.classicalConversion}`, {
|
||||
const response = await fetch(`${window.API_CONFIG.baseUrl}/api/aimodelapp/classical_conversion`, {
|
||||
method: 'POST',
|
||||
headers: headers,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
modern_text: modernText,
|
||||
style: style,
|
||||
|
||||
Reference in New Issue
Block a user