mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 09:17:53 +00:00
init
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user