From 73f93429e1319387f1a95208166b3e871ce4e03a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 19:21:26 +0000 Subject: [PATCH 1/2] feat: add support for error property in stream (#29) --- packages/ssestream/streaming.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/ssestream/streaming.go b/packages/ssestream/streaming.go index d9b4333..9fd59fd 100644 --- a/packages/ssestream/streaming.go +++ b/packages/ssestream/streaming.go @@ -6,9 +6,12 @@ import ( "bufio" "bytes" "encoding/json" + "fmt" "io" "net/http" "strings" + + "github.com/tidwall/gjson" ) type Decoder interface { @@ -144,6 +147,11 @@ func (s *Stream[T]) Next() bool { } if s.decoder.Event().Type == "" { + ep := gjson.GetBytes(s.decoder.Event().Data, "error") + if ep.Exists() { + s.err = fmt.Errorf("received error while streaming: %s", ep.String()) + return false + } s.err = json.Unmarshal(s.decoder.Event().Data, &s.cur) if s.err != nil { return false From 24977b07523451c67817ca1a7c1d1544ba0d80ab Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 19:21:42 +0000 Subject: [PATCH 2/2] release: 0.1.0-alpha.11 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ README.md | 2 +- internal/version.go | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3b005e5..ee49ac2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.10" + ".": "0.1.0-alpha.11" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c197264..b3666cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.11 (2024-08-22) + +Full Changelog: [v0.1.0-alpha.10...v0.1.0-alpha.11](https://github.com/openai/openai-go/compare/v0.1.0-alpha.10...v0.1.0-alpha.11) + +### Features + +* add support for error property in stream ([#29](https://github.com/openai/openai-go/issues/29)) ([73f9342](https://github.com/openai/openai-go/commit/73f93429e1319387f1a95208166b3e871ce4e03a)) + ## 0.1.0-alpha.10 (2024-08-21) Full Changelog: [v0.1.0-alpha.9...v0.1.0-alpha.10](https://github.com/openai/openai-go/compare/v0.1.0-alpha.9...v0.1.0-alpha.10) diff --git a/README.md b/README.md index bc5d1b6..1a104d5 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.10' +go get -u 'github.com/openai/openai-go@v0.1.0-alpha.11' ``` diff --git a/internal/version.go b/internal/version.go index 52822aa..dec22ba 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.1.0-alpha.10" // x-release-please-version +const PackageVersion = "0.1.0-alpha.11" // x-release-please-version