mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-01 21:20:44 +00:00
- Enhanced authentication method validation in `auth.ts` and `auth.test.ts`. - Introduced new model provider configuration logic - Updated environment variable handling for various auth types. - Removed deprecated utility functions and tests related to fallback mechanisms.
59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Qwen
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import type {
|
|
SlashCommand,
|
|
CommandContext,
|
|
OpenDialogActionReturn,
|
|
MessageActionReturn,
|
|
} from './types.js';
|
|
import { CommandKind } from './types.js';
|
|
import { t } from '../../i18n/index.js';
|
|
|
|
export const modelCommand: SlashCommand = {
|
|
name: 'model',
|
|
get description() {
|
|
return t('Switch the model for this session');
|
|
},
|
|
kind: CommandKind.BUILT_IN,
|
|
action: async (
|
|
context: CommandContext,
|
|
): Promise<OpenDialogActionReturn | MessageActionReturn> => {
|
|
const { services } = context;
|
|
const { config } = services;
|
|
|
|
if (!config) {
|
|
return {
|
|
type: 'message',
|
|
messageType: 'error',
|
|
content: 'Configuration not available.',
|
|
};
|
|
}
|
|
|
|
const contentGeneratorConfig = config.getContentGeneratorConfig();
|
|
if (!contentGeneratorConfig) {
|
|
return {
|
|
type: 'message',
|
|
messageType: 'error',
|
|
content: t('Content generator configuration not available.'),
|
|
};
|
|
}
|
|
|
|
const authType = contentGeneratorConfig.authType;
|
|
if (!authType) {
|
|
return {
|
|
type: 'message',
|
|
messageType: 'error',
|
|
content: t('Authentication type not available.'),
|
|
};
|
|
}
|
|
|
|
return {
|
|
type: 'dialog',
|
|
dialog: 'model',
|
|
};
|
|
},
|
|
};
|