mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 23:42:03 +00:00
fix: remove unshifted current modelId and add auth error response
This commit is contained in:
parent
889c49f0f4
commit
6fa11a7bae
3 changed files with 22 additions and 22 deletions
|
|
@ -286,6 +286,10 @@ class Connection {
|
|||
return RequestError.authRequired(details).toResult();
|
||||
}
|
||||
|
||||
if (details?.includes('/auth')) {
|
||||
return RequestError.authRequired(details).toResult();
|
||||
}
|
||||
|
||||
return RequestError.internalError(details).toResult();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -380,10 +380,10 @@ class GeminiAgent {
|
|||
const allConfiguredModels = config.getAllConfiguredModels();
|
||||
|
||||
const baseCurrentModelId = parseAcpBaseModelId(rawCurrentModelId);
|
||||
const currentModelId =
|
||||
currentAuthType && baseCurrentModelId
|
||||
? formatAcpModelId(baseCurrentModelId, currentAuthType)
|
||||
: baseCurrentModelId;
|
||||
const currentModelId = this.formatCurrentModelId(
|
||||
baseCurrentModelId,
|
||||
currentAuthType,
|
||||
);
|
||||
|
||||
const availableModels = allConfiguredModels;
|
||||
|
||||
|
|
@ -396,26 +396,20 @@ class GeminiAgent {
|
|||
},
|
||||
}));
|
||||
|
||||
if (
|
||||
currentModelId &&
|
||||
!mappedAvailableModels.some((model) => model.modelId === currentModelId)
|
||||
) {
|
||||
const currentContextWindowSize =
|
||||
config.getContentGeneratorConfig()?.contextWindowSize ??
|
||||
tokenLimit(currentModelId);
|
||||
mappedAvailableModels.unshift({
|
||||
modelId: currentModelId,
|
||||
name: currentModelId,
|
||||
description: null,
|
||||
_meta: {
|
||||
contextLimit: currentContextWindowSize,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
currentModelId,
|
||||
availableModels: mappedAvailableModels,
|
||||
};
|
||||
}
|
||||
|
||||
private formatCurrentModelId(
|
||||
baseModelId: string,
|
||||
authType?: AuthType,
|
||||
): string {
|
||||
if (!baseModelId) {
|
||||
return baseModelId;
|
||||
}
|
||||
|
||||
return authType ? formatAcpModelId(baseModelId, authType) : baseModelId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -371,7 +371,9 @@ export class Session implements SessionContext {
|
|||
const selectedAuthType = parsed.authType ?? previousAuthType;
|
||||
|
||||
if (!selectedAuthType) {
|
||||
throw acp.RequestError.invalidParams('authType cannot be determined');
|
||||
throw acp.RequestError.invalidParams(
|
||||
`authType cannot be determined for modelId "${parsed.modelId}"`,
|
||||
);
|
||||
}
|
||||
|
||||
await this.config.switchModel(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue