fix: use ConfigService for DeepSeek base URL in testCredential
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
- Replace hardcoded 'https://api.deepseek.com/v1/models' with config lookup - Single source of truth via ai.deepseek.baseUrl (DEEPSEEK_BASE_URL env) - Add ConfigService dep to UserAiService constructor + test mock Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
cb24e5fb96
commit
b0e9796acb
@ -1,4 +1,5 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
||||||
import { UserAiService } from './user-ai.service';
|
import { UserAiService } from './user-ai.service';
|
||||||
import { PrismaService } from '../../infrastructure/database/prisma.service';
|
import { PrismaService } from '../../infrastructure/database/prisma.service';
|
||||||
@ -42,6 +43,7 @@ describe('UserAiService.createAnalysisJob', () => {
|
|||||||
{ provide: PriorityRulesService, useValue: priorityRules },
|
{ provide: PriorityRulesService, useValue: priorityRules },
|
||||||
{ provide: UserAiQuotaService, useValue: quota },
|
{ provide: UserAiQuotaService, useValue: quota },
|
||||||
{ provide: PlatformBudgetService, useValue: budget },
|
{ provide: PlatformBudgetService, useValue: budget },
|
||||||
|
{ provide: ConfigService, useValue: { get: jest.fn().mockReturnValue('https://api.deepseek.com') } },
|
||||||
],
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { Injectable, NotFoundException, BadRequestException } from '@nestjs/common';
|
import { Injectable, NotFoundException, BadRequestException } from '@nestjs/common';
|
||||||
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { PrismaService } from '../../infrastructure/database/prisma.service';
|
import { PrismaService } from '../../infrastructure/database/prisma.service';
|
||||||
import { CredentialEncryptionService } from './credential-encryption.service';
|
import { CredentialEncryptionService } from './credential-encryption.service';
|
||||||
import { SnapshotBuilderService } from './snapshot-builder.service';
|
import { SnapshotBuilderService } from './snapshot-builder.service';
|
||||||
@ -24,6 +25,7 @@ export class UserAiService {
|
|||||||
private readonly priorityRules: PriorityRulesService,
|
private readonly priorityRules: PriorityRulesService,
|
||||||
private readonly quota: UserAiQuotaService,
|
private readonly quota: UserAiQuotaService,
|
||||||
private readonly budget: PlatformBudgetService,
|
private readonly budget: PlatformBudgetService,
|
||||||
|
private readonly config: ConfigService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
// ══ LearningProfile ══
|
// ══ LearningProfile ══
|
||||||
@ -143,7 +145,8 @@ export class UserAiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch('https://api.deepseek.com/v1/models', {
|
const baseUrl = this.config.get<string>('ai.deepseek.baseUrl', 'https://api.deepseek.com');
|
||||||
|
const res = await fetch(`${baseUrl}/v1/models`, {
|
||||||
headers: { Authorization: `Bearer ${decryptedKey}` },
|
headers: { Authorization: `Bearer ${decryptedKey}` },
|
||||||
signal: AbortSignal.timeout(10000),
|
signal: AbortSignal.timeout(10000),
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user