feat(cluster,api,models,cli): add cluster-aware model catalog deployments and request routing
This commit is contained in:
+39
-11
@@ -63,7 +63,11 @@ export class SanityMiddleware {
|
||||
if (request.temperature !== undefined) {
|
||||
const temp = request.temperature as number;
|
||||
if (typeof temp !== 'number' || temp < 0 || temp > 2) {
|
||||
return { valid: false, error: '"temperature" must be between 0 and 2', param: 'temperature' };
|
||||
return {
|
||||
valid: false,
|
||||
error: '"temperature" must be between 0 and 2',
|
||||
param: 'temperature',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +81,11 @@ export class SanityMiddleware {
|
||||
if (request.max_tokens !== undefined) {
|
||||
const maxTokens = request.max_tokens as number;
|
||||
if (typeof maxTokens !== 'number' || maxTokens < 1) {
|
||||
return { valid: false, error: '"max_tokens" must be a positive integer', param: 'max_tokens' };
|
||||
return {
|
||||
valid: false,
|
||||
error: '"max_tokens" must be a positive integer',
|
||||
param: 'max_tokens',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,14 +103,22 @@ export class SanityMiddleware {
|
||||
if (request.presence_penalty !== undefined) {
|
||||
const pp = request.presence_penalty as number;
|
||||
if (typeof pp !== 'number' || pp < -2 || pp > 2) {
|
||||
return { valid: false, error: '"presence_penalty" must be between -2 and 2', param: 'presence_penalty' };
|
||||
return {
|
||||
valid: false,
|
||||
error: '"presence_penalty" must be between -2 and 2',
|
||||
param: 'presence_penalty',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (request.frequency_penalty !== undefined) {
|
||||
const fp = request.frequency_penalty as number;
|
||||
if (typeof fp !== 'number' || fp < -2 || fp > 2) {
|
||||
return { valid: false, error: '"frequency_penalty" must be between -2 and 2', param: 'frequency_penalty' };
|
||||
return {
|
||||
valid: false,
|
||||
error: '"frequency_penalty" must be between -2 and 2',
|
||||
param: 'frequency_penalty',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +130,11 @@ export class SanityMiddleware {
|
||||
*/
|
||||
private validateMessage(msg: Record<string, unknown>, index: number): IValidationResult {
|
||||
if (!msg || typeof msg !== 'object') {
|
||||
return { valid: false, error: `Message at index ${index} must be an object`, param: `messages[${index}]` };
|
||||
return {
|
||||
valid: false,
|
||||
error: `Message at index ${index} must be an object`,
|
||||
param: `messages[${index}]`,
|
||||
};
|
||||
}
|
||||
|
||||
// Validate role
|
||||
@@ -178,7 +198,11 @@ export class SanityMiddleware {
|
||||
|
||||
const input = request.input;
|
||||
if (typeof input !== 'string' && !Array.isArray(input)) {
|
||||
return { valid: false, error: '"input" must be a string or array of strings', param: 'input' };
|
||||
return {
|
||||
valid: false,
|
||||
error: '"input" must be a string or array of strings',
|
||||
param: 'input',
|
||||
};
|
||||
}
|
||||
|
||||
if (Array.isArray(input)) {
|
||||
@@ -197,7 +221,11 @@ export class SanityMiddleware {
|
||||
if (request.encoding_format !== undefined) {
|
||||
const format = request.encoding_format as string;
|
||||
if (format !== 'float' && format !== 'base64') {
|
||||
return { valid: false, error: '"encoding_format" must be "float" or "base64"', param: 'encoding_format' };
|
||||
return {
|
||||
valid: false,
|
||||
error: '"encoding_format" must be "float" or "base64"',
|
||||
param: 'encoding_format',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,14 +233,14 @@ export class SanityMiddleware {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if model is in greenlist (async validation)
|
||||
* Check if model is in the public registry.
|
||||
*/
|
||||
public async validateModelGreenlist(modelName: string): Promise<IValidationResult> {
|
||||
const isGreenlit = await this.modelRegistry.isModelGreenlit(modelName);
|
||||
if (!isGreenlit) {
|
||||
const isListed = await this.modelRegistry.isModelListed(modelName);
|
||||
if (!isListed) {
|
||||
return {
|
||||
valid: false,
|
||||
error: `Model "${modelName}" is not greenlit. Contact administrator to add it to the greenlist.`,
|
||||
error: `Model "${modelName}" is not listed in the registry.`,
|
||||
param: 'model',
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user