feat(api): remove List* response types and nils for get/list

TODO:
- make sure docstrings are refreshed as needed.
- make sure this passes tests.
- address a TODO in code (obsolete comment?)
- make sure client side still works.
- analyze if any providers need adjustments.

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
This commit is contained in:
Ihar Hrachyshka 2025-03-14 10:25:59 -04:00
parent bfc79217a8
commit 90ed785fbd
21 changed files with 222 additions and 935 deletions

View file

@ -150,9 +150,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/BatchChatCompletionResponse"
"$ref": "#/components/schemas/ChatCompletionResponse"
}
}
}
@ -193,9 +193,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/BatchCompletionResponse"
"$ref": "#/components/schemas/CompletionResponse"
}
}
}
@ -366,11 +366,11 @@
"get": {
"responses": {
"200": {
"description": "A ListAgentsResponse.",
"description": "a list of Agents.",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListAgentsResponse"
"$ref": "#/components/schemas/Agent"
}
}
}
@ -562,9 +562,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListBucketResponse"
"$ref": "#/components/schemas/Bucket"
}
}
}
@ -604,7 +604,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FileUploadResponse"
"$ref": "#/components/schemas/FileUpload"
}
}
}
@ -831,7 +831,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FileResponse"
"$ref": "#/components/schemas/File"
}
}
}
@ -881,7 +881,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FileResponse"
"$ref": "#/components/schemas/File"
}
}
}
@ -1160,14 +1160,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Benchmark"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/Benchmark"
}
}
}
@ -1209,14 +1202,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Dataset"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/Dataset"
}
}
}
@ -1291,14 +1277,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Model"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/Model"
}
}
}
@ -1373,14 +1352,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/ScoringFn"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/ScoringFn"
}
}
}
@ -1422,14 +1394,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Shield"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/Shield"
}
}
}
@ -1732,14 +1697,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/PostTrainingJobArtifactsResponse"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/PostTrainingJobArtifactsResponse"
}
}
}
@ -1781,14 +1739,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/PostTrainingJobStatusResponse"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/PostTrainingJobStatusResponse"
}
}
}
@ -1828,9 +1779,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListPostTrainingJobsResponse"
"$ref": "#/components/schemas/PostTrainingJob"
}
}
}
@ -1863,14 +1814,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/FileUploadResponse"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/FileUpload"
}
}
}
@ -1911,14 +1855,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/FileResponse"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/File"
}
}
}
@ -1972,14 +1909,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/VectorDB"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/VectorDB"
}
}
}
@ -2244,14 +2174,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/JobStatus"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/JobStatus"
}
}
}
@ -2394,11 +2317,11 @@
"get": {
"responses": {
"200": {
"description": "A ListAgentSessionsResponse.",
"description": "A list of agent Sessions.",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListAgentSessionsResponse"
"$ref": "#/components/schemas/Session"
}
}
}
@ -2439,9 +2362,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListBenchmarksResponse"
"$ref": "#/components/schemas/Benchmark"
}
}
}
@ -2506,9 +2429,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListDatasetsResponse"
"$ref": "#/components/schemas/Dataset"
}
}
}
@ -2573,9 +2496,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListFileResponse"
"$ref": "#/components/schemas/File"
}
}
}
@ -2616,9 +2539,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListModelsResponse"
"$ref": "#/components/schemas/Model"
}
}
}
@ -2690,9 +2613,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListProvidersResponse"
"$ref": "#/components/schemas/ProviderInfo"
}
}
}
@ -2723,9 +2646,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListRoutesResponse"
"$ref": "#/components/schemas/RouteInfo"
}
}
}
@ -2806,9 +2729,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListScoringFunctionsResponse"
"$ref": "#/components/schemas/ScoringFn"
}
}
}
@ -2873,9 +2796,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListShieldsResponse"
"$ref": "#/components/schemas/Shield"
}
}
}
@ -2947,9 +2870,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListToolGroupsResponse"
"$ref": "#/components/schemas/ToolGroup"
}
}
}
@ -3014,9 +2937,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListToolsResponse"
"$ref": "#/components/schemas/Tool"
}
}
}
@ -3056,9 +2979,9 @@
"200": {
"description": "OK",
"content": {
"application/json": {
"application/jsonl": {
"schema": {
"$ref": "#/components/schemas/ListVectorDBsResponse"
"$ref": "#/components/schemas/VectorDB"
}
}
}
@ -3085,14 +3008,7 @@
"post": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/VectorDB"
}
}
}
"description": "OK"
},
"400": {
"$ref": "#/components/responses/BadRequest400"
@ -4550,22 +4466,6 @@
],
"title": "BatchChatCompletionRequest"
},
"BatchChatCompletionResponse": {
"type": "object",
"properties": {
"batch": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ChatCompletionResponse"
}
}
},
"additionalProperties": false,
"required": [
"batch"
],
"title": "BatchChatCompletionResponse"
},
"ChatCompletionResponse": {
"type": "object",
"properties": {
@ -4677,22 +4577,6 @@
],
"title": "BatchCompletionRequest"
},
"BatchCompletionResponse": {
"type": "object",
"properties": {
"batch": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CompletionResponse"
}
}
},
"additionalProperties": false,
"required": [
"batch"
],
"title": "BatchCompletionResponse"
},
"CompletionResponse": {
"type": "object",
"properties": {
@ -6154,7 +6038,7 @@
],
"title": "CreateUploadSessionRequest"
},
"FileUploadResponse": {
"FileUpload": {
"type": "object",
"properties": {
"id": {
@ -6181,10 +6065,10 @@
"offset",
"size"
],
"title": "FileUploadResponse",
"title": "FileUpload",
"description": "Response after initiating a file upload session."
},
"FileResponse": {
"File": {
"type": "object",
"properties": {
"bucket": {
@ -6221,7 +6105,7 @@
"bytes",
"created_at"
],
"title": "FileResponse",
"title": "File",
"description": "Response representing a file entry."
},
"EmbeddingsRequest": {
@ -7735,31 +7619,18 @@
"title": "PostTrainingJobStatusResponse",
"description": "Status of a finetuning job."
},
"ListPostTrainingJobsResponse": {
"PostTrainingJob": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"job_uuid": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"job_uuid"
],
"title": "PostTrainingJob"
}
"job_uuid": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"data"
"job_uuid"
],
"title": "ListPostTrainingJobsResponse"
"title": "PostTrainingJob"
},
"VectorDB": {
"type": "object",
@ -8084,39 +7955,7 @@
],
"title": "ToolInvocationResult"
},
"ListAgentSessionsResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Session"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListAgentSessionsResponse"
},
"ListAgentsResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Agent"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListAgentsResponse"
},
"BucketResponse": {
"Bucket": {
"type": "object",
"properties": {
"name": {
@ -8127,107 +7966,7 @@
"required": [
"name"
],
"title": "BucketResponse"
},
"ListBucketResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/BucketResponse"
},
"description": "List of FileResponse entries"
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListBucketResponse",
"description": "Response representing a list of file entries."
},
"ListBenchmarksResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Benchmark"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListBenchmarksResponse"
},
"ListDatasetsResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Dataset"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListDatasetsResponse"
},
"ListFileResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/FileResponse"
},
"description": "List of FileResponse entries"
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListFileResponse",
"description": "Response representing a list of file entries."
},
"ListModelsResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Model"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListModelsResponse"
},
"ListProvidersResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ProviderInfo"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListProvidersResponse"
"title": "Bucket"
},
"RouteInfo": {
"type": "object",
@ -8253,102 +7992,6 @@
],
"title": "RouteInfo"
},
"ListRoutesResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/RouteInfo"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListRoutesResponse"
},
"ListScoringFunctionsResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ScoringFn"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListScoringFunctionsResponse"
},
"ListShieldsResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Shield"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListShieldsResponse"
},
"ListToolGroupsResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ToolGroup"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListToolGroupsResponse"
},
"ListToolsResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Tool"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListToolsResponse"
},
"ListVectorDBsResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/VectorDB"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListVectorDBsResponse"
},
"Event": {
"oneOf": [
{
@ -8881,19 +8524,6 @@
],
"title": "PreferenceOptimizeRequest"
},
"PostTrainingJob": {
"type": "object",
"properties": {
"job_uuid": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"job_uuid"
],
"title": "PostTrainingJob"
},
"DefaultRAGQueryGeneratorConfig": {
"type": "object",
"properties": {

View file

@ -90,9 +90,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/BatchChatCompletionResponse'
$ref: '#/components/schemas/ChatCompletionResponse'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -119,9 +119,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/BatchCompletionResponse'
$ref: '#/components/schemas/CompletionResponse'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -241,11 +241,11 @@ paths:
get:
responses:
'200':
description: A ListAgentsResponse.
description: a list of Agents.
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListAgentsResponse'
$ref: '#/components/schemas/Agent'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -380,9 +380,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListBucketResponse'
$ref: '#/components/schemas/Bucket'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -409,7 +409,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/FileUploadResponse'
$ref: '#/components/schemas/FileUpload'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -568,7 +568,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/FileResponse'
$ref: '#/components/schemas/File'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -604,7 +604,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/FileResponse'
$ref: '#/components/schemas/File'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -801,9 +801,7 @@ paths:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Benchmark'
- type: 'null'
$ref: '#/components/schemas/Benchmark'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -831,9 +829,7 @@ paths:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Dataset'
- type: 'null'
$ref: '#/components/schemas/Dataset'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -884,9 +880,7 @@ paths:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Model'
- type: 'null'
$ref: '#/components/schemas/Model'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -937,9 +931,7 @@ paths:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/ScoringFn'
- type: 'null'
$ref: '#/components/schemas/ScoringFn'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -967,9 +959,7 @@ paths:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Shield'
- type: 'null'
$ref: '#/components/schemas/Shield'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1171,9 +1161,7 @@ paths:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/PostTrainingJobArtifactsResponse'
- type: 'null'
$ref: '#/components/schemas/PostTrainingJobArtifactsResponse'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1201,9 +1189,7 @@ paths:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/PostTrainingJobStatusResponse'
- type: 'null'
$ref: '#/components/schemas/PostTrainingJobStatusResponse'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1229,9 +1215,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListPostTrainingJobsResponse'
$ref: '#/components/schemas/PostTrainingJob'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1254,9 +1240,7 @@ paths:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/FileUploadResponse'
- type: 'null'
$ref: '#/components/schemas/FileUpload'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1285,9 +1269,7 @@ paths:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/FileResponse'
- type: 'null'
$ref: '#/components/schemas/File'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1325,9 +1307,7 @@ paths:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/VectorDB'
- type: 'null'
$ref: '#/components/schemas/VectorDB'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1509,9 +1489,7 @@ paths:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/JobStatus'
- type: 'null'
$ref: '#/components/schemas/JobStatus'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1610,11 +1588,11 @@ paths:
get:
responses:
'200':
description: A ListAgentSessionsResponse.
description: A list of agent Sessions.
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListAgentSessionsResponse'
$ref: '#/components/schemas/Session'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1642,9 +1620,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListBenchmarksResponse'
$ref: '#/components/schemas/Benchmark'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1689,9 +1667,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListDatasetsResponse'
$ref: '#/components/schemas/Dataset'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1736,9 +1714,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListFileResponse'
$ref: '#/components/schemas/File'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1765,9 +1743,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListModelsResponse'
$ref: '#/components/schemas/Model'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1816,9 +1794,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListProvidersResponse'
$ref: '#/components/schemas/ProviderInfo'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1839,9 +1817,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListRoutesResponse'
$ref: '#/components/schemas/RouteInfo'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1895,9 +1873,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListScoringFunctionsResponse'
$ref: '#/components/schemas/ScoringFn'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1942,9 +1920,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListShieldsResponse'
$ref: '#/components/schemas/Shield'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -1993,9 +1971,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListToolGroupsResponse'
$ref: '#/components/schemas/ToolGroup'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -2040,9 +2018,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListToolsResponse'
$ref: '#/components/schemas/Tool'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -2068,9 +2046,9 @@ paths:
'200':
description: OK
content:
application/json:
application/jsonl:
schema:
$ref: '#/components/schemas/ListVectorDBsResponse'
$ref: '#/components/schemas/VectorDB'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -2089,10 +2067,6 @@ paths:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/VectorDB'
'400':
$ref: '#/components/responses/BadRequest400'
'429':
@ -3100,17 +3074,6 @@ components:
- model
- messages_batch
title: BatchChatCompletionRequest
BatchChatCompletionResponse:
type: object
properties:
batch:
type: array
items:
$ref: '#/components/schemas/ChatCompletionResponse'
additionalProperties: false
required:
- batch
title: BatchChatCompletionResponse
ChatCompletionResponse:
type: object
properties:
@ -3190,17 +3153,6 @@ components:
- model
- content_batch
title: BatchCompletionRequest
BatchCompletionResponse:
type: object
properties:
batch:
type: array
items:
$ref: '#/components/schemas/CompletionResponse'
additionalProperties: false
required:
- batch
title: BatchCompletionResponse
CompletionResponse:
type: object
properties:
@ -4260,7 +4212,7 @@ components:
- mime_type
- size
title: CreateUploadSessionRequest
FileUploadResponse:
FileUpload:
type: object
properties:
id:
@ -4281,10 +4233,10 @@ components:
- url
- offset
- size
title: FileUploadResponse
title: FileUpload
description: >-
Response after initiating a file upload session.
FileResponse:
File:
type: object
properties:
bucket:
@ -4315,7 +4267,7 @@ components:
- url
- bytes
- created_at
title: FileResponse
title: File
description: Response representing a file entry.
EmbeddingsRequest:
type: object
@ -5302,24 +5254,15 @@ components:
- checkpoints
title: PostTrainingJobStatusResponse
description: Status of a finetuning job.
ListPostTrainingJobsResponse:
PostTrainingJob:
type: object
properties:
data:
type: array
items:
type: object
properties:
job_uuid:
type: string
additionalProperties: false
required:
- job_uuid
title: PostTrainingJob
job_uuid:
type: string
additionalProperties: false
required:
- data
title: ListPostTrainingJobsResponse
- job_uuid
title: PostTrainingJob
VectorDB:
type: object
properties:
@ -5506,29 +5449,7 @@ components:
required:
- content
title: ToolInvocationResult
ListAgentSessionsResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Session'
additionalProperties: false
required:
- data
title: ListAgentSessionsResponse
ListAgentsResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Agent'
additionalProperties: false
required:
- data
title: ListAgentsResponse
BucketResponse:
Bucket:
type: object
properties:
name:
@ -5536,79 +5457,7 @@ components:
additionalProperties: false
required:
- name
title: BucketResponse
ListBucketResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/BucketResponse'
description: List of FileResponse entries
additionalProperties: false
required:
- data
title: ListBucketResponse
description: >-
Response representing a list of file entries.
ListBenchmarksResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Benchmark'
additionalProperties: false
required:
- data
title: ListBenchmarksResponse
ListDatasetsResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Dataset'
additionalProperties: false
required:
- data
title: ListDatasetsResponse
ListFileResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/FileResponse'
description: List of FileResponse entries
additionalProperties: false
required:
- data
title: ListFileResponse
description: >-
Response representing a list of file entries.
ListModelsResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Model'
additionalProperties: false
required:
- data
title: ListModelsResponse
ListProvidersResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/ProviderInfo'
additionalProperties: false
required:
- data
title: ListProvidersResponse
title: Bucket
RouteInfo:
type: object
properties:
@ -5626,72 +5475,6 @@ components:
- method
- provider_types
title: RouteInfo
ListRoutesResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/RouteInfo'
additionalProperties: false
required:
- data
title: ListRoutesResponse
ListScoringFunctionsResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/ScoringFn'
additionalProperties: false
required:
- data
title: ListScoringFunctionsResponse
ListShieldsResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Shield'
additionalProperties: false
required:
- data
title: ListShieldsResponse
ListToolGroupsResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/ToolGroup'
additionalProperties: false
required:
- data
title: ListToolGroupsResponse
ListToolsResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Tool'
additionalProperties: false
required:
- data
title: ListToolsResponse
ListVectorDBsResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/VectorDB'
additionalProperties: false
required:
- data
title: ListVectorDBsResponse
Event:
oneOf:
- $ref: '#/components/schemas/UnstructuredLogEvent'
@ -6035,15 +5818,6 @@ components:
- hyperparam_search_config
- logger_config
title: PreferenceOptimizeRequest
PostTrainingJob:
type: object
properties:
job_uuid:
type: string
additionalProperties: false
required:
- job_uuid
title: PostTrainingJob
DefaultRAGQueryGeneratorConfig:
type: object
properties:

View file

@ -241,16 +241,6 @@ class Agent(BaseModel):
created_at: datetime
@json_schema_type
class ListAgentsResponse(BaseModel):
data: List[Agent]
@json_schema_type
class ListAgentSessionsResponse(BaseModel):
data: List[Session]
class AgentConfigOverridablePerTurn(AgentConfigCommon):
instructions: Optional[str] = None
@ -559,10 +549,10 @@ class Agents(Protocol):
...
@webmethod(route="/agents", method="GET")
async def list_agents(self) -> ListAgentsResponse:
async def list_agents(self) -> list[Agent]:
"""List all agents.
:returns: A ListAgentsResponse.
:returns: a list of Agents.
"""
...
@ -579,10 +569,10 @@ class Agents(Protocol):
async def list_agent_sessions(
self,
agent_id: str,
) -> ListAgentSessionsResponse:
) -> list[Session]:
"""List all session(s) of a given agent.
:param agent_id: The ID of the agent to list sessions for.
:returns: A ListAgentSessionsResponse.
:returns: A list of agent Sessions.
"""
...

View file

@ -6,8 +6,6 @@
from typing import List, Optional, Protocol, runtime_checkable
from pydantic import BaseModel
from llama_stack.apis.inference import (
ChatCompletionResponse,
CompletionResponse,
@ -20,17 +18,7 @@ from llama_stack.apis.inference import (
ToolDefinition,
ToolPromptFormat,
)
from llama_stack.schema_utils import json_schema_type, webmethod
@json_schema_type
class BatchCompletionResponse(BaseModel):
batch: List[CompletionResponse]
@json_schema_type
class BatchChatCompletionResponse(BaseModel):
batch: List[ChatCompletionResponse]
from llama_stack.schema_utils import webmethod
@runtime_checkable
@ -43,7 +31,7 @@ class BatchInference(Protocol):
sampling_params: Optional[SamplingParams] = None,
response_format: Optional[ResponseFormat] = None,
logprobs: Optional[LogProbConfig] = None,
) -> BatchCompletionResponse: ...
) -> list[CompletionResponse]: ...
@webmethod(route="/batch-inference/chat-completion", method="POST")
async def batch_chat_completion(
@ -57,4 +45,4 @@ class BatchInference(Protocol):
tool_prompt_format: Optional[ToolPromptFormat] = None,
response_format: Optional[ResponseFormat] = None,
logprobs: Optional[LogProbConfig] = None,
) -> BatchChatCompletionResponse: ...
) -> list[ChatCompletionResponse]: ...

View file

@ -39,20 +39,16 @@ class BenchmarkInput(CommonBenchmarkFields, BaseModel):
provider_benchmark_id: Optional[str] = None
class ListBenchmarksResponse(BaseModel):
data: List[Benchmark]
@runtime_checkable
class Benchmarks(Protocol):
@webmethod(route="/eval/benchmarks", method="GET")
async def list_benchmarks(self) -> ListBenchmarksResponse: ...
async def list_benchmarks(self) -> list[Benchmark]: ...
@webmethod(route="/eval/benchmarks/{benchmark_id}", method="GET")
async def get_benchmark(
self,
benchmark_id: str,
) -> Optional[Benchmark]: ...
) -> Benchmark: ...
@webmethod(route="/eval/benchmarks", method="POST")
async def register_benchmark(

View file

@ -4,7 +4,7 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import Any, Dict, List, Literal, Optional, Protocol
from typing import Any, Dict, Literal, Optional, Protocol
from pydantic import BaseModel, Field
@ -42,10 +42,6 @@ class DatasetInput(CommonDatasetFields, BaseModel):
provider_dataset_id: Optional[str] = None
class ListDatasetsResponse(BaseModel):
data: List[Dataset]
class Datasets(Protocol):
@webmethod(route="/datasets", method="POST")
async def register_dataset(
@ -62,10 +58,10 @@ class Datasets(Protocol):
async def get_dataset(
self,
dataset_id: str,
) -> Optional[Dataset]: ...
) -> Dataset: ...
@webmethod(route="/datasets", method="GET")
async def list_datasets(self) -> ListDatasetsResponse: ...
async def list_datasets(self) -> list[Dataset]: ...
@webmethod(route="/datasets/{dataset_id:path}", method="DELETE")
async def unregister_dataset(

View file

@ -117,7 +117,7 @@ class Eval(Protocol):
"""
@webmethod(route="/eval/benchmarks/{benchmark_id}/jobs/{job_id}", method="GET")
async def job_status(self, benchmark_id: str, job_id: str) -> Optional[JobStatus]:
async def job_status(self, benchmark_id: str, job_id: str) -> JobStatus:
"""Get the status of a job.
:param benchmark_id: The ID of the benchmark to run the evaluation on.

View file

@ -4,7 +4,7 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import List, Optional, Protocol, runtime_checkable
from typing import Protocol, runtime_checkable
from pydantic import BaseModel
@ -13,7 +13,7 @@ from llama_stack.schema_utils import json_schema_type, webmethod
@json_schema_type
class FileUploadResponse(BaseModel):
class FileUpload(BaseModel):
"""
Response after initiating a file upload session.
@ -30,23 +30,12 @@ class FileUploadResponse(BaseModel):
@json_schema_type
class BucketResponse(BaseModel):
class Bucket(BaseModel):
name: str
@json_schema_type
class ListBucketResponse(BaseModel):
"""
Response representing a list of file entries.
:param data: List of FileResponse entries
"""
data: List[BucketResponse]
@json_schema_type
class FileResponse(BaseModel):
class File(BaseModel):
"""
Response representing a file entry.
@ -66,17 +55,6 @@ class FileResponse(BaseModel):
created_at: int
@json_schema_type
class ListFileResponse(BaseModel):
"""
Response representing a list of file entries.
:param data: List of FileResponse entries
"""
data: List[FileResponse]
@runtime_checkable
@trace_protocol
class Files(Protocol):
@ -87,7 +65,7 @@ class Files(Protocol):
key: str,
mime_type: str,
size: int,
) -> FileUploadResponse:
) -> FileUpload:
"""
Create a new upload session for a file identified by a bucket and key.
@ -102,7 +80,7 @@ class Files(Protocol):
async def upload_content_to_session(
self,
upload_id: str,
) -> Optional[FileResponse]:
) -> File:
"""
Upload file content to an existing upload session.
On the server, request body will have the raw bytes that are uploaded.
@ -115,7 +93,7 @@ class Files(Protocol):
async def get_upload_session_info(
self,
upload_id: str,
) -> Optional[FileUploadResponse]:
) -> FileUpload:
"""
Returns information about an existsing upload session
@ -127,7 +105,7 @@ class Files(Protocol):
async def list_all_buckets(
self,
bucket: str,
) -> ListBucketResponse:
) -> list[Bucket]:
"""
List all buckets.
"""
@ -137,7 +115,7 @@ class Files(Protocol):
async def list_files_in_bucket(
self,
bucket: str,
) -> ListFileResponse:
) -> list[File]:
"""
List all files in a bucket.
@ -150,7 +128,7 @@ class Files(Protocol):
self,
bucket: str,
key: str,
) -> FileResponse:
) -> File:
"""
Get a file info identified by a bucket and key.
@ -164,7 +142,7 @@ class Files(Protocol):
self,
bucket: str,
key: str,
) -> FileResponse:
) -> File:
"""
Delete a file identified by a bucket and key.

View file

@ -31,26 +31,18 @@ class ProviderInfo(BaseModel):
provider_type: str
class ListProvidersResponse(BaseModel):
data: List[ProviderInfo]
@json_schema_type
class VersionInfo(BaseModel):
version: str
class ListRoutesResponse(BaseModel):
data: List[RouteInfo]
@runtime_checkable
class Inspect(Protocol):
@webmethod(route="/inspect/providers", method="GET")
async def list_providers(self) -> ListProvidersResponse: ...
async def list_providers(self) -> list[ProviderInfo]: ...
@webmethod(route="/inspect/routes", method="GET")
async def list_routes(self) -> ListRoutesResponse: ...
async def list_routes(self) -> list[RouteInfo]: ...
@webmethod(route="/health", method="GET")
async def health(self) -> HealthInfo: ...

View file

@ -5,7 +5,7 @@
# the root directory of this source tree.
from enum import Enum
from typing import Any, Dict, List, Literal, Optional, Protocol, runtime_checkable
from typing import Any, Dict, Literal, Optional, Protocol, runtime_checkable
from pydantic import BaseModel, ConfigDict, Field
@ -52,21 +52,17 @@ class ModelInput(CommonModelFields):
model_config = ConfigDict(protected_namespaces=())
class ListModelsResponse(BaseModel):
data: List[Model]
@runtime_checkable
@trace_protocol
class Models(Protocol):
@webmethod(route="/models", method="GET")
async def list_models(self) -> ListModelsResponse: ...
async def list_models(self) -> list[Model]: ...
@webmethod(route="/models/{model_id:path}", method="GET")
async def get_model(
self,
model_id: str,
) -> Optional[Model]: ...
) -> Model: ...
@webmethod(route="/models", method="POST")
async def register_model(

View file

@ -157,10 +157,6 @@ class PostTrainingJobStatusResponse(BaseModel):
checkpoints: List[Checkpoint] = Field(default_factory=list)
class ListPostTrainingJobsResponse(BaseModel):
data: List[PostTrainingJob]
@json_schema_type
class PostTrainingJobArtifactsResponse(BaseModel):
"""Artifacts of a finetuning job."""
@ -199,13 +195,13 @@ class PostTraining(Protocol):
) -> PostTrainingJob: ...
@webmethod(route="/post-training/jobs", method="GET")
async def get_training_jobs(self) -> ListPostTrainingJobsResponse: ...
async def get_training_jobs(self) -> list[PostTrainingJob]: ...
@webmethod(route="/post-training/job/status", method="GET")
async def get_training_job_status(self, job_uuid: str) -> Optional[PostTrainingJobStatusResponse]: ...
async def get_training_job_status(self, job_uuid: str) -> PostTrainingJobStatusResponse: ...
@webmethod(route="/post-training/job/cancel", method="POST")
async def cancel_training_job(self, job_uuid: str) -> None: ...
@webmethod(route="/post-training/job/artifacts", method="GET")
async def get_training_job_artifacts(self, job_uuid: str) -> Optional[PostTrainingJobArtifactsResponse]: ...
async def get_training_job_artifacts(self, job_uuid: str) -> PostTrainingJobArtifactsResponse: ...

View file

@ -4,7 +4,7 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import Any, Dict, List, Protocol, runtime_checkable
from typing import Any, Dict, Protocol, runtime_checkable
from pydantic import BaseModel
@ -19,10 +19,6 @@ class ProviderInfo(BaseModel):
config: Dict[str, Any]
class ListProvidersResponse(BaseModel):
data: List[ProviderInfo]
@runtime_checkable
class Providers(Protocol):
"""
@ -30,7 +26,7 @@ class Providers(Protocol):
"""
@webmethod(route="/providers", method="GET")
async def list_providers(self) -> ListProvidersResponse: ...
async def list_providers(self) -> list[ProviderInfo]: ...
@webmethod(route="/providers/{provider_id}", method="GET")
async def inspect_provider(self, provider_id: str) -> ProviderInfo: ...

View file

@ -125,17 +125,13 @@ class ScoringFnInput(CommonScoringFnFields, BaseModel):
provider_scoring_fn_id: Optional[str] = None
class ListScoringFunctionsResponse(BaseModel):
data: List[ScoringFn]
@runtime_checkable
class ScoringFunctions(Protocol):
@webmethod(route="/scoring-functions", method="GET")
async def list_scoring_functions(self) -> ListScoringFunctionsResponse: ...
async def list_scoring_functions(self) -> list[ScoringFn]: ...
@webmethod(route="/scoring-functions/{scoring_fn_id:path}", method="GET")
async def get_scoring_function(self, scoring_fn_id: str, /) -> Optional[ScoringFn]: ...
async def get_scoring_function(self, scoring_fn_id: str, /) -> ScoringFn: ...
@webmethod(route="/scoring-functions", method="POST")
async def register_scoring_function(

View file

@ -4,7 +4,7 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import Any, Dict, List, Literal, Optional, Protocol, runtime_checkable
from typing import Any, Dict, Literal, Optional, Protocol, runtime_checkable
from pydantic import BaseModel
@ -38,18 +38,14 @@ class ShieldInput(CommonShieldFields):
provider_shield_id: Optional[str] = None
class ListShieldsResponse(BaseModel):
data: List[Shield]
@runtime_checkable
@trace_protocol
class Shields(Protocol):
@webmethod(route="/shields", method="GET")
async def list_shields(self) -> ListShieldsResponse: ...
async def list_shields(self) -> list[Shield]: ...
@webmethod(route="/shields/{identifier:path}", method="GET")
async def get_shield(self, identifier: str) -> Optional[Shield]: ...
async def get_shield(self, identifier: str) -> Shield: ...
@webmethod(route="/shields", method="POST")
async def register_shield(

View file

@ -103,6 +103,7 @@ class MetricInResponse(BaseModel):
unit: Optional[str] = None
# TODO: check what this comment is about
# This is a short term solution to allow inference API to return metrics
# The ideal way to do this is to have a way for all response types to include metrics
# and all metric events logged to the telemetry API to be inlcuded with the response

View file

@ -80,14 +80,6 @@ class ToolStore(Protocol):
def get_tool_group(self, toolgroup_id: str) -> ToolGroup: ...
class ListToolGroupsResponse(BaseModel):
data: List[ToolGroup]
class ListToolsResponse(BaseModel):
data: List[Tool]
@runtime_checkable
@trace_protocol
class ToolGroups(Protocol):
@ -109,12 +101,12 @@ class ToolGroups(Protocol):
) -> ToolGroup: ...
@webmethod(route="/toolgroups", method="GET")
async def list_tool_groups(self) -> ListToolGroupsResponse:
async def list_tool_groups(self) -> list[ToolGroup]:
"""List tool groups with optional provider"""
...
@webmethod(route="/tools", method="GET")
async def list_tools(self, toolgroup_id: Optional[str] = None) -> ListToolsResponse:
async def list_tools(self, toolgroup_id: Optional[str] = None) -> list[Tool]:
"""List tools with optional tool group"""
...
@ -148,7 +140,7 @@ class ToolRuntime(Protocol):
@webmethod(route="/tool-runtime/list-tools", method="GET")
async def list_runtime_tools(
self, tool_group_id: Optional[str] = None, mcp_endpoint: Optional[URL] = None
) -> List[ToolDef]: ...
) -> list[ToolDef]: ...
@webmethod(route="/tool-runtime/invoke", method="POST")
async def invoke_tool(self, tool_name: str, kwargs: Dict[str, Any]) -> ToolInvocationResult:

View file

@ -4,7 +4,7 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
from typing import List, Literal, Optional, Protocol, runtime_checkable
from typing import Literal, Optional, Protocol, runtime_checkable
from pydantic import BaseModel
@ -36,21 +36,17 @@ class VectorDBInput(BaseModel):
provider_vector_db_id: Optional[str] = None
class ListVectorDBsResponse(BaseModel):
data: List[VectorDB]
@runtime_checkable
@trace_protocol
class VectorDBs(Protocol):
@webmethod(route="/vector-dbs", method="GET")
async def list_vector_dbs(self) -> ListVectorDBsResponse: ...
async def list_vector_dbs(self) -> list[VectorDB]: ...
@webmethod(route="/vector-dbs/{vector_db_id:path}", method="GET")
async def get_vector_db(
self,
vector_db_id: str,
) -> Optional[VectorDB]: ...
) -> VectorDB: ...
@webmethod(route="/vector-dbs", method="POST")
async def register_vector_db(
@ -60,7 +56,7 @@ class VectorDBs(Protocol):
embedding_dimension: Optional[int] = 384,
provider_id: Optional[str] = None,
provider_vector_db_id: Optional[str] = None,
) -> VectorDB: ...
) -> None: ...
@webmethod(route="/vector-dbs/{vector_db_id:path}", method="DELETE")
async def unregister_vector_db(self, vector_db_id: str) -> None: ...

View file

@ -30,7 +30,7 @@ class QueryChunksResponse(BaseModel):
class VectorDBStore(Protocol):
def get_vector_db(self, vector_db_id: str) -> Optional[VectorDB]: ...
def get_vector_db(self, vector_db_id: str) -> VectorDB: ...
@runtime_checkable

View file

@ -11,8 +11,6 @@ from pydantic import BaseModel
from llama_stack.apis.inspect import (
HealthInfo,
Inspect,
ListProvidersResponse,
ListRoutesResponse,
ProviderInfo,
RouteInfo,
VersionInfo,
@ -39,43 +37,27 @@ class DistributionInspectImpl(Inspect):
async def initialize(self) -> None:
pass
async def list_providers(self) -> ListProvidersResponse:
run_config = self.config.run_config
ret = []
for api, providers in run_config.providers.items():
ret.extend(
[
ProviderInfo(
api=api,
provider_id=p.provider_id,
provider_type=p.provider_type,
)
for p in providers
]
async def list_providers(self) -> list[ProviderInfo]:
return [
ProviderInfo(
api=api,
provider_id=p.provider_id,
provider_type=p.provider_type,
)
for api, providers in self.config.run_config.providers.items()
for p in providers
]
return ListProvidersResponse(data=ret)
async def list_routes(self) -> ListRoutesResponse:
run_config = self.config.run_config
ret = []
all_endpoints = get_all_api_endpoints()
for api, endpoints in all_endpoints.items():
providers = run_config.providers.get(api.value, [])
ret.extend(
[
RouteInfo(
route=e.route,
method=e.method,
provider_types=[p.provider_type for p in providers],
)
for e in endpoints
]
async def list_routes(self) -> list[RouteInfo]:
return [
RouteInfo(
route=e.route,
method=e.method,
provider_types=[p.provider_type for p in self.config.run_config.providers.get(api.value, [])],
)
return ListRoutesResponse(data=ret)
for api, endpoints in get_all_api_endpoints().items()
for e in endpoints
]
async def health(self) -> HealthInfo:
return HealthInfo(status="OK")

View file

@ -7,7 +7,7 @@
from pydantic import BaseModel
from llama_stack.apis.providers import ListProvidersResponse, ProviderInfo, Providers
from llama_stack.apis.providers import ProviderInfo, Providers
from .datatypes import StackRunConfig
from .stack import redact_sensitive_fields
@ -31,28 +31,23 @@ class ProviderImpl(Providers):
async def initialize(self) -> None:
pass
async def list_providers(self) -> ListProvidersResponse:
async def list_providers(self) -> list[ProviderInfo]:
run_config = self.config.run_config
safe_config = StackRunConfig(**redact_sensitive_fields(run_config.model_dump()))
ret = []
for api, providers in safe_config.providers.items():
ret.extend(
[
ProviderInfo(
api=api,
provider_id=p.provider_id,
provider_type=p.provider_type,
config=p.config,
)
for p in providers
]
return [
ProviderInfo(
api=api,
provider_id=p.provider_id,
provider_type=p.provider_type,
config=p.config,
)
return ListProvidersResponse(data=ret)
for api, providers in safe_config.providers.items()
for p in providers
]
async def inspect_provider(self, provider_id: str) -> ProviderInfo:
all_providers = await self.list_providers()
for p in all_providers.data:
for p in all_providers:
if p.provider_id == provider_id:
return p

View file

@ -9,28 +9,25 @@ from typing import Any, Dict, List, Optional
from pydantic import TypeAdapter
from llama_stack.apis.benchmarks import Benchmark, Benchmarks, ListBenchmarksResponse
from llama_stack.apis.benchmarks import Benchmark, Benchmarks
from llama_stack.apis.common.content_types import URL
from llama_stack.apis.common.type_system import ParamType
from llama_stack.apis.datasets import Dataset, Datasets, ListDatasetsResponse
from llama_stack.apis.models import ListModelsResponse, Model, Models, ModelType
from llama_stack.apis.datasets import Dataset, Datasets
from llama_stack.apis.models import Model, Models, ModelType
from llama_stack.apis.resource import ResourceType
from llama_stack.apis.scoring_functions import (
ListScoringFunctionsResponse,
ScoringFn,
ScoringFnParams,
ScoringFunctions,
)
from llama_stack.apis.shields import ListShieldsResponse, Shield, Shields
from llama_stack.apis.shields import Shield, Shields
from llama_stack.apis.tools import (
ListToolGroupsResponse,
ListToolsResponse,
Tool,
ToolGroup,
ToolGroups,
ToolHost,
)
from llama_stack.apis.vector_dbs import ListVectorDBsResponse, VectorDB, VectorDBs
from llama_stack.apis.vector_dbs import VectorDB, VectorDBs
from llama_stack.distribution.datatypes import (
RoutableObject,
RoutableObjectWithProvider,
@ -208,8 +205,8 @@ class CommonRoutingTableImpl(RoutingTable):
class ModelsRoutingTable(CommonRoutingTableImpl, Models):
async def list_models(self) -> ListModelsResponse:
return ListModelsResponse(data=await self.get_all_with_type("model"))
async def list_models(self) -> list[Model]:
return await self.get_all_with_type("model")
async def get_model(self, model_id: str) -> Optional[Model]:
return await self.get_object_by_identifier("model", model_id)
@ -256,8 +253,8 @@ class ModelsRoutingTable(CommonRoutingTableImpl, Models):
class ShieldsRoutingTable(CommonRoutingTableImpl, Shields):
async def list_shields(self) -> ListShieldsResponse:
return ListShieldsResponse(data=await self.get_all_with_type(ResourceType.shield.value))
async def list_shields(self) -> list[Shield]:
return await self.get_all_with_type(ResourceType.shield.value)
async def get_shield(self, identifier: str) -> Optional[Shield]:
return await self.get_object_by_identifier("shield", identifier)
@ -292,8 +289,8 @@ class ShieldsRoutingTable(CommonRoutingTableImpl, Shields):
class VectorDBsRoutingTable(CommonRoutingTableImpl, VectorDBs):
async def list_vector_dbs(self) -> ListVectorDBsResponse:
return ListVectorDBsResponse(data=await self.get_all_with_type("vector_db"))
async def list_vector_dbs(self) -> list[VectorDB]:
return await self.get_all_with_type("vector_db")
async def get_vector_db(self, vector_db_id: str) -> Optional[VectorDB]:
return await self.get_object_by_identifier("vector_db", vector_db_id)
@ -344,8 +341,8 @@ class VectorDBsRoutingTable(CommonRoutingTableImpl, VectorDBs):
class DatasetsRoutingTable(CommonRoutingTableImpl, Datasets):
async def list_datasets(self) -> ListDatasetsResponse:
return ListDatasetsResponse(data=await self.get_all_with_type(ResourceType.dataset.value))
async def list_datasets(self) -> list[Dataset]:
return await self.get_all_with_type(ResourceType.dataset.value)
async def get_dataset(self, dataset_id: str) -> Optional[Dataset]:
return await self.get_object_by_identifier("dataset", dataset_id)
@ -389,8 +386,8 @@ class DatasetsRoutingTable(CommonRoutingTableImpl, Datasets):
class ScoringFunctionsRoutingTable(CommonRoutingTableImpl, ScoringFunctions):
async def list_scoring_functions(self) -> ListScoringFunctionsResponse:
return ListScoringFunctionsResponse(data=await self.get_all_with_type(ResourceType.scoring_function.value))
async def list_scoring_functions(self) -> list[ScoringFunctions]:
return await self.get_all_with_type(ResourceType.scoring_function.value)
async def get_scoring_function(self, scoring_fn_id: str) -> Optional[ScoringFn]:
return await self.get_object_by_identifier("scoring_function", scoring_fn_id)
@ -426,8 +423,8 @@ class ScoringFunctionsRoutingTable(CommonRoutingTableImpl, ScoringFunctions):
class BenchmarksRoutingTable(CommonRoutingTableImpl, Benchmarks):
async def list_benchmarks(self) -> ListBenchmarksResponse:
return ListBenchmarksResponse(data=await self.get_all_with_type("benchmark"))
async def list_benchmarks(self) -> list[Benchmark]:
return await self.get_all_with_type("benchmark")
async def get_benchmark(self, benchmark_id: str) -> Optional[Benchmark]:
return await self.get_object_by_identifier("benchmark", benchmark_id)
@ -464,14 +461,14 @@ class BenchmarksRoutingTable(CommonRoutingTableImpl, Benchmarks):
class ToolGroupsRoutingTable(CommonRoutingTableImpl, ToolGroups):
async def list_tools(self, toolgroup_id: Optional[str] = None) -> ListToolsResponse:
async def list_tools(self, toolgroup_id: Optional[str] = None) -> list[Tool]:
tools = await self.get_all_with_type("tool")
if toolgroup_id:
tools = [tool for tool in tools if tool.toolgroup_id == toolgroup_id]
return ListToolsResponse(data=tools)
return tools
async def list_tool_groups(self) -> ListToolGroupsResponse:
return ListToolGroupsResponse(data=await self.get_all_with_type("tool_group"))
async def list_tool_groups(self) -> list[ToolGroup]:
return await self.get_all_with_type("tool_group")
async def get_tool_group(self, toolgroup_id: str) -> ToolGroup:
return await self.get_object_by_identifier("tool_group", toolgroup_id)