Skip to content

Commit e215e25

Browse files
committed
feat: add s3 provider to files API
Signed-off-by: Sébastien Han <[email protected]>
1 parent 68eeace commit e215e25

File tree

14 files changed

+494
-147
lines changed

14 files changed

+494
-147
lines changed

docs/_static/llama-stack-spec.html

Lines changed: 35 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,11 @@
501501
"get": {
502502
"responses": {
503503
"200": {
504-
"description": "OK",
504+
"description": "PaginatedResponse with the list of buckets",
505505
"content": {
506506
"application/json": {
507507
"schema": {
508-
"$ref": "#/components/schemas/ListBucketResponse"
508+
"$ref": "#/components/schemas/PaginatedResponse"
509509
}
510510
}
511511
}
@@ -529,11 +529,21 @@
529529
"description": "List all buckets.",
530530
"parameters": [
531531
{
532-
"name": "bucket",
532+
"name": "page",
533533
"in": "query",
534-
"required": true,
534+
"description": "The page number (1-based). If None, starts from first page.",
535+
"required": false,
535536
"schema": {
536-
"type": "string"
537+
"type": "integer"
538+
}
539+
},
540+
{
541+
"name": "size",
542+
"in": "query",
543+
"description": "Number of items per page. If None or -1, returns all items.",
544+
"required": false,
545+
"schema": {
546+
"type": "integer"
537547
}
538548
}
539549
]
@@ -2503,11 +2513,11 @@
25032513
"get": {
25042514
"responses": {
25052515
"200": {
2506-
"description": "OK",
2516+
"description": "PaginatedResponse with the list of files",
25072517
"content": {
25082518
"application/json": {
25092519
"schema": {
2510-
"$ref": "#/components/schemas/ListFileResponse"
2520+
"$ref": "#/components/schemas/PaginatedResponse"
25112521
}
25122522
}
25132523
}
@@ -2538,6 +2548,24 @@
25382548
"schema": {
25392549
"type": "string"
25402550
}
2551+
},
2552+
{
2553+
"name": "page",
2554+
"in": "query",
2555+
"description": "The page number (1-based). If None, starts from first page.",
2556+
"required": false,
2557+
"schema": {
2558+
"type": "integer"
2559+
}
2560+
},
2561+
{
2562+
"name": "size",
2563+
"in": "query",
2564+
"description": "Number of items per page. If None or -1, returns all items.",
2565+
"required": false,
2566+
"schema": {
2567+
"type": "integer"
2568+
}
25412569
}
25422570
]
25432571
}
@@ -8309,37 +8337,6 @@
83098337
],
83108338
"title": "ListAgentsResponse"
83118339
},
8312-
"BucketResponse": {
8313-
"type": "object",
8314-
"properties": {
8315-
"name": {
8316-
"type": "string"
8317-
}
8318-
},
8319-
"additionalProperties": false,
8320-
"required": [
8321-
"name"
8322-
],
8323-
"title": "BucketResponse"
8324-
},
8325-
"ListBucketResponse": {
8326-
"type": "object",
8327-
"properties": {
8328-
"data": {
8329-
"type": "array",
8330-
"items": {
8331-
"$ref": "#/components/schemas/BucketResponse"
8332-
},
8333-
"description": "List of FileResponse entries"
8334-
}
8335-
},
8336-
"additionalProperties": false,
8337-
"required": [
8338-
"data"
8339-
],
8340-
"title": "ListBucketResponse",
8341-
"description": "Response representing a list of file entries."
8342-
},
83438340
"ListBenchmarksResponse": {
83448341
"type": "object",
83458342
"properties": {
@@ -8372,24 +8369,6 @@
83728369
],
83738370
"title": "ListDatasetsResponse"
83748371
},
8375-
"ListFileResponse": {
8376-
"type": "object",
8377-
"properties": {
8378-
"data": {
8379-
"type": "array",
8380-
"items": {
8381-
"$ref": "#/components/schemas/FileResponse"
8382-
},
8383-
"description": "List of FileResponse entries"
8384-
}
8385-
},
8386-
"additionalProperties": false,
8387-
"required": [
8388-
"data"
8389-
],
8390-
"title": "ListFileResponse",
8391-
"description": "Response representing a list of file entries."
8392-
},
83938372
"ListModelsResponse": {
83948373
"type": "object",
83958374
"properties": {

docs/_static/llama-stack-spec.yaml

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,12 @@ paths:
334334
get:
335335
responses:
336336
'200':
337-
description: OK
337+
description: >-
338+
PaginatedResponse with the list of buckets
338339
content:
339340
application/json:
340341
schema:
341-
$ref: '#/components/schemas/ListBucketResponse'
342+
$ref: '#/components/schemas/PaginatedResponse'
342343
'400':
343344
$ref: '#/components/responses/BadRequest400'
344345
'429':
@@ -353,11 +354,20 @@ paths:
353354
- Files
354355
description: List all buckets.
355356
parameters:
356-
- name: bucket
357+
- name: page
357358
in: query
358-
required: true
359+
description: >-
360+
The page number (1-based). If None, starts from first page.
361+
required: false
359362
schema:
360-
type: string
363+
type: integer
364+
- name: size
365+
in: query
366+
description: >-
367+
Number of items per page. If None or -1, returns all items.
368+
required: false
369+
schema:
370+
type: integer
361371
post:
362372
responses:
363373
'200':
@@ -1727,11 +1737,11 @@ paths:
17271737
get:
17281738
responses:
17291739
'200':
1730-
description: OK
1740+
description: PaginatedResponse with the list of files
17311741
content:
17321742
application/json:
17331743
schema:
1734-
$ref: '#/components/schemas/ListFileResponse'
1744+
$ref: '#/components/schemas/PaginatedResponse'
17351745
'400':
17361746
$ref: '#/components/responses/BadRequest400'
17371747
'429':
@@ -1752,6 +1762,20 @@ paths:
17521762
required: true
17531763
schema:
17541764
type: string
1765+
- name: page
1766+
in: query
1767+
description: >-
1768+
The page number (1-based). If None, starts from first page.
1769+
required: false
1770+
schema:
1771+
type: integer
1772+
- name: size
1773+
in: query
1774+
description: >-
1775+
Number of items per page. If None or -1, returns all items.
1776+
required: false
1777+
schema:
1778+
type: integer
17551779
/v1/models:
17561780
get:
17571781
responses:
@@ -5706,29 +5730,6 @@ components:
57065730
required:
57075731
- data
57085732
title: ListAgentsResponse
5709-
BucketResponse:
5710-
type: object
5711-
properties:
5712-
name:
5713-
type: string
5714-
additionalProperties: false
5715-
required:
5716-
- name
5717-
title: BucketResponse
5718-
ListBucketResponse:
5719-
type: object
5720-
properties:
5721-
data:
5722-
type: array
5723-
items:
5724-
$ref: '#/components/schemas/BucketResponse'
5725-
description: List of FileResponse entries
5726-
additionalProperties: false
5727-
required:
5728-
- data
5729-
title: ListBucketResponse
5730-
description: >-
5731-
Response representing a list of file entries.
57325733
ListBenchmarksResponse:
57335734
type: object
57345735
properties:
@@ -5751,20 +5752,6 @@ components:
57515752
required:
57525753
- data
57535754
title: ListDatasetsResponse
5754-
ListFileResponse:
5755-
type: object
5756-
properties:
5757-
data:
5758-
type: array
5759-
items:
5760-
$ref: '#/components/schemas/FileResponse'
5761-
description: List of FileResponse entries
5762-
additionalProperties: false
5763-
required:
5764-
- data
5765-
title: ListFileResponse
5766-
description: >-
5767-
Response representing a list of file entries.
57685755
ListModelsResponse:
57695756
type: object
57705757
properties:

docs/source/distributions/self_hosted_distro/ollama.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The `llamastack/distribution-ollama` distribution consists of the following prov
1818
| agents | `inline::meta-reference` |
1919
| datasetio | `remote::huggingface`, `inline::localfs` |
2020
| eval | `inline::meta-reference` |
21+
| files | `remote::s3` |
2122
| inference | `remote::ollama` |
2223
| safety | `inline::llama-guard` |
2324
| scoring | `inline::basic`, `inline::llm-as-judge`, `inline::braintrust` |
@@ -36,6 +37,12 @@ The following environment variables can be configured:
3637
- `OLLAMA_URL`: URL of the Ollama server (default: `http://127.0.0.1:11434`)
3738
- `INFERENCE_MODEL`: Inference model loaded into the Ollama server (default: `meta-llama/Llama-3.2-3B-Instruct`)
3839
- `SAFETY_MODEL`: Safety model loaded into the Ollama server (default: `meta-llama/Llama-Guard-3-1B`)
40+
- `AWS_ACCESS_KEY_ID`: AWS access key ID for S3 access (default: ``)
41+
- `AWS_SECRET_ACCESS_KEY`: AWS secret access key for S3 access (default: ``)
42+
- `AWS_REGION_NAME`: AWS region name for S3 access (default: ``)
43+
- `AWS_ENDPOINT_URL`: AWS endpoint URL for S3 access (for custom endpoints) (default: ``)
44+
- `AWS_BUCKET_NAME`: AWS bucket name for S3 access (default: ``)
45+
- `AWS_VERIFY_TLS`: Whether to verify TLS for S3 connections (default: `true`)
3946

4047

4148
## Setting up Ollama server

llama_stack/apis/files/files.py

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
# This source code is licensed under the terms described in the LICENSE file in
55
# the root directory of this source tree.
66

7-
from typing import List, Optional, Protocol, runtime_checkable
7+
from typing import Optional, Protocol, runtime_checkable
88

99
from pydantic import BaseModel
1010

11+
from llama_stack.apis.common.responses import PaginatedResponse
1112
from llama_stack.providers.utils.telemetry.trace_protocol import trace_protocol
1213
from llama_stack.schema_utils import json_schema_type, webmethod
1314

@@ -34,17 +35,6 @@ class BucketResponse(BaseModel):
3435
name: str
3536

3637

37-
@json_schema_type
38-
class ListBucketResponse(BaseModel):
39-
"""
40-
Response representing a list of file entries.
41-
42-
:param data: List of FileResponse entries
43-
"""
44-
45-
data: List[BucketResponse]
46-
47-
4838
@json_schema_type
4939
class FileResponse(BaseModel):
5040
"""
@@ -66,17 +56,6 @@ class FileResponse(BaseModel):
6656
created_at: int
6757

6858

69-
@json_schema_type
70-
class ListFileResponse(BaseModel):
71-
"""
72-
Response representing a list of file entries.
73-
74-
:param data: List of FileResponse entries
75-
"""
76-
77-
data: List[FileResponse]
78-
79-
8059
@runtime_checkable
8160
@trace_protocol
8261
class Files(Protocol):
@@ -126,22 +105,32 @@ async def get_upload_session_info(
126105
@webmethod(route="/files", method="GET")
127106
async def list_all_buckets(
128107
self,
129-
bucket: str,
130-
) -> ListBucketResponse:
108+
page: Optional[int] = None,
109+
size: Optional[int] = None,
110+
) -> PaginatedResponse:
131111
"""
132112
List all buckets.
113+
114+
:param page: The page number (1-based). If None, starts from first page.
115+
:param size: Number of items per page. If None or -1, returns all items.
116+
:return: PaginatedResponse with the list of buckets
133117
"""
134118
...
135119

136120
@webmethod(route="/files/{bucket}", method="GET")
137121
async def list_files_in_bucket(
138122
self,
139123
bucket: str,
140-
) -> ListFileResponse:
124+
page: Optional[int] = None,
125+
size: Optional[int] = None,
126+
) -> PaginatedResponse:
141127
"""
142128
List all files in a bucket.
143129
144130
:param bucket: Bucket name (valid chars: a-zA-Z0-9_-)
131+
:param page: The page number (1-based). If None, starts from first page.
132+
:param size: Number of items per page. If None or -1, returns all items.
133+
:return: PaginatedResponse with the list of files
145134
"""
146135
...
147136

0 commit comments

Comments
 (0)