Skip to content

Commit d52bf88

Browse files
committed
Support undocumented Files filter
1 parent 9c5be63 commit d52bf88

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

files.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,25 @@ func (c *Client) ListFiles(ctx context.Context) (files FilesList, err error) {
147147
return
148148
}
149149

150+
// ListFilesForIDs Lists the files based on provided IDs.
151+
// WARNING: This is an undocumented API, used by the OpenAI platform UI. Consider it a hack.
152+
func (c *Client) ListFilesForIDs(ctx context.Context, fileIDs []string) (files FilesList, err error) {
153+
req, err := c.newRequest(ctx, http.MethodGet, c.fullURL("/files"))
154+
if err != nil {
155+
return
156+
}
157+
158+
reqQuery := req.URL.Query()
159+
for _, id := range fileIDs {
160+
reqQuery.Add("ids[]", id)
161+
}
162+
163+
req.URL.RawQuery = reqQuery.Encode()
164+
165+
err = c.sendRequest(req, &files)
166+
return
167+
}
168+
150169
// GetFile Retrieves a file instance, providing basic information about the file
151170
// such as the file name and purpose.
152171
func (c *Client) GetFile(ctx context.Context, fileID string) (file File, err error) {

0 commit comments

Comments
 (0)