diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b5db7ce..c373724 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.7" + ".": "0.1.0-alpha.8" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 2371b7b..185585b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 68 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-285bce7dcdae7eea5fe84a8d6e5af2c1473d65ea193109370fb2257851eef7eb.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-8ff62fa1091460d68fbd36d72c17d91b709917bebf2983c9c4de5784bc384a2e.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 5505319..d1820e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.8 (2024-08-15) + +Full Changelog: [v0.1.0-alpha.7...v0.1.0-alpha.8](https://github.com/openai/openai-go/compare/v0.1.0-alpha.7...v0.1.0-alpha.8) + +### Chores + +* **types:** define FilePurpose enum ([#22](https://github.com/openai/openai-go/issues/22)) ([2a7c699](https://github.com/openai/openai-go/commit/2a7c699e4fb21f848aa5d260da9d2a5c471866d1)) + ## 0.1.0-alpha.7 (2024-08-12) Full Changelog: [v0.1.0-alpha.6...v0.1.0-alpha.7](https://github.com/openai/openai-go/compare/v0.1.0-alpha.6...v0.1.0-alpha.7) diff --git a/README.md b/README.md index 6b5bb47..aa4ecdb 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Or to pin the version: ```sh -go get -u 'github.com/openai/openai-go@v0.1.0-alpha.7' +go get -u 'github.com/openai/openai-go@v0.1.0-alpha.8' ``` @@ -263,19 +263,19 @@ which can be used to wrap any `io.Reader` with the appropriate file name and con file, err := os.Open("input.jsonl") openai.FileNewParams{ File: openai.F[io.Reader](file), - Purpose: openai.F(openai.FileNewParamsPurposeFineTune), + Purpose: openai.F(openai.FilePurposeFineTune), } // A file from a string openai.FileNewParams{ File: openai.F[io.Reader](strings.NewReader("my file contents")), - Purpose: openai.F(openai.FileNewParamsPurposeFineTune), + Purpose: openai.F(openai.FilePurposeFineTune), } // With a custom filename and contentType openai.FileNewParams{ File: openai.FileParam(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"), - Purpose: openai.F(openai.FileNewParamsPurposeFineTune), + Purpose: openai.F(openai.FilePurposeFineTune), } ``` diff --git a/api.md b/api.md index ecec90f..4c35934 100644 --- a/api.md +++ b/api.md @@ -76,6 +76,10 @@ Methods: # Files +Params Types: + +- openai.FilePurpose + Response Types: - openai.FileDeleted diff --git a/file.go b/file.go index 25d90bb..30dde49 100644 --- a/file.go +++ b/file.go @@ -269,6 +269,31 @@ func (r FileObjectStatus) IsKnown() bool { return false } +// The intended purpose of the uploaded file. +// +// Use "assistants" for +// [Assistants](https://platform.openai.com/docs/api-reference/assistants) and +// [Message](https://platform.openai.com/docs/api-reference/messages) files, +// "vision" for Assistants image file inputs, "batch" for +// [Batch API](https://platform.openai.com/docs/guides/batch), and "fine-tune" for +// [Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning). +type FilePurpose string + +const ( + FilePurposeAssistants FilePurpose = "assistants" + FilePurposeBatch FilePurpose = "batch" + FilePurposeFineTune FilePurpose = "fine-tune" + FilePurposeVision FilePurpose = "vision" +) + +func (r FilePurpose) IsKnown() bool { + switch r { + case FilePurposeAssistants, FilePurposeBatch, FilePurposeFineTune, FilePurposeVision: + return true + } + return false +} + type FileNewParams struct { // The File object (not file name) to be uploaded. File param.Field[io.Reader] `json:"file,required" format:"binary"` @@ -280,7 +305,7 @@ type FileNewParams struct { // "vision" for Assistants image file inputs, "batch" for // [Batch API](https://platform.openai.com/docs/guides/batch), and "fine-tune" for // [Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning). - Purpose param.Field[FileNewParamsPurpose] `json:"purpose,required"` + Purpose param.Field[FilePurpose] `json:"purpose,required"` } func (r FileNewParams) MarshalMultipart() (data []byte, contentType string, err error) { @@ -298,31 +323,6 @@ func (r FileNewParams) MarshalMultipart() (data []byte, contentType string, err return buf.Bytes(), writer.FormDataContentType(), nil } -// The intended purpose of the uploaded file. -// -// Use "assistants" for -// [Assistants](https://platform.openai.com/docs/api-reference/assistants) and -// [Message](https://platform.openai.com/docs/api-reference/messages) files, -// "vision" for Assistants image file inputs, "batch" for -// [Batch API](https://platform.openai.com/docs/guides/batch), and "fine-tune" for -// [Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning). -type FileNewParamsPurpose string - -const ( - FileNewParamsPurposeAssistants FileNewParamsPurpose = "assistants" - FileNewParamsPurposeBatch FileNewParamsPurpose = "batch" - FileNewParamsPurposeFineTune FileNewParamsPurpose = "fine-tune" - FileNewParamsPurposeVision FileNewParamsPurpose = "vision" -) - -func (r FileNewParamsPurpose) IsKnown() bool { - switch r { - case FileNewParamsPurposeAssistants, FileNewParamsPurposeBatch, FileNewParamsPurposeFineTune, FileNewParamsPurposeVision: - return true - } - return false -} - type FileListParams struct { // Only return files with the given purpose. Purpose param.Field[string] `query:"purpose"` diff --git a/file_test.go b/file_test.go index c5b5557..588a561 100644 --- a/file_test.go +++ b/file_test.go @@ -31,7 +31,7 @@ func TestFileNew(t *testing.T) { ) _, err := client.Files.New(context.TODO(), openai.FileNewParams{ File: openai.F(io.Reader(bytes.NewBuffer([]byte("some file contents")))), - Purpose: openai.F(openai.FileNewParamsPurposeAssistants), + Purpose: openai.F(openai.FilePurposeAssistants), }) if err != nil { var apierr *openai.Error diff --git a/internal/version.go b/internal/version.go index c0909e1..64dcebb 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.1.0-alpha.7" // x-release-please-version +const PackageVersion = "0.1.0-alpha.8" // x-release-please-version diff --git a/upload.go b/upload.go index d39cbfd..fa5ebc4 100644 --- a/upload.go +++ b/upload.go @@ -193,34 +193,13 @@ type UploadNewParams struct { // // See the // [documentation on File purposes](https://platform.openai.com/docs/api-reference/files/create#files-create-purpose). - Purpose param.Field[UploadNewParamsPurpose] `json:"purpose,required"` + Purpose param.Field[FilePurpose] `json:"purpose,required"` } func (r UploadNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// The intended purpose of the uploaded file. -// -// See the -// [documentation on File purposes](https://platform.openai.com/docs/api-reference/files/create#files-create-purpose). -type UploadNewParamsPurpose string - -const ( - UploadNewParamsPurposeAssistants UploadNewParamsPurpose = "assistants" - UploadNewParamsPurposeBatch UploadNewParamsPurpose = "batch" - UploadNewParamsPurposeFineTune UploadNewParamsPurpose = "fine-tune" - UploadNewParamsPurposeVision UploadNewParamsPurpose = "vision" -) - -func (r UploadNewParamsPurpose) IsKnown() bool { - switch r { - case UploadNewParamsPurposeAssistants, UploadNewParamsPurposeBatch, UploadNewParamsPurposeFineTune, UploadNewParamsPurposeVision: - return true - } - return false -} - type UploadCompleteParams struct { // The ordered list of Part IDs. PartIDs param.Field[[]string] `json:"part_ids,required"` diff --git a/upload_test.go b/upload_test.go index 43d5d2e..e19a277 100644 --- a/upload_test.go +++ b/upload_test.go @@ -29,7 +29,7 @@ func TestUploadNew(t *testing.T) { Bytes: openai.F(int64(0)), Filename: openai.F("filename"), MimeType: openai.F("mime_type"), - Purpose: openai.F(openai.UploadNewParamsPurposeAssistants), + Purpose: openai.F(openai.FilePurposeAssistants), }) if err != nil { var apierr *openai.Error