Endpoints¶
Top-level package for fastmlx.
add_model(model_name)
async
¶
Add a new model to the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
The name of the model to add. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the status of the operation. |
Source code in fastmlx/fastmlx.py
289 290 291 292 293 294 295 296 297 298 299 300 301 |
|
chat_completion(request)
async
¶
Handle chat completion requests for both VLM and LM models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
ChatCompletionRequest
|
The chat completion request. |
required |
Returns:
Name | Type | Description |
---|---|---|
ChatCompletionResponse |
ChatCompletionResponse
|
The generated chat completion response. |
Raises:
Type | Description |
---|---|
HTTPException(str)
|
If MLX library is not available. |
Source code in fastmlx/fastmlx.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
get_supported_models()
async
¶
Get a list of supported model types for VLM and LM.
Returns:
Name | Type | Description |
---|---|---|
JSONResponse |
json
|
A JSON response containing the supported models. |
Source code in fastmlx/fastmlx.py
259 260 261 262 263 264 265 266 267 |
|
list_models()
async
¶
Get list of models - provided in OpenAI API compliant format.
Source code in fastmlx/fastmlx.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
|
lm_generate(model, tokenizer, prompt, max_tokens=100, **kwargs)
¶
Generate a complete response from the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Module
|
The language model. |
required |
tokenizer
|
PreTrainedTokenizer
|
The tokenizer. |
required |
prompt
|
str
|
The string prompt. |
required |
max_tokens
|
int
|
The maximum number of tokens. Default: |
100
|
verbose
|
bool
|
If |
required |
formatter
|
Optional[Callable]
|
A function which takes a token and a probability and displays it. |
required |
kwargs
|
The remaining options get passed to :func: |
{}
|
Source code in fastmlx/utils.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
|
remove_model(model_name)
async
¶
Remove a model from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
The name of the model to remove. |
required |
Returns:
Name | Type | Description |
---|---|---|
Response |
str
|
A 204 No Content response if successful. |
Raises:
Type | Description |
---|---|
HTTPException(str)
|
If the model is not found. |
Source code in fastmlx/fastmlx.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
|