|
|
@@ -27,6 +27,7 @@ import { getConfigField } from '../../config/index';
|
|
|
*/
|
|
|
function getSseUrl(agent_id, mode) {
|
|
|
const chat_id = agent_id;
|
|
|
+ let url = null;
|
|
|
if (['agent-dialog'].includes(mode)) {
|
|
|
return `/api/v1/chat/${chat_id}/completions`;
|
|
|
}
|
|
|
@@ -40,6 +41,22 @@ function getSseUrl(agent_id, mode) {
|
|
|
if (['agent-basic'].includes(mode)) {
|
|
|
return `/api/v1/complex/${chat_id}/completions`;
|
|
|
}
|
|
|
+
|
|
|
+ if (!url) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ // 获取环境配置并动态替换 URL
|
|
|
+ if (import.meta.env.MODE === 'production') {
|
|
|
+ const base_url = getConfigField('API_BASE_URL');
|
|
|
+ if (!base_url) {
|
|
|
+ throw new Error('关键配置项 API_BASE_URL 不存在,请在 /config.js 进行配置');
|
|
|
+ }
|
|
|
+ return base_url + url;
|
|
|
+ } else {
|
|
|
+ // 开发环境,使用相对路径(代理会处理)
|
|
|
+ return url;
|
|
|
+ }
|
|
|
+
|
|
|
return null;
|
|
|
}
|
|
|
|