Explorar o código

Corrected bug in openrouter.ts and pre-commit and pre-push husky scripts (#1853)

- 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.
Jason Owens hai 11 meses
pai
achega
87b9b72b32
Modificáronse 3 ficheiros con 18 adicións e 3 borrados
  1. 8 1
      .husky/pre-commit
  2. 8 1
      .husky/pre-push
  3. 2 1
      src/api/providers/openrouter.ts

+ 8 - 1
.husky/pre-commit

@@ -5,4 +5,11 @@ if [ "$branch" = "main" ]; then
   exit 1
   exit 1
 fi
 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

+ 8 - 1
.husky/pre-push

@@ -5,7 +5,14 @@ if [ "$branch" = "main" ]; then
   exit 1
   exit 1
 fi
 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.
 # Check for new changesets.
 NEW_CHANGESETS=$(find .changeset -name "*.md" ! -name "README.md" | wc -l | tr -d ' ')
 NEW_CHANGESETS=$(find .changeset -name "*.md" ! -name "README.md" | wc -l | tr -d ' ')

+ 2 - 1
src/api/providers/openrouter.ts

@@ -256,12 +256,13 @@ export async function getOpenRouterModels(options?: ApiHandlerOptions) {
 					modelInfo.maxTokens = 8192
 					modelInfo.maxTokens = 8192
 					break
 					break
 				case rawModel.id.startsWith("anthropic/claude-3-haiku"):
 				case rawModel.id.startsWith("anthropic/claude-3-haiku"):
-				default:
 					modelInfo.supportsPromptCache = true
 					modelInfo.supportsPromptCache = true
 					modelInfo.cacheWritesPrice = 0.3
 					modelInfo.cacheWritesPrice = 0.3
 					modelInfo.cacheReadsPrice = 0.03
 					modelInfo.cacheReadsPrice = 0.03
 					modelInfo.maxTokens = 8192
 					modelInfo.maxTokens = 8192
 					break
 					break
+				default:
+					break
 			}
 			}
 
 
 			models[rawModel.id] = modelInfo
 			models[rawModel.id] = modelInfo