Skip to content

[model-parameters] Simplify the model parameters REST API #1464

@dlqqq

Description

@dlqqq

Problem

Here is the existing REST API interface:

export type GetModelParametersResponse = {
  parameters: Record<string, ParameterSchema>;
  parameter_names: string[];
  count: number;
};

export type ParameterSchema = {
  type: 'boolean' | 'integer' | 'number' | 'string' | 'array' | 'object';
  description: string;
  min?: number;
  max?: number;
};

export type UpdateModelParametersResponse = {
  status: string;
  message: string;
  model_id: string;
  parameters: Record<string, any>;
};

There are a couple of issues:

  1. UpdateModelParametersResponse is totally unused by the frontend. The parameters property is the same as the request object. The model_id is already known by the frontend, and both status and message are unnecessary as HTTP status codes can be used.

  2. GetModelParametersResponse and ParameterSchema are not defined as Pydantic models in the backend. Pydantic models are basically an easier way to define object types, and can provide validation at runtime.

  3. GetModelParametersResponse.count is not necessary. It is very easy to get the length of a list in most languages.

  4. ParameterSchema has two number types: 'number' and 'integer'. We should probably rename 'number' to 'float' for clarity.

Context

This issue to track source code comments added here: jonahjung22#1

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions