From d2333c88c69ab51e0429e9b81ac68b53889af4f1 Mon Sep 17 00:00:00 2001 From: Jason Owens <67338327+Jdo300@users.noreply.github.com> Date: Thu, 20 Mar 2025 16:23:57 -0400 Subject: [PATCH] Corrected bug in openrouter.ts and pre-commit and pre-push husky scripts - Corrected error causing free models listed under openrouter to show pricing information - Updated pre-push and pre-commit scripts to work in Windows environments when pushing to branch (windows requires npm/npx to include the ".cmd" extension to recognize and compile. --- .husky/pre-commit | 9 ++++++++- .husky/pre-push | 9 ++++++++- src/api/providers/openrouter.ts | 3 ++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 111a1c0f91..8a87777657 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -5,4 +5,11 @@ if [ "$branch" = "main" ]; then exit 1 fi -npx lint-staged +# Detect if running on Windows and use npx.cmd, otherwise use npx +if [ "$OS" = "Windows_NT" ]; then + npx_cmd="npx.cmd" +else + npx_cmd="npx" +fi + +"$npx_cmd" lint-staged \ No newline at end of file diff --git a/.husky/pre-push b/.husky/pre-push index a4fea4a34a..79fe13835d 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -5,7 +5,14 @@ if [ "$branch" = "main" ]; then exit 1 fi -npm run compile +# Detect if running on Windows and use npm.cmd, otherwise use npm +if [ "$OS" = "Windows_NT" ]; then + npm_cmd="npm.cmd" +else + npm_cmd="npm" +fi + +"$npm_cmd" run compile # Check for new changesets. NEW_CHANGESETS=$(find .changeset -name "*.md" ! -name "README.md" | wc -l | tr -d ' ') diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts index 3823400455..f33d203379 100644 --- a/src/api/providers/openrouter.ts +++ b/src/api/providers/openrouter.ts @@ -289,12 +289,13 @@ export async function getOpenRouterModels(options?: ApiHandlerOptions) { modelInfo.maxTokens = 8192 break case rawModel.id.startsWith("anthropic/claude-3-haiku"): - default: modelInfo.supportsPromptCache = true modelInfo.cacheWritesPrice = 0.3 modelInfo.cacheReadsPrice = 0.03 modelInfo.maxTokens = 8192 break + default: + break } models[rawModel.id] = modelInfo