diff --git a/.release-please-manifest.json b/.release-please-manifest.json index de2352fe..50b34035 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.52" + ".": "0.1.0-alpha.53" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 9a2cd3b2..a411158d 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-6204952a29973265b9c0d66fc67ffaf53c6a90ae4d75cdacf9d147676f5274c9.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-fc5dbc19505b0035f9e7f88868619f4fb519b048bde011f6154f3132d4be71fb.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 25968fab..477a0819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## 0.1.0-alpha.53 (2025-02-05) + +Full Changelog: [v0.1.0-alpha.52...v0.1.0-alpha.53](https://github.com/openai/openai-go/compare/v0.1.0-alpha.52...v0.1.0-alpha.53) + +### Bug Fixes + +* **api/types:** correct audio duration & role types ([#209](https://github.com/openai/openai-go/issues/209)) ([bb8cc1a](https://github.com/openai/openai-go/commit/bb8cc1a938ba142068261170d7c82a445c2f0c6c)) + + +### Chores + +* **api:** delete deprecated method ([#208](https://github.com/openai/openai-go/issues/208)) ([0a927ba](https://github.com/openai/openai-go/commit/0a927ba16dfc5cde2a368e8a1040f5ba3cda7708)) +* **docs:** add docstring explaining streaming pattern ([#205](https://github.com/openai/openai-go/issues/205)) ([0bdb37f](https://github.com/openai/openai-go/commit/0bdb37f7efd9b338c32a1a83b90cecdb74f8ecce)) + + +### Documentation + +* **examples:** fix typo ([#207](https://github.com/openai/openai-go/issues/207)) ([05796de](https://github.com/openai/openai-go/commit/05796de39d3c1c88251fc42674bec1a53730c3d2)) + ## 0.1.0-alpha.52 (2025-02-03) Full Changelog: [v0.1.0-alpha.51...v0.1.0-alpha.52](https://github.com/openai/openai-go/compare/v0.1.0-alpha.51...v0.1.0-alpha.52) diff --git a/README.md b/README.md index 4b54e193..efbf8be8 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Or to pin the version: ```sh -go get -u 'github.com/openai/openai-go@v0.1.0-alpha.52' +go get -u 'github.com/openai/openai-go@v0.1.0-alpha.53' ``` diff --git a/api.md b/api.md index 18eae07d..306b7933 100644 --- a/api.md +++ b/api.md @@ -95,7 +95,6 @@ Params Types: Response Types: -- openai.FileContent - openai.FileDeleted - openai.FileObject @@ -106,7 +105,6 @@ Methods: - client.Files.List(ctx context.Context, query openai.FileListParams) (pagination.CursorPage[openai.FileObject], error) - client.Files.Delete(ctx context.Context, fileID string) (openai.FileDeleted, error) - client.Files.Content(ctx context.Context, fileID string) (http.Response, error) -- client.Files.GetContent(ctx context.Context, fileID string) (openai.FileContent, error) # Images diff --git a/chatcompletion.go b/chatcompletion.go index 9e8681da..039c4021 100644 --- a/chatcompletion.go +++ b/chatcompletion.go @@ -685,6 +685,7 @@ func (r chatCompletionChunkChoicesDeltaFunctionCallJSON) RawJSON() string { type ChatCompletionChunkChoicesDeltaRole string const ( + ChatCompletionChunkChoicesDeltaRoleDeveloper ChatCompletionChunkChoicesDeltaRole = "developer" ChatCompletionChunkChoicesDeltaRoleSystem ChatCompletionChunkChoicesDeltaRole = "system" ChatCompletionChunkChoicesDeltaRoleUser ChatCompletionChunkChoicesDeltaRole = "user" ChatCompletionChunkChoicesDeltaRoleAssistant ChatCompletionChunkChoicesDeltaRole = "assistant" @@ -693,7 +694,7 @@ const ( func (r ChatCompletionChunkChoicesDeltaRole) IsKnown() bool { switch r { - case ChatCompletionChunkChoicesDeltaRoleSystem, ChatCompletionChunkChoicesDeltaRoleUser, ChatCompletionChunkChoicesDeltaRoleAssistant, ChatCompletionChunkChoicesDeltaRoleTool: + case ChatCompletionChunkChoicesDeltaRoleDeveloper, ChatCompletionChunkChoicesDeltaRoleSystem, ChatCompletionChunkChoicesDeltaRoleUser, ChatCompletionChunkChoicesDeltaRoleAssistant, ChatCompletionChunkChoicesDeltaRoleTool: return true } return false diff --git a/examples/chat-completion-tool-calling/main.go b/examples/chat-completion-tool-calling/main.go index d82a77a7..9607ed95 100644 --- a/examples/chat-completion-tool-calling/main.go +++ b/examples/chat-completion-tool-calling/main.go @@ -58,7 +58,7 @@ func main() { return } - // If there is a was a function call, continue the conversation + // If there is a function call, continue the conversation params.Messages.Value = append(params.Messages.Value, completion.Choices[0].Message) for _, toolCall := range toolCalls { if toolCall.Function.Name == "get_weather" { diff --git a/file.go b/file.go index 7f9ede58..b03ade4c 100644 --- a/file.go +++ b/file.go @@ -128,22 +128,6 @@ func (r *FileService) Content(ctx context.Context, fileID string, opts ...option return } -// Returns the contents of the specified file. -// -// Deprecated: The `.content()` method should be used instead -func (r *FileService) GetContent(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileContent, err error) { - opts = append(r.Options[:], opts...) - if fileID == "" { - err = errors.New("missing required file_id parameter") - return - } - path := fmt.Sprintf("files/%s/content", fileID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -type FileContent = string - type FileDeleted struct { ID string `json:"id,required"` Deleted bool `json:"deleted,required"` diff --git a/file_test.go b/file_test.go index bd6a2c38..aec6f07a 100644 --- a/file_test.go +++ b/file_test.go @@ -146,25 +146,3 @@ func TestFileContent(t *testing.T) { t.Fatalf("return value not %s: %s", "abc", b) } } - -func TestFileGetContent(t *testing.T) { - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := openai.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("My API Key"), - ) - _, err := client.Files.GetContent(context.TODO(), "file_id") - if err != nil { - var apierr *openai.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} diff --git a/internal/version.go b/internal/version.go index 279513f5..c33cc6a0 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.1.0-alpha.52" // x-release-please-version +const PackageVersion = "0.1.0-alpha.53" // x-release-please-version diff --git a/packages/ssestream/ssestream.go b/packages/ssestream/ssestream.go index 3c6cc319..d927149b 100644 --- a/packages/ssestream/ssestream.go +++ b/packages/ssestream/ssestream.go @@ -131,6 +131,17 @@ func NewStream[T any](decoder Decoder, err error) *Stream[T] { } } +// Next returns false if the stream has ended or an error occurred. +// Call Stream.Current() to get the current value. +// Call Stream.Err() to get the error. +// +// for stream.Next() { +// data := stream.Current() +// } +// +// if stream.Err() != nil { +// ... +// } func (s *Stream[T]) Next() bool { if s.err != nil { return false