Skip to content

Commit 9b46a60

Browse files
committed
feat(ai): enhance OpenAI configuration with additional headers
- Added 'X-Title' and 'HTTP-Referer' headers to the OpenAI client configuration for improved request context. - Included web URL in the configuration to support better tracking and analytics. Signed-off-by: Innei <tukon479@gmail.com>
1 parent f7cd8c7 commit 9b46a60

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

apps/core/src/modules/ai/ai.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class AiService {
1313
public async getOpenAiChain(options?: { maxTokens?: number }) {
1414
const {
1515
ai: { openAiKey, openAiEndpoint, openAiPreferredModel },
16+
url: { webUrl },
1617
} = await this.configService.waitForConfigReady()
1718
if (!openAiKey) {
1819
throw new BizException(ErrorCodeEnum.AINotEnabled, 'Key not found')
@@ -23,6 +24,10 @@ export class AiService {
2324
apiKey: openAiKey,
2425
configuration: {
2526
baseURL: openAiEndpoint || void 0,
27+
defaultHeaders: {
28+
'X-Title': 'Mix Space AI Client',
29+
'HTTP-Referer': webUrl,
30+
},
2631
},
2732
maxTokens: options?.maxTokens,
2833
})

0 commit comments

Comments
 (0)