Skip to content

Commit e5f679f

Browse files
feat(api): SDKs for vector store file batches apis
1 parent 2060878 commit e5f679f

File tree

8 files changed

+789
-3
lines changed

8 files changed

+789
-3
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 102
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-3c569913f686c852ab392d470b9d905cc944d5a46a2324a21aa1376fb24e6714.yml
3-
openapi_spec_hash: 455f397c5f401ea425a4064bb39c6801
1+
configured_endpoints: 109
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-05bb7b0636a86ad0b485a5f2abfbd6b9e1873e802235f340af291f9ad9fb03b3.yml
3+
openapi_spec_hash: a78c30e308bc39473ea8e9ae9d0b726c
44
config_hash: 53c09ba1fdae5045de1860c479a51dc7

api.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ Response Types:
325325

326326
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFile">VectorStoreFile</a>
327327
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileDeleteResponse">VectorStoreFileDeleteResponse</a>
328+
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileContentResponse">VectorStoreFileContentResponse</a>
328329

329330
Methods:
330331

@@ -333,9 +334,22 @@ Methods:
333334
- <code title="post /v1/vector_stores/{vector_store_id}/files/{file_id}">client.VectorStores.Files.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, fileID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileUpdateParams">VectorStoreFileUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFile">VectorStoreFile</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
334335
- <code title="get /v1/vector_stores/{vector_store_id}/files">client.VectorStores.Files.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, vectorStoreID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileListParams">VectorStoreFileListParams</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go/packages/pagination#OpenAICursorPage">OpenAICursorPage</a>[<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFile">VectorStoreFile</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
335336
- <code title="delete /v1/vector_stores/{vector_store_id}/files/{file_id}">client.VectorStores.Files.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, fileID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileDeleteParams">VectorStoreFileDeleteParams</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileDeleteResponse">VectorStoreFileDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
337+
- <code title="get /v1/vector_stores/{vector_store_id}/files/{file_id}/content">client.VectorStores.Files.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileService.Content">Content</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, fileID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileContentParams">VectorStoreFileContentParams</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileContentResponse">VectorStoreFileContentResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
336338

337339
## FileBatches
338340

341+
Response Types:
342+
343+
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#ListVectorStoreFilesInBatchResponse">ListVectorStoreFilesInBatchResponse</a>
344+
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileBatches">VectorStoreFileBatches</a>
345+
346+
Methods:
347+
348+
- <code title="post /v1/vector_stores/{vector_store_id}/file_batches">client.VectorStores.FileBatches.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileBatchService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, vectorStoreID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileBatchNewParams">VectorStoreFileBatchNewParams</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileBatches">VectorStoreFileBatches</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
349+
- <code title="get /v1/vector_stores/{vector_store_id}/file_batches/{batch_id}">client.VectorStores.FileBatches.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileBatchService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, batchID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileBatchGetParams">VectorStoreFileBatchGetParams</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileBatches">VectorStoreFileBatches</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
350+
- <code title="get /v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/files">client.VectorStores.FileBatches.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileBatchService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, batchID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileBatchListParams">VectorStoreFileBatchListParams</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go/packages/pagination#OpenAICursorPage">OpenAICursorPage</a>[<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFile">VectorStoreFile</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
351+
- <code title="post /v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel">client.VectorStores.FileBatches.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileBatchService.Cancel">Cancel</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, batchID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileBatchCancelParams">VectorStoreFileBatchCancelParams</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#VectorStoreFileBatches">VectorStoreFileBatches</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
352+
339353
# Models
340354

341355
Response Types:
@@ -525,12 +539,15 @@ Methods:
525539

526540
Response Types:
527541

542+
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#DeleteFileResponse">DeleteFileResponse</a>
528543
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#File">File</a>
529544
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#ListFilesResponse">ListFilesResponse</a>
530545
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#FileContentResponse">FileContentResponse</a>
531546

532547
Methods:
533548

534549
- <code title="post /v1/files">client.Files.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#FileService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#FileNewParams">FileNewParams</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#File">File</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
550+
- <code title="get /v1/files/{file_id}">client.Files.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#FileService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, fileID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#File">File</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
535551
- <code title="get /v1/files">client.Files.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#FileService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#FileListParams">FileListParams</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go/packages/pagination#OpenAICursorPage">OpenAICursorPage</a>[<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#File">File</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
552+
- <code title="delete /v1/files/{file_id}">client.Files.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#FileService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, fileID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#DeleteFileResponse">DeleteFileResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
536553
- <code title="get /v1/files/{file_id}/content">client.Files.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#FileService.Content">Content</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, fileID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#FileContentResponse">FileContentResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

file.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ func (r *FileService) New(ctx context.Context, body FileNewParams, opts ...optio
5656
return
5757
}
5858

59+
// Returns information about a specific file.
60+
func (r *FileService) Get(ctx context.Context, fileID string, opts ...option.RequestOption) (res *File, err error) {
61+
opts = slices.Concat(r.Options, opts)
62+
if fileID == "" {
63+
err = errors.New("missing required file_id parameter")
64+
return
65+
}
66+
path := fmt.Sprintf("v1/files/%s", fileID)
67+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
68+
return
69+
}
70+
5971
// Returns a list of files that belong to the user's organization.
6072
func (r *FileService) List(ctx context.Context, query FileListParams, opts ...option.RequestOption) (res *pagination.OpenAICursorPage[File], err error) {
6173
var raw *http.Response
@@ -79,6 +91,18 @@ func (r *FileService) ListAutoPaging(ctx context.Context, query FileListParams,
7991
return pagination.NewOpenAICursorPageAutoPager(r.List(ctx, query, opts...))
8092
}
8193

94+
// Delete a file.
95+
func (r *FileService) Delete(ctx context.Context, fileID string, opts ...option.RequestOption) (res *DeleteFileResponse, err error) {
96+
opts = slices.Concat(r.Options, opts)
97+
if fileID == "" {
98+
err = errors.New("missing required file_id parameter")
99+
return
100+
}
101+
path := fmt.Sprintf("v1/files/%s", fileID)
102+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
103+
return
104+
}
105+
82106
// Returns the contents of the specified file.
83107
func (r *FileService) Content(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileContentResponse, err error) {
84108
opts = slices.Concat(r.Options, opts)
@@ -91,6 +115,30 @@ func (r *FileService) Content(ctx context.Context, fileID string, opts ...option
91115
return
92116
}
93117

118+
// Response for deleting a file in OpenAI Files API.
119+
type DeleteFileResponse struct {
120+
// The file identifier that was deleted
121+
ID string `json:"id,required"`
122+
// Whether the file was successfully deleted
123+
Deleted bool `json:"deleted,required"`
124+
// The object type, which is always "file"
125+
Object constant.File `json:"object,required"`
126+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
127+
JSON struct {
128+
ID respjson.Field
129+
Deleted respjson.Field
130+
Object respjson.Field
131+
ExtraFields map[string]respjson.Field
132+
raw string
133+
} `json:"-"`
134+
}
135+
136+
// Returns the unmodified JSON received from the API
137+
func (r DeleteFileResponse) RawJSON() string { return r.JSON.raw }
138+
func (r *DeleteFileResponse) UnmarshalJSON(data []byte) error {
139+
return apijson.UnmarshalRoot(data, r)
140+
}
141+
94142
// OpenAI File object as defined in the OpenAI Files API.
95143
type File struct {
96144
// The file identifier, which can be referenced in the API endpoints

file_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,27 @@ func TestFileNewWithOptionalParams(t *testing.T) {
4242
}
4343
}
4444

45+
func TestFileGet(t *testing.T) {
46+
baseURL := "http://localhost:4010"
47+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
48+
baseURL = envURL
49+
}
50+
if !testutil.CheckTestServer(t, baseURL) {
51+
return
52+
}
53+
client := llamastackclient.NewClient(
54+
option.WithBaseURL(baseURL),
55+
)
56+
_, err := client.Files.Get(context.TODO(), "file_id")
57+
if err != nil {
58+
var apierr *llamastackclient.Error
59+
if errors.As(err, &apierr) {
60+
t.Log(string(apierr.DumpRequest(true)))
61+
}
62+
t.Fatalf("err should be nil: %s", err.Error())
63+
}
64+
}
65+
4566
func TestFileListWithOptionalParams(t *testing.T) {
4667
baseURL := "http://localhost:4010"
4768
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -68,6 +89,27 @@ func TestFileListWithOptionalParams(t *testing.T) {
6889
}
6990
}
7091

92+
func TestFileDelete(t *testing.T) {
93+
baseURL := "http://localhost:4010"
94+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
95+
baseURL = envURL
96+
}
97+
if !testutil.CheckTestServer(t, baseURL) {
98+
return
99+
}
100+
client := llamastackclient.NewClient(
101+
option.WithBaseURL(baseURL),
102+
)
103+
_, err := client.Files.Delete(context.TODO(), "file_id")
104+
if err != nil {
105+
var apierr *llamastackclient.Error
106+
if errors.As(err, &apierr) {
107+
t.Log(string(apierr.DumpRequest(true)))
108+
}
109+
t.Fatalf("err should be nil: %s", err.Error())
110+
}
111+
}
112+
71113
func TestFileContent(t *testing.T) {
72114
baseURL := "http://localhost:4010"
73115
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {

0 commit comments

Comments
 (0)