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