Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.1.0-alpha.8 #23

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.7"
".": "0.1.0-alpha.8"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Or to pin the version:
<!-- x-release-please-start-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'
```

<!-- x-release-please-end -->
Expand Down Expand Up @@ -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),
}
```

Expand Down
4 changes: 4 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ Methods:

# Files

Params Types:

- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#FilePurpose">FilePurpose</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileDeleted">FileDeleted</a>
Expand Down
52 changes: 26 additions & 26 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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) {
Expand All @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 1 addition & 22 deletions upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading