/** * 大模型网关(对齐 ruoyi-ui/.env.development、vue.config.js) * * - H5 开发:请求同源 /llm-dev-proxy,由 vite devServer 转发到 LLM_PROXY_TARGET,避免 CORS 预检 OPTIONS 无 Authorization 被网关 401 * - H5 生产 / App / 小程序:直连 LLM_PROXY_TARGET */ export const LLM_API_KEY = 'yak_4dd329d945aa964baaee006118ef82f6' /** 真实网关根地址(与 ruoyi-ui LLM_PROXY_TARGET 一致) */ export const LLM_PROXY_TARGET = 'http://harrison1.iask.in:9107' /** * H5 开发是否走 /llm-dev-proxy(需 vite.config.js 配置转发) */ export const H5_LLM_USE_PROXY = true /** 开发代理路径前缀(与 ruoyi-ui VUE_APP_LLM_BASE_URL 开发值一致) */ export const LLM_DEV_PROXY_PREFIX = '/llm-dev-proxy' export function getLlmBaseUrl() { const target = String(LLM_PROXY_TARGET || '').replace(/\/$/, '') // #ifdef H5 if (H5_LLM_USE_PROXY && typeof import.meta !== 'undefined' && import.meta.env && import.meta.env.DEV) { return LLM_DEV_PROXY_PREFIX } // #endif return target } /** @deprecated 请使用 getLlmBaseUrl();保留兼容旧引用 */ export const LLM_BASE_URL = getLlmBaseUrl() /** * 拼接大模型接口地址 * @param {string} path 如 /v1/chat/completions */ export function joinLlmUrl(path) { if (!path) { return getLlmBaseUrl() } if (/^https?:\/\//i.test(path)) { return path } const p = path.startsWith('/') ? path : '/' + path const base = getLlmBaseUrl().replace(/\/$/, '') return base + p }