From 8f8eeacc3d37010bfd368d30b271de1748e0ef20 Mon Sep 17 00:00:00 2001 From: musi Date: Thu, 10 Jul 2025 20:51:30 +0800 Subject: [PATCH] fix fallback to the default model when no router configuration is provided --- README.md | 5 +++-- src/utils/router.ts | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e2c80af..ca5a78d 100644 --- a/README.md +++ b/README.md @@ -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 用户名) \ No newline at end of file diff --git a/src/utils/router.ts b/src/utils/router.ts index cbe86a6..7f167a7 100644 --- a/src/utils/router.ts +++ b/src/utils/router.ts @@ -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; };