Skip to content

Commit

Permalink
fix: replace img host (labring#3691)
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu authored Feb 5, 2025
1 parent ac95828 commit b6e441c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/service/core/chat/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ export const loadRequestMessages = async ({
const baseURL = process.env.FE_DOMAIN;
if (!baseURL) return text;
// 匹配 /api/system/img/xxx.xx 的图片链接,并追加 baseURL
return text.replace(/(\/api\/system\/img\/[^\s.]*\.[^\s]*)/g, (match, p1) => `${baseURL}${p1}`);
return text.replace(
/(?<!https?:\/\/[^\s]*)(?:\/api\/system\/img\/[^\s.]*\.[^\s]*)/g,
(match) => `${baseURL}${match}`
);
};
const parseSystemMessage = (
content: string | ChatCompletionContentPartText[]
Expand Down

0 comments on commit b6e441c

Please sign in to comment.