Skip to content

Commit e466c2b

Browse files
author
Andrej Simurka
committed
Added providers endpoint + tests
1 parent 9c1ab9b commit e466c2b

File tree

8 files changed

+664
-3
lines changed

8 files changed

+664
-3
lines changed

docs/auth.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ authorization:
249249
- `info` - Access the `/` endpoint, `/info` endpoint, `/readiness` endpoint, and `/liveness` endpoint
250250
- `get_config` - Access the `/config` endpoint
251251
- `get_models` - Access the `/models` endpoint
252+
- `list_providers` - Access the `/providers` endpoint
253+
- `get_provider` - Access the `/providers/{provider_id}` endpoint
252254
- `get_metrics` - Access the `/metrics` endpoint
253255
- `list_conversations` - Access the `/conversations` endpoint
254256
- `list_other_conversations` - Access conversations not owned by the user

docs/openapi.json

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,119 @@
203203
}
204204
}
205205
},
206+
"/v1/providers": {
207+
"get": {
208+
"tags": [
209+
"providers"
210+
],
211+
"summary": "Providers Endpoint Handler",
212+
"description": "Handle requests to the /providers endpoint.\n\nProcess GET requests to the /providers endpoint, returning a list of available\nproviders from the Llama Stack service.\n\nRaises:\n HTTPException: If unable to connect to the Llama Stack server or if\n providers retrieval fails for any reason.\n\nReturns:\n ProvidersListResponse: An object containing the list of available providers.",
213+
"operationId": "providers_endpoint_handler_v1_providers_get",
214+
"responses": {
215+
"200": {
216+
"description": "Successful Response",
217+
"content": {
218+
"application/json": {
219+
"schema": {
220+
"$ref": "#/components/schemas/ProvidersListResponse"
221+
}
222+
}
223+
},
224+
225+
"providers": {
226+
"agents": [
227+
{
228+
"provider_id": "meta-reference",
229+
"provider_type": "inline::meta-reference"
230+
}
231+
],
232+
"datasetio": [
233+
{
234+
"provider_id": "huggingface",
235+
"provider_type": "remote::huggingface"
236+
},
237+
{
238+
"provider_id": "localfs",
239+
"provider_type": "inline::localfs"
240+
}
241+
],
242+
"inference": [
243+
{
244+
"provider_id": "sentence-transformers",
245+
"provider_type": "inline::sentence-transformers"
246+
},
247+
{
248+
"provider_id": "openai",
249+
"provider_type": "remote::openai"
250+
}
251+
]
252+
}
253+
},
254+
"500": {
255+
"description": "Connection to Llama Stack is broken"
256+
}
257+
}
258+
}
259+
},
260+
"/v1/providers/{provider_id}": {
261+
"get": {
262+
"summary": "Retrieve a single provider by ID",
263+
"description": "Fetches detailed information about a specific provider, including its API, configuration, health status, provider ID, and type. Returns a 404 error if the provider with the specified ID does not exist, or a 500 error if there is a problem connecting to the Llama Stack service.",
264+
"parameters": [
265+
{
266+
"name": "provider_id",
267+
"in": "path",
268+
"required": true,
269+
"description": "Unique identifier of the provider to retrieve",
270+
"schema": {
271+
"type": "string"
272+
}
273+
}
274+
],
275+
"responses": {
276+
"200": {
277+
"description": "Provider found successfully",
278+
"content": {
279+
"application/json": {
280+
"schema": { "$ref": "#/components/schemas/ProviderResponse" },
281+
"example": {
282+
"api": "inference",
283+
"config": {"api_key": "********"},
284+
"health": {
285+
"status": "Not Implemented",
286+
"message": "Provider does not implement health check"
287+
},
288+
"provider_id": "openai",
289+
"provider_type": "remote::openai"
290+
}
291+
}
292+
}
293+
},
294+
"404": {
295+
"description": "Provider with the specified ID was not found",
296+
"content": {
297+
"application/json": {
298+
"example": {
299+
"response": "Provider with given id not found"
300+
}
301+
}
302+
}
303+
},
304+
"500": {
305+
"description": "Unable to retrieve provider due to server error or connection issues",
306+
"content": {
307+
"application/json": {
308+
"example": {
309+
"response": "Unable to retrieve list of providers",
310+
"cause": "Connection to Llama Stack is broken"
311+
}
312+
}
313+
}
314+
}
315+
},
316+
"tags": ["providers"]
317+
}
318+
},
206319
"/v1/query": {
207320
"post": {
208321
"tags": [
@@ -1246,6 +1359,8 @@
12461359
"get_models",
12471360
"get_tools",
12481361
"get_shields",
1362+
"list_providers",
1363+
"get_provider",
12491364
"get_metrics",
12501365
"get_config",
12511366
"info",
@@ -2762,6 +2877,105 @@
27622877
"title": "ProviderHealthStatus",
27632878
"description": "Model representing the health status of a provider.\n\nAttributes:\n provider_id: The ID of the provider.\n status: The health status ('ok', 'unhealthy', 'not_implemented').\n message: Optional message about the health status."
27642879
},
2880+
"ProviderResponse": {
2881+
"type": "object",
2882+
"title": "ProviderInfo",
2883+
"description": "Model representing a provider and its configuration, health, and identification details.",
2884+
"properties": {
2885+
"api": {
2886+
"type": "string",
2887+
"description": "The API name this provider implements"
2888+
},
2889+
"config": {
2890+
"type": "object",
2891+
"description": "Configuration parameters for the provider",
2892+
"additionalProperties": true
2893+
},
2894+
"health": {
2895+
"type": "object",
2896+
"description": "Current health status of the provider",
2897+
"additionalProperties": true
2898+
},
2899+
"provider_id": {
2900+
"type": "string",
2901+
"description": "Unique identifier for the provider"
2902+
},
2903+
"provider_type": {
2904+
"type": "string",
2905+
"description": "The type of provider implementation"
2906+
}
2907+
},
2908+
"required": [
2909+
"api",
2910+
"config",
2911+
"health",
2912+
"provider_id",
2913+
"provider_type"
2914+
],
2915+
"example": {
2916+
"api": "inference",
2917+
"config": {"api_key": "********"},
2918+
"health": {
2919+
"status": "Not Implemented",
2920+
"message": "Provider does not implement health check"
2921+
},
2922+
"provider_id": "openai",
2923+
"provider_type": "remote::openai"
2924+
}
2925+
},
2926+
"ProvidersListResponse": {
2927+
"type": "object",
2928+
"properties": {
2929+
"providers": {
2930+
"type": "object",
2931+
"description": "Mapping of API type to list of its available providers",
2932+
"additionalProperties": {
2933+
"type": "array",
2934+
"items": {
2935+
"type": "object",
2936+
"properties": {
2937+
"provider_id": {
2938+
"type": "string",
2939+
"description": "Unique local identifier of provider"
2940+
},
2941+
"provider_type": {
2942+
"type": "string",
2943+
"description": "Llama stack identifier of provider (following schema <type>::<name>)"
2944+
}
2945+
},
2946+
"required": ["provider_id", "provider_type"]
2947+
}
2948+
},
2949+
"examples": [
2950+
{
2951+
"inference": [
2952+
{
2953+
"provider_id": "sentence-transformers",
2954+
"provider_type": "inline::sentence-transformers"
2955+
},
2956+
{
2957+
"provider_id": "openai",
2958+
"provider_type": "remote::openai"
2959+
}
2960+
],
2961+
"datasetio": [
2962+
{
2963+
"provider_id": "huggingface",
2964+
"provider_type": "remote::huggingface"
2965+
},
2966+
{
2967+
"provider_id": "localfs",
2968+
"provider_type": "inline::localfs"
2969+
}
2970+
]
2971+
}
2972+
]
2973+
}
2974+
},
2975+
"required": ["providers"],
2976+
"title": "ProvidersListResponse",
2977+
"description": "Model representing a response to providers request."
2978+
},
27652979
"QueryRequest": {
27662980
"properties": {
27672981
"query": {

0 commit comments

Comments
 (0)