fix fallback to the default model when no router configuration is provided

This commit is contained in:
musi
2025-07-10 20:51:30 +08:00
parent 50a679278d
commit 8f8eeacc3d
2 changed files with 9 additions and 8 deletions

View File

@@ -242,5 +242,6 @@ Thanks to the following sponsors for supporting the continued development of thi
[@bobleer](https://github.com/bobleer)
@\*苗 (可通过主页邮箱联系我修改 github 用户名)
@\*划 (可通过主页邮箱联系我修改 github 用户名)
[@Clarence-pan](https://github.com/Clarence-pan)
[@carter003](https://github.com/carter003)
[@Clarence-pan](https://github.com/Clarence-pan)
[@carter003](https://github.com/carter003)
@S\*r (可通过主页邮箱联系我修改 github 用户名)

View File

@@ -9,19 +9,19 @@ const getUseModel = (req: any, tokenCount: number, config: any) => {
return req.body.model;
}
// if tokenCount is greater than 60K, use the long context model
if (tokenCount > 1000 * 60) {
if (tokenCount > 1000 * 60 && config.Router.longContext) {
log("Using long context model due to token count:", tokenCount);
return config.Router!.longContext;
return config.Router.longContext;
}
// If the model is claude-3-5-haiku, use the background model
if (req.body.model?.startsWith("claude-3-5-haiku")) {
if (req.body.model?.startsWith("claude-3-5-haiku") && config.Router.background) {
log("Using background model for ", req.body.model);
return config.Router!.background;
return config.Router.background;
}
// if exits thinking, use the think model
if (req.body.thinking) {
if (req.body.thinking && config.Router.think) {
log("Using think model for ", req.body.thinking);
return config.Router!.think;
return config.Router.think;
}
return config.Router!.default;
};