This commit is contained in:
koalazf99
2025-08-01 01:44:13 +08:00
parent bdf946a321
commit 9d1ffb4af6
13 changed files with 58 additions and 58 deletions

View File

@@ -5,5 +5,5 @@
*/
export const DEFAULT_GEMINI_MODEL = 'qwen3-coder-plus';
export const DEFAULT_GEMINI_FLASH_MODEL = 'gemini-2.5-flash';
export const DEFAULT_GEMINI_FLASH_MODEL = 'qwen3-coder-flash';
export const DEFAULT_GEMINI_EMBEDDING_MODEL = 'gemini-embedding-001';

View File

@@ -34,7 +34,7 @@ describe('OpenAIContentGenerator Timeout Handling', () => {
vi.clearAllMocks();
// Mock environment variables
vi.stubEnv('OPENAI_BASE_URL', '');
vi.stubEnv('QWEN_CODE_BASE_URL', '');
// Mock config
mockConfig = {

View File

@@ -75,7 +75,7 @@ export async function createContentGeneratorConfig(
const googleApiKey = process.env.GOOGLE_API_KEY || undefined;
const googleCloudProject = process.env.GOOGLE_CLOUD_PROJECT || undefined;
const googleCloudLocation = process.env.GOOGLE_CLOUD_LOCATION || undefined;
const openaiApiKey = process.env.OPENAI_API_KEY;
const openaiApiKey = process.env.QWEN_CODE_API_KEY;
// Use runtime model from config if available, otherwise fallback to parameter or default
const effectiveModel = model || DEFAULT_GEMINI_MODEL;
@@ -117,7 +117,7 @@ export async function createContentGeneratorConfig(
if (authType === AuthType.USE_OPENAI && openaiApiKey) {
contentGeneratorConfig.apiKey = openaiApiKey;
contentGeneratorConfig.model =
process.env.OPENAI_MODEL || DEFAULT_GEMINI_MODEL;
process.env.QWEN_CODE_MODEL || DEFAULT_GEMINI_MODEL;
return contentGeneratorConfig;
}

View File

@@ -97,7 +97,7 @@ export class OpenAIContentGenerator implements ContentGenerator {
constructor(apiKey: string, model: string, config: Config) {
this.model = model;
this.config = config;
const baseURL = process.env.OPENAI_BASE_URL || '';
const baseURL = process.env.QWEN_CODE_BASE_URL || '';
// Configure timeout settings - using progressive timeouts
const timeoutConfig = {

View File

@@ -130,8 +130,8 @@ describe('URL matching with trailing slash compatibility', () => {
// Test case 1: No trailing slash in config, actual URL has trailing slash
process.env = {
...originalEnv,
OPENAI_BASE_URL: 'https://api.example.com/',
OPENAI_MODEL: 'gpt-4',
QWEN_CODE_BASE_URL: 'https://api.example.com/',
QWEN_CODE_MODEL: 'gpt-4',
};
const result1 = getCoreSystemPrompt(undefined, config);
@@ -140,8 +140,8 @@ describe('URL matching with trailing slash compatibility', () => {
// Test case 2: Config has trailing slash, actual URL has no trailing slash
process.env = {
...originalEnv,
OPENAI_BASE_URL: 'https://api.openai.com',
OPENAI_MODEL: 'gpt-3.5-turbo',
QWEN_CODE_BASE_URL: 'https://api.openai.com',
QWEN_CODE_MODEL: 'gpt-3.5-turbo',
};
const result2 = getCoreSystemPrompt(undefined, config);
@@ -150,8 +150,8 @@ describe('URL matching with trailing slash compatibility', () => {
// Test case 3: No trailing slash in config, actual URL has no trailing slash
process.env = {
...originalEnv,
OPENAI_BASE_URL: 'https://api.example.com',
OPENAI_MODEL: 'gpt-4',
QWEN_CODE_BASE_URL: 'https://api.example.com',
QWEN_CODE_MODEL: 'gpt-4',
};
const result3 = getCoreSystemPrompt(undefined, config);
@@ -160,8 +160,8 @@ describe('URL matching with trailing slash compatibility', () => {
// Test case 4: Config has trailing slash, actual URL has trailing slash
process.env = {
...originalEnv,
OPENAI_BASE_URL: 'https://api.openai.com/',
OPENAI_MODEL: 'gpt-3.5-turbo',
QWEN_CODE_BASE_URL: 'https://api.openai.com/',
QWEN_CODE_MODEL: 'gpt-3.5-turbo',
};
const result4 = getCoreSystemPrompt(undefined, config);
@@ -187,8 +187,8 @@ describe('URL matching with trailing slash compatibility', () => {
// Test case: URLs do not match
process.env = {
...originalEnv,
OPENAI_BASE_URL: 'https://api.different.com',
OPENAI_MODEL: 'gpt-4',
QWEN_CODE_BASE_URL: 'https://api.different.com',
QWEN_CODE_MODEL: 'gpt-4',
};
const result = getCoreSystemPrompt(undefined, config);

View File

@@ -65,8 +65,8 @@ export function getCoreSystemPrompt(
// Check for system prompt mappings from global config
if (config?.systemPromptMappings) {
const currentModel = process.env.OPENAI_MODEL || DEFAULT_GEMINI_MODEL;
const currentBaseUrl = process.env.OPENAI_BASE_URL || '';
const currentModel = process.env.QWEN_CODE_MODEL || DEFAULT_GEMINI_MODEL;
const currentBaseUrl = process.env.QWEN_CODE_BASE_URL || '';
const matchedMapping = config.systemPromptMappings.find((mapping) => {
const { baseUrls, modelNames } = mapping;