Skip to content

Commit 2060878

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

File tree

8 files changed

+36
-249
lines changed

8 files changed

+36
-249
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 105
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-d7bea816190382a93511491e33d1f37f707620926ab133ae8ce0883d763df741.yml
3-
openapi_spec_hash: f73b3af77108625edae3f25972b9e665
4-
config_hash: 548f336ac1b68ab1dfe385b79df764dd
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
4+
config_hash: 53c09ba1fdae5045de1860c479a51dc7

api.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ 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>
329328

330329
Methods:
331330

@@ -334,7 +333,8 @@ Methods:
334333
- <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>
335334
- <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>
336335
- <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>
336+
337+
## FileBatches
338338

339339
# Models
340340

@@ -525,15 +525,12 @@ Methods:
525525

526526
Response Types:
527527

528-
- <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>
529528
- <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>
530529
- <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>
531530
- <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>
532531

533532
Methods:
534533

535534
- <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>
536-
- <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>
537535
- <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>
538-
- <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>
539536
- <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: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,6 @@ 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-
7159
// Returns a list of files that belong to the user's organization.
7260
func (r *FileService) List(ctx context.Context, query FileListParams, opts ...option.RequestOption) (res *pagination.OpenAICursorPage[File], err error) {
7361
var raw *http.Response
@@ -91,18 +79,6 @@ func (r *FileService) ListAutoPaging(ctx context.Context, query FileListParams,
9179
return pagination.NewOpenAICursorPageAutoPager(r.List(ctx, query, opts...))
9280
}
9381

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-
10682
// Returns the contents of the specified file.
10783
func (r *FileService) Content(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileContentResponse, err error) {
10884
opts = slices.Concat(r.Options, opts)
@@ -115,30 +91,6 @@ func (r *FileService) Content(ctx context.Context, fileID string, opts ...option
11591
return
11692
}
11793

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-
14294
// OpenAI File object as defined in the OpenAI Files API.
14395
type File struct {
14496
// The file identifier, which can be referenced in the API endpoints

file_test.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,6 @@ 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-
6645
func TestFileListWithOptionalParams(t *testing.T) {
6746
baseURL := "http://localhost:4010"
6847
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -89,27 +68,6 @@ func TestFileListWithOptionalParams(t *testing.T) {
8968
}
9069
}
9170

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-
11371
func TestFileContent(t *testing.T) {
11472
baseURL := "http://localhost:4010"
11573
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {

vectorstore.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ import (
2828
// automatically. You should not instantiate this service directly, and instead use
2929
// the [NewVectorStoreService] method instead.
3030
type VectorStoreService struct {
31-
Options []option.RequestOption
32-
Files VectorStoreFileService
31+
Options []option.RequestOption
32+
Files VectorStoreFileService
33+
FileBatches VectorStoreFileBatchService
3334
}
3435

3536
// NewVectorStoreService generates a new service that applies the given options to
@@ -39,6 +40,7 @@ func NewVectorStoreService(opts ...option.RequestOption) (r VectorStoreService)
3940
r = VectorStoreService{}
4041
r.Options = opts
4142
r.Files = NewVectorStoreFileService(opts...)
43+
r.FileBatches = NewVectorStoreFileBatchService(opts...)
4244
return
4345
}
4446

vectorstorefile.go

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,6 @@ func (r *VectorStoreFileService) Delete(ctx context.Context, fileID string, body
127127
return
128128
}
129129

130-
// Retrieves the contents of a vector store file.
131-
func (r *VectorStoreFileService) Content(ctx context.Context, fileID string, query VectorStoreFileContentParams, opts ...option.RequestOption) (res *VectorStoreFileContentResponse, err error) {
132-
opts = slices.Concat(r.Options, opts)
133-
if query.VectorStoreID == "" {
134-
err = errors.New("missing required vector_store_id parameter")
135-
return
136-
}
137-
if fileID == "" {
138-
err = errors.New("missing required file_id parameter")
139-
return
140-
}
141-
path := fmt.Sprintf("v1/vector_stores/%s/files/%s/content", query.VectorStoreID, fileID)
142-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
143-
return
144-
}
145-
146130
// OpenAI Vector Store File object.
147131
type VectorStoreFile struct {
148132
// Unique identifier for the file
@@ -429,106 +413,6 @@ func (r *VectorStoreFileDeleteResponse) UnmarshalJSON(data []byte) error {
429413
return apijson.UnmarshalRoot(data, r)
430414
}
431415

432-
// Response from retrieving the contents of a vector store file.
433-
type VectorStoreFileContentResponse struct {
434-
// Key-value attributes associated with the file
435-
Attributes map[string]VectorStoreFileContentResponseAttributeUnion `json:"attributes,required"`
436-
// List of content items from the file
437-
Content []VectorStoreFileContentResponseContent `json:"content,required"`
438-
// Unique identifier for the file
439-
FileID string `json:"file_id,required"`
440-
// Name of the file
441-
Filename string `json:"filename,required"`
442-
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
443-
JSON struct {
444-
Attributes respjson.Field
445-
Content respjson.Field
446-
FileID respjson.Field
447-
Filename respjson.Field
448-
ExtraFields map[string]respjson.Field
449-
raw string
450-
} `json:"-"`
451-
}
452-
453-
// Returns the unmodified JSON received from the API
454-
func (r VectorStoreFileContentResponse) RawJSON() string { return r.JSON.raw }
455-
func (r *VectorStoreFileContentResponse) UnmarshalJSON(data []byte) error {
456-
return apijson.UnmarshalRoot(data, r)
457-
}
458-
459-
// VectorStoreFileContentResponseAttributeUnion contains all possible properties
460-
// and values from [bool], [float64], [string], [[]any].
461-
//
462-
// Use the methods beginning with 'As' to cast the union to one of its variants.
463-
//
464-
// If the underlying value is not a json object, one of the following properties
465-
// will be valid: OfBool OfFloat OfString OfAnyArray]
466-
type VectorStoreFileContentResponseAttributeUnion struct {
467-
// This field will be present if the value is a [bool] instead of an object.
468-
OfBool bool `json:",inline"`
469-
// This field will be present if the value is a [float64] instead of an object.
470-
OfFloat float64 `json:",inline"`
471-
// This field will be present if the value is a [string] instead of an object.
472-
OfString string `json:",inline"`
473-
// This field will be present if the value is a [[]any] instead of an object.
474-
OfAnyArray []any `json:",inline"`
475-
JSON struct {
476-
OfBool respjson.Field
477-
OfFloat respjson.Field
478-
OfString respjson.Field
479-
OfAnyArray respjson.Field
480-
raw string
481-
} `json:"-"`
482-
}
483-
484-
func (u VectorStoreFileContentResponseAttributeUnion) AsBool() (v bool) {
485-
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
486-
return
487-
}
488-
489-
func (u VectorStoreFileContentResponseAttributeUnion) AsFloat() (v float64) {
490-
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
491-
return
492-
}
493-
494-
func (u VectorStoreFileContentResponseAttributeUnion) AsString() (v string) {
495-
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
496-
return
497-
}
498-
499-
func (u VectorStoreFileContentResponseAttributeUnion) AsAnyArray() (v []any) {
500-
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
501-
return
502-
}
503-
504-
// Returns the unmodified JSON received from the API
505-
func (u VectorStoreFileContentResponseAttributeUnion) RawJSON() string { return u.JSON.raw }
506-
507-
func (r *VectorStoreFileContentResponseAttributeUnion) UnmarshalJSON(data []byte) error {
508-
return apijson.UnmarshalRoot(data, r)
509-
}
510-
511-
// Content item from a vector store file or search result.
512-
type VectorStoreFileContentResponseContent struct {
513-
// The actual text content
514-
Text string `json:"text,required"`
515-
// Content type, currently only "text" is supported
516-
Type constant.Text `json:"type,required"`
517-
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
518-
JSON struct {
519-
Text respjson.Field
520-
Type respjson.Field
521-
ExtraFields map[string]respjson.Field
522-
raw string
523-
} `json:"-"`
524-
}
525-
526-
// Returns the unmodified JSON received from the API
527-
func (r VectorStoreFileContentResponseContent) RawJSON() string { return r.JSON.raw }
528-
func (r *VectorStoreFileContentResponseContent) UnmarshalJSON(data []byte) error {
529-
return apijson.UnmarshalRoot(data, r)
530-
}
531-
532416
type VectorStoreFileNewParams struct {
533417
// The ID of the file to attach to the vector store.
534418
FileID string `json:"file_id,required"`
@@ -787,8 +671,3 @@ type VectorStoreFileDeleteParams struct {
787671
VectorStoreID string `path:"vector_store_id,required" json:"-"`
788672
paramObj
789673
}
790-
791-
type VectorStoreFileContentParams struct {
792-
VectorStoreID string `path:"vector_store_id,required" json:"-"`
793-
paramObj
794-
}

0 commit comments

Comments
 (0)