riffer 0.4.2 → 0.5.1
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 +4 -4
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +36 -29
- data/LICENSE.txt +1 -1
- data/README.md +6 -7
- data/lib/riffer/agent.rb +30 -1
- data/lib/riffer/providers/base.rb +0 -26
- data/lib/riffer/providers/open_ai.rb +6 -11
- data/lib/riffer/providers/repository.rb +15 -0
- data/lib/riffer/providers/test.rb +6 -5
- data/lib/riffer/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8b78c9eff3bd51ccab98e50b8adbee7c5aabd8b5da8fea825559c7a7b7783340
|
|
4
|
+
data.tar.gz: 605b9ab5ab96bf8f7b6af9083a955293931a0603875c6a17011a1249d4533948
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e80cf949f74dbb12d9e161525c4403cfa8f560333e322580f28f187a946c0c061acd47e92a68d328767819daeba4397639891d7f6585d3c095109824d6702638
|
|
7
|
+
data.tar.gz: 1f81bb4bd577b13d0e0c45c37d594012c340f13bf8e1bf59a34f88481cb6cecddd54078a51d1dae262982e73d8bcbbbe6fae030e61a3d7cc7a3c7ae3014ed39d
|
data/CHANGELOG.md
CHANGED
|
@@ -5,68 +5,75 @@ 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.
|
|
8
|
+
## [0.5.1](https://github.com/janeapp/riffer/compare/riffer/v0.5.0...riffer/v0.5.1) (2026-01-10)
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
### Bug Fixes
|
|
12
12
|
|
|
13
|
-
* update
|
|
13
|
+
* update Code of Conduct URL in README ([#67](https://github.com/janeapp/riffer/issues/67)) ([39ae1f5](https://github.com/janeapp/riffer/commit/39ae1f5025bcd36e1c5cab76fe8d312179f664ba))
|
|
14
|
+
* update gem details to reflect janeapp ownership ([#66](https://github.com/janeapp/riffer/issues/66)) ([06a008d](https://github.com/janeapp/riffer/commit/06a008d5ab050ca2c1afd4163104c6c95c9d248b))
|
|
15
|
+
* update GitHub Pages deployment action in release workflow ([#68](https://github.com/janeapp/riffer/issues/68)) ([e2f7961](https://github.com/janeapp/riffer/commit/e2f79616464101d90488f8f28aedcbdf4086277d))
|
|
14
16
|
|
|
15
|
-
## [0.
|
|
17
|
+
## [0.5.0](https://github.com/janeapp/riffer/compare/riffer/v0.4.2...riffer/v0.5.0) (2026-01-06)
|
|
16
18
|
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
- streaming via agents ([#63](https://github.com/janeapp/riffer/issues/63)) ([b4171c2](https://github.com/janeapp/riffer/commit/b4171c20f64a7ada1264ce90ab5278c19ff8a47a))
|
|
22
|
+
|
|
23
|
+
## [0.4.2](https://github.com/janeapp/riffer/compare/riffer/v0.4.1...riffer/v0.4.2) (2025-12-29)
|
|
17
24
|
|
|
18
25
|
### Bug Fixes
|
|
19
26
|
|
|
20
|
-
|
|
21
|
-
* add permissions for contents in docs job ([#57](https://github.com/bottrall/riffer/issues/57)) ([1dd5f7a](https://github.com/bottrall/riffer/commit/1dd5f7a817d4f73c1a0cad1a93fee0148ef10705))
|
|
22
|
-
* suppress output during documentation generation ([#53](https://github.com/bottrall/riffer/issues/53)) ([6b7f2d9](https://github.com/bottrall/riffer/commit/6b7f2d9aa7adb5450855097840c971dcf201d8c0))
|
|
23
|
-
* update rdoc command to target the lib directory ([#56](https://github.com/bottrall/riffer/issues/56)) ([c319efe](https://github.com/bottrall/riffer/commit/c319efe039ddb118411ad9e270dc0994d3b8cf5c))
|
|
27
|
+
- update README for clarity on provider usage and examples ([#60](https://github.com/janeapp/riffer/issues/60)) ([b12835c](https://github.com/janeapp/riffer/commit/b12835ce71c29e02074a0897551db50283ac8be6))
|
|
24
28
|
|
|
25
|
-
## [0.4.
|
|
29
|
+
## [0.4.1](https://github.com/janeapp/riffer/compare/riffer/v0.4.0...riffer/v0.4.1) (2025-12-29)
|
|
26
30
|
|
|
31
|
+
### Bug Fixes
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
- add conditional check for docs job execution based on release creation ([#58](https://github.com/janeapp/riffer/issues/58)) ([97bc6f7](https://github.com/janeapp/riffer/commit/97bc6f79b20902f94edac35b7d9d25c2e033d8bd))
|
|
34
|
+
- add permissions for contents in docs job ([#57](https://github.com/janeapp/riffer/issues/57)) ([1dd5f7a](https://github.com/janeapp/riffer/commit/1dd5f7a817d4f73c1a0cad1a93fee0148ef10705))
|
|
35
|
+
- suppress output during documentation generation ([#53](https://github.com/janeapp/riffer/issues/53)) ([6b7f2d9](https://github.com/janeapp/riffer/commit/6b7f2d9aa7adb5450855097840c971dcf201d8c0))
|
|
36
|
+
- update rdoc command to target the lib directory ([#56](https://github.com/janeapp/riffer/issues/56)) ([c319efe](https://github.com/janeapp/riffer/commit/c319efe039ddb118411ad9e270dc0994d3b8cf5c))
|
|
29
37
|
|
|
30
|
-
|
|
38
|
+
## [0.4.0](https://github.com/janeapp/riffer/compare/riffer/v0.3.2...riffer/v0.4.0) (2025-12-29)
|
|
31
39
|
|
|
32
|
-
|
|
40
|
+
### Features
|
|
33
41
|
|
|
42
|
+
- add documentation generation and publishing workflow ([#51](https://github.com/janeapp/riffer/issues/51)) ([49e3b04](https://github.com/janeapp/riffer/commit/49e3b046c2011f56bb8803b76e152df9ffb26617))
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
## [0.3.2](https://github.com/janeapp/riffer/compare/riffer/v0.3.1...riffer/v0.3.2) (2025-12-29)
|
|
36
45
|
|
|
37
|
-
|
|
46
|
+
### Bug Fixes
|
|
38
47
|
|
|
39
|
-
|
|
48
|
+
- add Rubygems credentials configuration step in release workflow ([#49](https://github.com/janeapp/riffer/issues/49)) ([dcc71e0](https://github.com/janeapp/riffer/commit/dcc71e01f541510ab73986237adaabfab1ef2401))
|
|
40
49
|
|
|
50
|
+
## [0.3.1](https://github.com/janeapp/riffer/compare/riffer/v0.3.0...riffer/v0.3.1) (2025-12-29)
|
|
41
51
|
|
|
42
52
|
### Bug Fixes
|
|
43
53
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## [0.3.0](https://github.com/bottrall/riffer/compare/riffer-v0.2.0...riffer/v0.3.0) (2025-12-29)
|
|
54
|
+
- update checkout action version in release workflow ([#47](https://github.com/janeapp/riffer/issues/47)) ([c6b1361](https://github.com/janeapp/riffer/commit/c6b1361b20d7cc4522e20c46fa1a75ad3a8a80d7))
|
|
47
55
|
|
|
56
|
+
## [0.3.0](https://github.com/janeapp/riffer/compare/riffer-v0.2.0...riffer/v0.3.0) (2025-12-29)
|
|
48
57
|
|
|
49
58
|
### Features
|
|
50
59
|
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
- add release and publish workflows ([#35](https://github.com/janeapp/riffer/issues/35)) ([3eb0389](https://github.com/janeapp/riffer/commit/3eb03897d0e96c01ef1857c04b2bafa53e37dde0))
|
|
53
61
|
|
|
54
62
|
### Bug Fixes
|
|
55
63
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
## [0.2.0](https://github.com/bottrall/riffer/compare/v0.1.0...v0.2.0) (2025-12-28)
|
|
64
|
+
- add manifest file to release configuration ([#43](https://github.com/janeapp/riffer/issues/43)) ([8d46135](https://github.com/janeapp/riffer/commit/8d46135ccd1c4315d624fa11a639e51aa1f1e5b8))
|
|
65
|
+
- auto-publishing on new release ([#38](https://github.com/janeapp/riffer/issues/38)) ([5a1d267](https://github.com/janeapp/riffer/commit/5a1d267e046c1531e01c80b9e40b94eed216360c))
|
|
66
|
+
- remove manifest file from release configuration ([#41](https://github.com/janeapp/riffer/issues/41)) ([2f898d8](https://github.com/janeapp/riffer/commit/2f898d8e1bdf6787583f22c83e83e90f2a75142e))
|
|
67
|
+
- remove release-type configuration from release workflow ([#42](https://github.com/janeapp/riffer/issues/42)) ([e270a6c](https://github.com/janeapp/riffer/commit/e270a6c906f7e04f1b0ce57b7d29808c98e7dce8))
|
|
68
|
+
- reset release manifest to empty object ([#44](https://github.com/janeapp/riffer/issues/44)) ([26f1b6d](https://github.com/janeapp/riffer/commit/26f1b6d2dcb622295026cc7fb247559156864d74))
|
|
69
|
+
- restructure release configuration and update manifest format ([#45](https://github.com/janeapp/riffer/issues/45)) ([d07694c](https://github.com/janeapp/riffer/commit/d07694c05d49166740f3408a343c351d33749edf))
|
|
70
|
+
- simplify release configuration by removing unnecessary package structure ([#40](https://github.com/janeapp/riffer/issues/40)) ([8472967](https://github.com/janeapp/riffer/commit/84729670fd202208256e6de69f1b81366ad0a688))
|
|
65
71
|
|
|
72
|
+
## [0.2.0](https://github.com/janeapp/riffer/compare/v0.1.0...v0.2.0) (2025-12-28)
|
|
66
73
|
|
|
67
74
|
### Features
|
|
68
75
|
|
|
69
|
-
|
|
76
|
+
- add release and publish workflows ([#35](https://github.com/janeapp/riffer/issues/35)) ([3eb0389](https://github.com/janeapp/riffer/commit/3eb03897d0e96c01ef1857c04b2bafa53e37dde0))
|
|
70
77
|
|
|
71
78
|
## [0.1.0] - 2024-12-20
|
|
72
79
|
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -42,7 +42,7 @@ gem 'riffer'
|
|
|
42
42
|
Install the development branch directly from GitHub:
|
|
43
43
|
|
|
44
44
|
```ruby
|
|
45
|
-
gem 'riffer', git: 'https://github.com/
|
|
45
|
+
gem 'riffer', git: 'https://github.com/janeapp/riffer.git'
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
## Quick Start
|
|
@@ -68,13 +68,12 @@ puts agent.generate('Hello world')
|
|
|
68
68
|
# => "Hello world"
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
Streaming example
|
|
71
|
+
Streaming example:
|
|
72
72
|
|
|
73
73
|
```ruby
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
puts chunk.content
|
|
74
|
+
agent = EchoAgent.new
|
|
75
|
+
agent.stream('Tell me a story').each do |event|
|
|
76
|
+
print event.content
|
|
78
77
|
end
|
|
79
78
|
```
|
|
80
79
|
|
|
@@ -111,7 +110,7 @@ bin/console
|
|
|
111
110
|
2. Run tests and linters locally: `bundle exec rake`
|
|
112
111
|
3. Submit a pull request with a clear description of the change
|
|
113
112
|
|
|
114
|
-
Please follow the [Code of Conduct](https://github.com/
|
|
113
|
+
Please follow the [Code of Conduct](https://github.com/janeapp/riffer/blob/main/CODE_OF_CONDUCT.md).
|
|
115
114
|
|
|
116
115
|
## Changelog
|
|
117
116
|
|
data/lib/riffer/agent.rb
CHANGED
|
@@ -91,6 +91,31 @@ class Riffer::Agent
|
|
|
91
91
|
extract_final_response
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
+
# Streams a response from the agent
|
|
95
|
+
# @param prompt_or_messages [String, Array<Hash, Riffer::Messages::Base>]
|
|
96
|
+
# @return [Enumerator] an enumerator yielding stream events
|
|
97
|
+
def stream(prompt_or_messages)
|
|
98
|
+
initialize_messages(prompt_or_messages)
|
|
99
|
+
|
|
100
|
+
Enumerator.new do |yielder|
|
|
101
|
+
accumulated_content = ""
|
|
102
|
+
|
|
103
|
+
call_llm_stream.each do |event|
|
|
104
|
+
yielder << event
|
|
105
|
+
|
|
106
|
+
case event
|
|
107
|
+
when Riffer::StreamEvents::TextDelta
|
|
108
|
+
accumulated_content += event.content
|
|
109
|
+
when Riffer::StreamEvents::TextDone
|
|
110
|
+
accumulated_content = event.content
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
response = Riffer::Messages::Assistant.new(accumulated_content)
|
|
115
|
+
@messages << response
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
94
119
|
private
|
|
95
120
|
|
|
96
121
|
def initialize_messages(prompt_or_messages)
|
|
@@ -110,9 +135,13 @@ class Riffer::Agent
|
|
|
110
135
|
provider_instance.generate_text(messages: @messages, model: @model_name)
|
|
111
136
|
end
|
|
112
137
|
|
|
138
|
+
def call_llm_stream
|
|
139
|
+
provider_instance.stream_text(messages: @messages, model: @model_name)
|
|
140
|
+
end
|
|
141
|
+
|
|
113
142
|
def provider_instance
|
|
114
143
|
@provider_instance ||= begin
|
|
115
|
-
provider_class = Riffer::Providers::
|
|
144
|
+
provider_class = Riffer::Providers::Repository.find(@provider_name)
|
|
116
145
|
raise Riffer::ArgumentError, "Provider not found: #{@provider_name}" unless provider_class
|
|
117
146
|
provider_class.new
|
|
118
147
|
end
|
|
@@ -4,32 +4,6 @@ class Riffer::Providers::Base
|
|
|
4
4
|
include Riffer::Helpers::Dependencies
|
|
5
5
|
include Riffer::Messages::Converter
|
|
6
6
|
|
|
7
|
-
class << self
|
|
8
|
-
def identifier(value = nil)
|
|
9
|
-
return @identifier if value.nil?
|
|
10
|
-
|
|
11
|
-
@identifier = value
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# Finds a provider class by identifier
|
|
15
|
-
# @param identifier [String, Symbol] the identifier to search for
|
|
16
|
-
# @return [Class, nil] the provider class, or nil if not found
|
|
17
|
-
def find(identifier)
|
|
18
|
-
ensure_providers_loaded
|
|
19
|
-
subclasses.find { |provider_class| provider_class.identifier == identifier }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
def ensure_providers_loaded
|
|
25
|
-
return if @providers_loaded
|
|
26
|
-
|
|
27
|
-
Zeitwerk::Loader.eager_load_namespace(Riffer::Providers)
|
|
28
|
-
|
|
29
|
-
@providers_loaded = true
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
7
|
# Generates text using the provider.
|
|
34
8
|
#
|
|
35
9
|
# @param prompt [String, nil] the user prompt (required when `messages` is not provided)
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
require "openai"
|
|
4
4
|
|
|
5
5
|
class Riffer::Providers::OpenAI < Riffer::Providers::Base
|
|
6
|
-
identifier "openai"
|
|
7
|
-
|
|
8
6
|
# Initializes the OpenAI provider.
|
|
9
7
|
# @param options [Hash] optional client options. Use `:api_key` to override `Riffer.config.openai.api_key`.
|
|
10
8
|
# @raise [Riffer::ArgumentError] if an API key is not provided either via `:api_key` or `Riffer.config.openai.api_key`.
|
|
@@ -78,19 +76,16 @@ class Riffer::Providers::OpenAI < Riffer::Providers::Base
|
|
|
78
76
|
end
|
|
79
77
|
|
|
80
78
|
def process_stream_events(stream, yielder)
|
|
81
|
-
stream.each do |
|
|
82
|
-
|
|
79
|
+
stream.each do |raw_event|
|
|
80
|
+
event = convert_event(raw_event)
|
|
83
81
|
|
|
84
|
-
|
|
85
|
-
yielder << content if content
|
|
86
|
-
end
|
|
87
|
-
end
|
|
82
|
+
next unless event
|
|
88
83
|
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
yielder << event if event
|
|
85
|
+
end
|
|
91
86
|
end
|
|
92
87
|
|
|
93
|
-
def
|
|
88
|
+
def convert_event(event)
|
|
94
89
|
case event.type
|
|
95
90
|
when :"response.output_text.delta"
|
|
96
91
|
Riffer::StreamEvents::TextDelta.new(event.delta)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class Riffer::Providers::Repository
|
|
2
|
+
REPO = {
|
|
3
|
+
openai: -> { Riffer::Providers::OpenAI },
|
|
4
|
+
test: -> { Riffer::Providers::Test }
|
|
5
|
+
}.freeze
|
|
6
|
+
|
|
7
|
+
class << self
|
|
8
|
+
# Finds a provider class by identifier
|
|
9
|
+
# @param identifier [String, Symbol] the identifier to search for
|
|
10
|
+
# @return [Class, nil] the provider class, or nil if not found
|
|
11
|
+
def find(identifier)
|
|
12
|
+
REPO.fetch(identifier.to_sym, nil)&.call
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Riffer::Providers::Test < Riffer::Providers::Base
|
|
4
|
-
identifier "test"
|
|
5
|
-
|
|
6
4
|
attr_reader :calls
|
|
7
5
|
|
|
8
6
|
def initialize(**options)
|
|
@@ -35,11 +33,14 @@ class Riffer::Providers::Test < Riffer::Providers::Base
|
|
|
35
33
|
response = @stubbed_response || @responses[@current_index] || {role: "assistant", content: "Test response"}
|
|
36
34
|
@current_index += 1
|
|
37
35
|
Enumerator.new do |yielder|
|
|
38
|
-
|
|
36
|
+
full_content = response[:content]
|
|
37
|
+
content_parts = full_content.split(". ").map { |part| part + (part.end_with?(".") ? "" : ".") }
|
|
38
|
+
|
|
39
39
|
content_parts.each do |part|
|
|
40
|
-
yielder <<
|
|
41
|
-
sleep 0.5
|
|
40
|
+
yielder << Riffer::StreamEvents::TextDelta.new(part + " ")
|
|
42
41
|
end
|
|
42
|
+
|
|
43
|
+
yielder << Riffer::StreamEvents::TextDone.new(full_content)
|
|
43
44
|
end
|
|
44
45
|
end
|
|
45
46
|
end
|
data/lib/riffer/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jake Bottrall
|
|
@@ -35,14 +35,14 @@ dependencies:
|
|
|
35
35
|
requirements:
|
|
36
36
|
- - "~>"
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: 0.
|
|
38
|
+
version: 0.43.0
|
|
39
39
|
type: :development
|
|
40
40
|
prerelease: false
|
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
42
|
requirements:
|
|
43
43
|
- - "~>"
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: 0.
|
|
45
|
+
version: 0.43.0
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: minitest
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -150,6 +150,7 @@ files:
|
|
|
150
150
|
- lib/riffer/providers.rb
|
|
151
151
|
- lib/riffer/providers/base.rb
|
|
152
152
|
- lib/riffer/providers/open_ai.rb
|
|
153
|
+
- lib/riffer/providers/repository.rb
|
|
153
154
|
- lib/riffer/providers/test.rb
|
|
154
155
|
- lib/riffer/stream_events.rb
|
|
155
156
|
- lib/riffer/stream_events/base.rb
|
|
@@ -163,8 +164,8 @@ licenses:
|
|
|
163
164
|
metadata:
|
|
164
165
|
allowed_push_host: https://rubygems.org
|
|
165
166
|
homepage_uri: https://riffer.ai
|
|
166
|
-
source_code_uri: https://github.com/
|
|
167
|
-
changelog_uri: https://github.com/
|
|
167
|
+
source_code_uri: https://github.com/janeapp/riffer
|
|
168
|
+
changelog_uri: https://github.com/janeapp/riffer/blob/main/CHANGELOG.md
|
|
168
169
|
rdoc_options:
|
|
169
170
|
- "--main"
|
|
170
171
|
- README.md
|