Fix: Resolve TypeScript type errors and improve npm installation in Docker build
This commit is contained in:
@@ -17,7 +17,7 @@ COPY package*.json ./
|
||||
|
||||
# Install dependencies with development environment for building
|
||||
ENV NODE_ENV=development
|
||||
RUN npm install --no-optional
|
||||
RUN npm install --no-optional --verbose
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
@@ -71,17 +71,17 @@ export class ModelCache {
|
||||
public searchModels(params: {
|
||||
query?: string;
|
||||
provider?: string;
|
||||
minContextLength?: number;
|
||||
maxContextLength?: number;
|
||||
maxPromptPrice?: number;
|
||||
maxCompletionPrice?: number;
|
||||
minContextLength?: number | string;
|
||||
maxContextLength?: number | string;
|
||||
maxPromptPrice?: number | string;
|
||||
maxCompletionPrice?: number | string;
|
||||
capabilities?: {
|
||||
functions?: boolean;
|
||||
tools?: boolean;
|
||||
vision?: boolean;
|
||||
json_mode?: boolean;
|
||||
};
|
||||
limit?: number;
|
||||
limit?: number | string;
|
||||
}): any[] {
|
||||
let results = this.getAllModels();
|
||||
|
||||
@@ -103,33 +103,53 @@ export class ModelCache {
|
||||
}
|
||||
|
||||
// Filter by context length
|
||||
if (params.minContextLength) {
|
||||
if (params.minContextLength !== undefined) {
|
||||
const minContextLength = typeof params.minContextLength === 'string'
|
||||
? parseInt(params.minContextLength, 10)
|
||||
: params.minContextLength;
|
||||
if (!isNaN(minContextLength)) {
|
||||
results = results.filter(
|
||||
(model) => model.context_length >= params.minContextLength
|
||||
(model) => model.context_length >= minContextLength
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.maxContextLength) {
|
||||
if (params.maxContextLength !== undefined) {
|
||||
const maxContextLength = typeof params.maxContextLength === 'string'
|
||||
? parseInt(params.maxContextLength, 10)
|
||||
: params.maxContextLength;
|
||||
if (!isNaN(maxContextLength)) {
|
||||
results = results.filter(
|
||||
(model) => model.context_length <= params.maxContextLength
|
||||
(model) => model.context_length <= maxContextLength
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter by price
|
||||
if (params.maxPromptPrice) {
|
||||
if (params.maxPromptPrice !== undefined) {
|
||||
const maxPromptPrice = typeof params.maxPromptPrice === 'string'
|
||||
? parseFloat(params.maxPromptPrice)
|
||||
: params.maxPromptPrice;
|
||||
if (!isNaN(maxPromptPrice)) {
|
||||
results = results.filter(
|
||||
(model) =>
|
||||
!model.pricing?.prompt || model.pricing.prompt <= params.maxPromptPrice
|
||||
!model.pricing?.prompt || model.pricing.prompt <= maxPromptPrice
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.maxCompletionPrice) {
|
||||
if (params.maxCompletionPrice !== undefined) {
|
||||
const maxCompletionPrice = typeof params.maxCompletionPrice === 'string'
|
||||
? parseFloat(params.maxCompletionPrice)
|
||||
: params.maxCompletionPrice;
|
||||
if (!isNaN(maxCompletionPrice)) {
|
||||
results = results.filter(
|
||||
(model) =>
|
||||
!model.pricing?.completion ||
|
||||
model.pricing.completion <= params.maxCompletionPrice
|
||||
model.pricing.completion <= maxCompletionPrice
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Filter by capabilities
|
||||
if (params.capabilities) {
|
||||
@@ -150,8 +170,13 @@ export class ModelCache {
|
||||
}
|
||||
|
||||
// Apply limit
|
||||
if (params.limit && params.limit > 0) {
|
||||
results = results.slice(0, params.limit);
|
||||
if (params.limit !== undefined) {
|
||||
const limit = typeof params.limit === 'string'
|
||||
? parseInt(params.limit, 10)
|
||||
: params.limit;
|
||||
if (!isNaN(limit) && limit > 0) {
|
||||
results = results.slice(0, limit);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
|
||||
@@ -4,17 +4,17 @@ import { OpenRouterAPIClient } from '../openrouter-api.js';
|
||||
export interface SearchModelsToolRequest {
|
||||
query?: string;
|
||||
provider?: string;
|
||||
minContextLength?: number;
|
||||
maxContextLength?: number;
|
||||
maxPromptPrice?: number;
|
||||
maxCompletionPrice?: number;
|
||||
minContextLength?: number | string;
|
||||
maxContextLength?: number | string;
|
||||
maxPromptPrice?: number | string;
|
||||
maxCompletionPrice?: number | string;
|
||||
capabilities?: {
|
||||
functions?: boolean;
|
||||
tools?: boolean;
|
||||
vision?: boolean;
|
||||
json_mode?: boolean;
|
||||
};
|
||||
limit?: number;
|
||||
limit?: number | string;
|
||||
}
|
||||
|
||||
export async function handleSearchModels(
|
||||
|
||||
Reference in New Issue
Block a user