feat: add /jobs API

This API will be later tied to jobs as defined for specific flows
(post-training, eval, etc.) through the common scheduler mechanism.

Note: At the moment, API does nothing useful. (Except returning Not
Implemented errors when called.)

This is an alternative to developing per-flow jobs APIs. Eventually,
once /jobs API is implemented, we should be able to deprecate existing
APIs under /v1/post-training/, /v1/eval/ etc.

See #1587 (tracker)
See #1238 (design details)

Note: This is an alternative path to #1582 and #1583.

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
This commit is contained in:
Ihar Hrachyshka 2025-03-12 16:15:30 -04:00
parent 0fdb15bcc7
commit 90799cdcee
12 changed files with 557 additions and 11 deletions

View file

@ -142,6 +142,30 @@ paths:
schema:
$ref: '#/components/schemas/BatchCompletionRequest'
required: true
/v1/jobs/{job_id}/cancel:
post:
responses:
'200':
description: OK
'400':
$ref: '#/components/responses/BadRequest400'
'429':
$ref: >-
#/components/responses/TooManyRequests429
'500':
$ref: >-
#/components/responses/InternalServerError500
default:
$ref: '#/components/responses/DefaultError'
tags:
- Jobs
description: ''
parameters:
- name: job_id
in: path
required: true
schema:
type: string
/v1/post-training/job/cancel:
post:
responses:
@ -633,6 +657,57 @@ paths:
required: true
schema:
type: string
/v1/jobs/{job_id}:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/JobInfo'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
$ref: >-
#/components/responses/TooManyRequests429
'500':
$ref: >-
#/components/responses/InternalServerError500
default:
$ref: '#/components/responses/DefaultError'
tags:
- Jobs
description: ''
parameters:
- name: job_id
in: path
required: true
schema:
type: string
delete:
responses:
'200':
description: OK
'400':
$ref: '#/components/responses/BadRequest400'
'429':
$ref: >-
#/components/responses/TooManyRequests429
'500':
$ref: >-
#/components/responses/InternalServerError500
default:
$ref: '#/components/responses/DefaultError'
tags:
- Jobs
description: ''
parameters:
- name: job_id
in: path
required: true
schema:
type: string
/v1/inference/embeddings:
post:
responses:
@ -1731,6 +1806,29 @@ paths:
required: true
schema:
type: string
/v1/jobs:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ListJobsResponse'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
$ref: >-
#/components/responses/TooManyRequests429
'500':
$ref: >-
#/components/responses/InternalServerError500
default:
$ref: '#/components/responses/DefaultError'
tags:
- Jobs
description: ''
parameters: []
/v1/models:
get:
responses:
@ -3213,6 +3311,10 @@ components:
CompletionResponse:
type: object
properties:
metrics:
type: array
items:
$ref: '#/components/schemas/MetricEvent'
content:
type: string
description: The generated completion text
@ -3531,6 +3633,10 @@ components:
CompletionResponseStreamChunk:
type: object
properties:
metrics:
type: array
items:
$ref: '#/components/schemas/MetricEvent'
delta:
type: string
description: >-
@ -4901,6 +5007,60 @@ components:
required:
- type
title: UnionType
JobArtifact:
type: object
properties:
name:
type: string
type:
type: string
uri:
type: string
metadata:
type: object
title: dict
description: >-
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized
from a mapping object's (key, value) pairs dict(iterable) -> new dictionary
initialized as if via: d = {} for k, v in iterable: d[k]
= v dict(**kwargs) -> new dictionary initialized with the name=value pairs in
the keyword argument list. For example: dict(one=1, two=2)
additionalProperties: false
required:
- name
- type
- uri
- metadata
title: JobArtifact
JobInfo:
type: object
properties:
uuid:
type: string
type:
type: string
status:
type: string
scheduled_at:
type: string
format: date-time
started_at:
type: string
format: date-time
completed_at:
type: string
format: date-time
artifacts:
type: array
items:
$ref: '#/components/schemas/JobArtifact'
additionalProperties: false
required:
- uuid
- type
- status
- artifacts
title: JobInfo
Model:
type: object
properties:
@ -5562,6 +5722,17 @@ components:
title: ListFileResponse
description: >-
Response representing a list of file entries.
ListJobsResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/JobInfo'
additionalProperties: false
required:
- data
title: ListJobsResponse
ListModelsResponse:
type: object
properties:
@ -6818,6 +6989,7 @@ tags:
Llama Stack Inference API for generating completions, chat completions, and
embeddings.
- name: Inspect
- name: Jobs
- name: Models
- name: PostTraining (Coming Soon)
- name: Safety
@ -6842,6 +7014,7 @@ x-tagGroups:
- Files (Coming Soon)
- Inference
- Inspect
- Jobs
- Models
- PostTraining (Coming Soon)
- Safety