riffer 0.24.0 → 0.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd2f811bba1934e2285de7f4ec122259039dcb61f6d6141e3c26992d38ba2e07
4
- data.tar.gz: 877941ede9824184db9e7eb99ee901096995298937033f65c87562afeec7d208
3
+ metadata.gz: c289127e9ee54b63afe3ca65349054459f906553e37d39cf5001c6876ee6b1e9
4
+ data.tar.gz: 22e8286f74b98f23d00e49c6c337bcba9c68f452763be082533fb0f082688632
5
5
  SHA512:
6
- metadata.gz: 2477d9fcba22f212f7a83b6e7a400476aa7e4cc7c842d631d9044d7771827fcf903355f4015d9fa357e752ceb41a26fcfd62afd3711134c61a9745c3005dfe3c
7
- data.tar.gz: d06abbd9da19f04cfc97449e72f283297ae07ab5dface13119c92cdf2121515c1de83ed6992daa1ab49ec460e15c5afaf4883b4224c9ed7c838f64b7f9ca816a
6
+ metadata.gz: f2e75464955df9f0fd7dd1d57eef8b54a763d77d8d80ba46ff0bc2c3e11c8fa258de633ff5288551be299d8a92b10c99419ab95acdcb86683f9fb1ca0331ead2
7
+ data.tar.gz: ce4a3e9ee805e074142a02a84ceb6089be539fb22d0a4d141de4eef43d8b9a0843f931ab05298571c79e933f1d1a6336c4f8b3ea443da403485e46a001d4dc45
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.24.0"
2
+ ".": "0.24.2"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.24.2](https://github.com/janeapp/riffer/compare/riffer/v0.24.1...riffer/v0.24.2) (2026-04-23)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **providers:** surface Bedrock stream errors and concat text blocks ([#222](https://github.com/janeapp/riffer/issues/222)) ([d30421e](https://github.com/janeapp/riffer/commit/d30421e48ed50e6517b834aa7281ee5349d66309))
14
+
15
+ ## [0.24.1](https://github.com/janeapp/riffer/compare/riffer/v0.24.0...riffer/v0.24.1) (2026-04-23)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * disable gzip on Anthropic stream to avoid SSE buffering ([#220](https://github.com/janeapp/riffer/issues/220)) ([ee2aaca](https://github.com/janeapp/riffer/commit/ee2aaca06eaefb12e5b6cbc3bde48ba8f3ea4ee8))
21
+
8
22
  ## [0.24.0](https://github.com/janeapp/riffer/compare/riffer/v0.23.0...riffer/v0.24.0) (2026-04-20)
9
23
 
10
24
 
@@ -102,7 +102,7 @@ class Riffer::Providers::AmazonBedrock < Riffer::Providers::Base
102
102
  text_content = ""
103
103
 
104
104
  content_blocks.each do |block|
105
- text_content = block.text if block.respond_to?(:text) && block.text
105
+ text_content += block.text if block.respond_to?(:text) && block.text
106
106
  end
107
107
 
108
108
  text_content
@@ -139,22 +139,44 @@ class Riffer::Providers::AmazonBedrock < Riffer::Providers::Base
139
139
 
140
140
  @client.converse_stream(**params) do |stream|
141
141
  stream.on_event do |event|
142
- case event.event_type
143
- when :content_block_start
142
+ case event
143
+ when Aws::BedrockRuntime::Types::ContentBlockStartEvent
144
144
  handle_content_block_start_tool_use(event, state: current_state, yielder: yielder) if event.start&.tool_use
145
- when :content_block_delta
145
+ when Aws::BedrockRuntime::Types::ContentBlockDeltaEvent
146
146
  handle_content_block_delta_text_delta(event, state: current_state, yielder: yielder) if event.delta&.text
147
147
  handle_content_block_delta_tool_use(event, state: current_state, yielder: yielder) if event.delta&.tool_use
148
- when :content_block_stop
148
+ when Aws::BedrockRuntime::Types::ContentBlockStopEvent
149
149
  handle_content_block_stop_text_delta(event, state: current_state, yielder: yielder) if current_state[:text]
150
150
  handle_content_block_stop_tool_use(event, state: current_state, yielder: yielder) if current_state[:tool_call]
151
- when :metadata
151
+ when Aws::BedrockRuntime::Types::ConverseStreamMetadataEvent
152
152
  handle_metadata_usage(event, state: current_state, yielder: yielder) if event.usage
153
+ else
154
+ raise_if_stream_exception!(event)
153
155
  end
154
156
  end
155
157
  end
156
158
  end
157
159
 
160
+ # Re-raises a Bedrock stream exception event as the matching
161
+ # +Aws::BedrockRuntime::Errors+ service error. ConverseStream delivers API
162
+ # errors on the same channel as content, so without this a mid-stream
163
+ # failure would silently end the enumerator with no tokens or content.
164
+ #
165
+ # Detection is by class-name suffix: every Bedrock stream-exception struct
166
+ # is named +*Exception+ and has a matching +Aws::BedrockRuntime::Errors+
167
+ # class of the same name (generated via +DynamicErrors+ if not explicit).
168
+ # Non-exception events (e.g. +MessageStartEvent+) pass through silently.
169
+ #--
170
+ #: (untyped) -> void
171
+ def raise_if_stream_exception!(event)
172
+ klass_name = event.class.name&.split("::")&.last
173
+ return unless klass_name&.end_with?("Exception")
174
+
175
+ error_klass = Aws::BedrockRuntime::Errors.const_get(klass_name)
176
+ context = Seahorse::Client::RequestContext.new(operation_name: :converse_stream)
177
+ raise error_klass.new(context, event.message, event)
178
+ end
179
+
158
180
  #--
159
181
  #: (Aws::BedrockRuntime::Types::ContentBlockStartEvent, state: Hash[Symbol, untyped], yielder: Enumerator[Riffer::StreamEvents::Base, void]) -> void
160
182
  def handle_content_block_start_tool_use(event, state:, yielder:)
@@ -144,7 +144,12 @@ class Riffer::Providers::Anthropic < Riffer::Providers::Base
144
144
  web_search_query: nil
145
145
  }
146
146
 
147
- stream = @client.messages.stream(**params)
147
+ # Workaround for anthropics/anthropic-sdk-ruby#182: force identity
148
+ # encoding so Net::HTTP/Zlib doesn't buffer SSE chunks until EOF.
149
+ stream = @client.messages.stream(
150
+ **params,
151
+ request_options: {extra_headers: {"accept-encoding" => "identity"}}
152
+ )
148
153
  current_state[:stream] = stream
149
154
 
150
155
  stream.each do |event|
@@ -2,5 +2,5 @@
2
2
  # rbs_inline: enabled
3
3
 
4
4
  module Riffer
5
- VERSION = "0.24.0" #: String
5
+ VERSION = "0.24.2" #: String
6
6
  end
@@ -38,6 +38,19 @@ class Riffer::Providers::AmazonBedrock < Riffer::Providers::Base
38
38
  # : (Hash[Symbol, untyped], Enumerator::Yielder) -> void
39
39
  def execute_stream: (Hash[Symbol, untyped], Enumerator::Yielder) -> void
40
40
 
41
+ # Re-raises a Bedrock stream exception event as the matching
42
+ # +Aws::BedrockRuntime::Errors+ service error. ConverseStream delivers API
43
+ # errors on the same channel as content, so without this a mid-stream
44
+ # failure would silently end the enumerator with no tokens or content.
45
+ #
46
+ # Detection is by class-name suffix: every Bedrock stream-exception struct
47
+ # is named +*Exception+ and has a matching +Aws::BedrockRuntime::Errors+
48
+ # class of the same name (generated via +DynamicErrors+ if not explicit).
49
+ # Non-exception events (e.g. +MessageStartEvent+) pass through silently.
50
+ # --
51
+ # : (untyped) -> void
52
+ def raise_if_stream_exception!: (untyped) -> void
53
+
41
54
  # --
42
55
  # : (Aws::BedrockRuntime::Types::ContentBlockStartEvent, state: Hash[Symbol, untyped], yielder: Enumerator[Riffer::StreamEvents::Base, void]) -> void
43
56
  def handle_content_block_start_tool_use: (Aws::BedrockRuntime::Types::ContentBlockStartEvent, state: Hash[Symbol, untyped], yielder: Enumerator[Riffer::StreamEvents::Base, void]) -> void
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.24.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Bottrall