riffer 0.6.1 → 0.8.0
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/.agents/architecture.md +113 -0
- data/.agents/code-style.md +42 -0
- data/.agents/providers.md +46 -0
- data/.agents/rdoc.md +51 -0
- data/.agents/testing.md +56 -0
- data/.release-please-manifest.json +1 -1
- data/AGENTS.md +28 -0
- data/CHANGELOG.md +17 -0
- data/README.md +26 -36
- data/Rakefile +1 -1
- data/docs/01_OVERVIEW.md +106 -0
- data/docs/02_GETTING_STARTED.md +128 -0
- data/docs/03_AGENTS.md +226 -0
- data/docs/04_TOOLS.md +251 -0
- data/docs/05_MESSAGES.md +173 -0
- data/docs/06_STREAM_EVENTS.md +191 -0
- data/docs/07_CONFIGURATION.md +195 -0
- data/docs_providers/01_PROVIDERS.md +168 -0
- data/docs_providers/02_AMAZON_BEDROCK.md +196 -0
- data/docs_providers/03_ANTHROPIC.md +211 -0
- data/docs_providers/04_OPENAI.md +157 -0
- data/docs_providers/05_TEST_PROVIDER.md +163 -0
- data/docs_providers/06_CUSTOM_PROVIDERS.md +304 -0
- data/lib/riffer/agent.rb +220 -57
- data/lib/riffer/config.rb +20 -12
- data/lib/riffer/core.rb +7 -7
- data/lib/riffer/helpers/class_name_converter.rb +6 -3
- data/lib/riffer/helpers/dependencies.rb +18 -0
- data/lib/riffer/helpers/validations.rb +9 -0
- data/lib/riffer/messages/assistant.rb +23 -1
- data/lib/riffer/messages/base.rb +15 -0
- data/lib/riffer/messages/converter.rb +15 -5
- data/lib/riffer/messages/system.rb +8 -1
- data/lib/riffer/messages/tool.rb +58 -4
- data/lib/riffer/messages/user.rb +8 -1
- data/lib/riffer/messages.rb +7 -0
- data/lib/riffer/providers/amazon_bedrock.rb +128 -13
- data/lib/riffer/providers/anthropic.rb +209 -0
- data/lib/riffer/providers/base.rb +23 -18
- data/lib/riffer/providers/open_ai.rb +119 -39
- data/lib/riffer/providers/repository.rb +9 -4
- data/lib/riffer/providers/test.rb +78 -24
- data/lib/riffer/providers.rb +6 -0
- data/lib/riffer/stream_events/base.rb +13 -1
- data/lib/riffer/stream_events/reasoning_delta.rb +15 -1
- data/lib/riffer/stream_events/reasoning_done.rb +15 -1
- data/lib/riffer/stream_events/text_delta.rb +14 -1
- data/lib/riffer/stream_events/text_done.rb +14 -1
- data/lib/riffer/stream_events/tool_call_delta.rb +35 -0
- data/lib/riffer/stream_events/tool_call_done.rb +40 -0
- data/lib/riffer/stream_events.rb +9 -0
- data/lib/riffer/tool.rb +120 -0
- data/lib/riffer/tools/param.rb +68 -0
- data/lib/riffer/tools/params.rb +118 -0
- data/lib/riffer/tools.rb +9 -0
- data/lib/riffer/version.rb +1 -1
- data/lib/riffer.rb +23 -19
- metadata +41 -2
- data/CLAUDE.md +0 -73
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ace7d52275897dc91ce42de1acc67db3de289c55953a56fa833a0f92f9c48c7c
|
|
4
|
+
data.tar.gz: ddee9798fb18502bd0e0e14e61d899a3cb24b240a6e6f9ab95b00199f03f7b59
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c32731c0ac374bcc90fddd3c1cf071e3e2a1a2e2ae197ffcf98aace5acc4402c38d24657b2d3c211dfbf8d951a48ab9e94087a4b3accb2e763eb6202fa07312
|
|
7
|
+
data.tar.gz: da8b8ba45b0a5e08e4f2c7b212ddba5761fd2673d1c89fea695b1cb2d60e9ba1f7a01d9138f0eed33b406a7c7e116eb219e1f7a4919a7a4183cfe2dc97f59622
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
## Core Components
|
|
4
|
+
|
|
5
|
+
### Agent (`lib/riffer/agent.rb`)
|
|
6
|
+
|
|
7
|
+
Base class for AI agents. Subclass and use DSL methods `model` and `instructions` to configure. Orchestrates message flow, LLM calls, and tool execution via a generate/stream loop.
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
class EchoAgent < Riffer::Agent
|
|
11
|
+
model 'openai/gpt-5-mini' # provider/model
|
|
12
|
+
instructions 'You are an assistant that repeats what the user says.'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
agent = EchoAgent.new
|
|
16
|
+
puts agent.generate('Hello world')
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Providers (`lib/riffer/providers/`)
|
|
20
|
+
|
|
21
|
+
Adapters for LLM APIs. Each provider extends `Riffer::Providers::Base` and implements:
|
|
22
|
+
|
|
23
|
+
- `perform_generate_text(messages, model:)` - returns `Riffer::Messages::Assistant`
|
|
24
|
+
- `perform_stream_text(messages, model:)` - returns an `Enumerator` yielding stream events
|
|
25
|
+
|
|
26
|
+
Providers are registered in `Riffer::Providers::Repository::REPO` with identifiers (e.g., `openai`, `amazon_bedrock`).
|
|
27
|
+
|
|
28
|
+
### Messages (`lib/riffer/messages/`)
|
|
29
|
+
|
|
30
|
+
Typed message objects that extend `Riffer::Messages::Base`:
|
|
31
|
+
|
|
32
|
+
- `System` - system instructions
|
|
33
|
+
- `User` - user input
|
|
34
|
+
- `Assistant` - AI responses
|
|
35
|
+
- `Tool` - tool execution results
|
|
36
|
+
|
|
37
|
+
The `Converter` module handles hash-to-object conversion.
|
|
38
|
+
|
|
39
|
+
### StreamEvents (`lib/riffer/stream_events/`)
|
|
40
|
+
|
|
41
|
+
Structured events for streaming responses:
|
|
42
|
+
|
|
43
|
+
- `TextDelta` - incremental text chunks
|
|
44
|
+
- `TextDone` - completion signals
|
|
45
|
+
- `ReasoningDelta` - reasoning process chunks
|
|
46
|
+
- `ReasoningDone` - reasoning completion
|
|
47
|
+
|
|
48
|
+
## Key Patterns
|
|
49
|
+
|
|
50
|
+
- Model strings use `provider/model` format (e.g., `openai/gpt-4`)
|
|
51
|
+
- Configuration via `Riffer.configure { |c| c.openai.api_key = "..." }`
|
|
52
|
+
- Providers use `depends_on` helper for runtime dependency checking
|
|
53
|
+
- Zeitwerk for autoloading - file structure must match module/class names
|
|
54
|
+
|
|
55
|
+
## Project Structure
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
lib/
|
|
59
|
+
riffer.rb # Main entry point, uses Zeitwerk for autoloading
|
|
60
|
+
riffer/
|
|
61
|
+
version.rb # VERSION constant
|
|
62
|
+
config.rb # Configuration class
|
|
63
|
+
core.rb # Core functionality
|
|
64
|
+
agent.rb # Agent class
|
|
65
|
+
messages.rb # Messages namespace/module
|
|
66
|
+
providers.rb # Providers namespace/module
|
|
67
|
+
stream_events.rb # Stream events namespace/module
|
|
68
|
+
helpers/
|
|
69
|
+
class_name_converter.rb # Class name conversion utilities
|
|
70
|
+
dependencies.rb # Dependency management
|
|
71
|
+
validations.rb # Validation helpers
|
|
72
|
+
messages/
|
|
73
|
+
base.rb # Base message class
|
|
74
|
+
assistant.rb # Assistant message
|
|
75
|
+
converter.rb # Message converter
|
|
76
|
+
system.rb # System message
|
|
77
|
+
user.rb # User message
|
|
78
|
+
tool.rb # Tool message
|
|
79
|
+
providers/
|
|
80
|
+
base.rb # Base provider class
|
|
81
|
+
open_ai.rb # OpenAI provider
|
|
82
|
+
amazon_bedrock.rb # Amazon Bedrock provider
|
|
83
|
+
repository.rb # Provider registry
|
|
84
|
+
test.rb # Test provider
|
|
85
|
+
stream_events/
|
|
86
|
+
base.rb # Base stream event
|
|
87
|
+
text_delta.rb # Text delta event
|
|
88
|
+
text_done.rb # Text done event
|
|
89
|
+
reasoning_delta.rb # Reasoning delta event
|
|
90
|
+
reasoning_done.rb # Reasoning done event
|
|
91
|
+
test/
|
|
92
|
+
test_helper.rb # Minitest configuration with VCR
|
|
93
|
+
riffer_test.rb # Main module tests
|
|
94
|
+
riffer/
|
|
95
|
+
[feature]_test.rb # Feature tests mirror lib/riffer/ structure
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Configuration Example
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
Riffer.configure do |config|
|
|
102
|
+
config.openai.api_key = ENV['OPENAI_API_KEY']
|
|
103
|
+
end
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Streaming Example
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
agent = EchoAgent.new
|
|
110
|
+
agent.stream('Tell me a story').each do |event|
|
|
111
|
+
print event.content
|
|
112
|
+
end
|
|
113
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Code Style
|
|
2
|
+
|
|
3
|
+
## Formatting
|
|
4
|
+
|
|
5
|
+
- Use StandardRB for linting and formatting
|
|
6
|
+
- Custom rules are defined in `.standard.yml`
|
|
7
|
+
- Run `bundle exec rake standard` to check, `bundle exec rake standard:fix` to auto-fix
|
|
8
|
+
|
|
9
|
+
## Required Header
|
|
10
|
+
|
|
11
|
+
All Ruby files must include:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
# frozen_string_literal: true
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Error Handling
|
|
18
|
+
|
|
19
|
+
Define custom errors as subclasses of `Riffer::Error`:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
class MyCustomError < Riffer::Error
|
|
23
|
+
end
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Comments
|
|
27
|
+
|
|
28
|
+
- Only add comments when the code is ambiguous or not semantically obvious
|
|
29
|
+
- Explain **why** something is done, not **what** is being done
|
|
30
|
+
- Comments should add value beyond what the code already expresses
|
|
31
|
+
|
|
32
|
+
## Module Structure
|
|
33
|
+
|
|
34
|
+
```ruby
|
|
35
|
+
# frozen_string_literal: true
|
|
36
|
+
|
|
37
|
+
module Riffer::Feature
|
|
38
|
+
class MyClass
|
|
39
|
+
# Implementation
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Adding a New Provider
|
|
2
|
+
|
|
3
|
+
## Steps
|
|
4
|
+
|
|
5
|
+
1. Create `lib/riffer/providers/your_provider.rb` extending `Riffer::Providers::Base`
|
|
6
|
+
2. Implement required methods (see below)
|
|
7
|
+
3. Register in `Riffer::Providers::Repository::REPO`
|
|
8
|
+
4. Add provider config to `Riffer::Config` if needed
|
|
9
|
+
5. Create tests in `test/riffer/providers/your_provider_test.rb`
|
|
10
|
+
|
|
11
|
+
## Required Methods
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
# frozen_string_literal: true
|
|
15
|
+
|
|
16
|
+
module Riffer
|
|
17
|
+
module Providers
|
|
18
|
+
class YourProvider < Base
|
|
19
|
+
# Returns Riffer::Messages::Assistant
|
|
20
|
+
def perform_generate_text(messages, model:)
|
|
21
|
+
# Implementation
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Returns Enumerator yielding stream events
|
|
25
|
+
def perform_stream_text(messages, model:)
|
|
26
|
+
# Implementation
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Registration
|
|
34
|
+
|
|
35
|
+
Add to `Riffer::Providers::Repository::REPO`:
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
REPO = {
|
|
39
|
+
# ... existing providers
|
|
40
|
+
your_provider: -> { YourProvider }
|
|
41
|
+
}.freeze
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Dependencies
|
|
45
|
+
|
|
46
|
+
Use `depends_on` helper for runtime dependency checking if your provider requires external gems.
|
data/.agents/rdoc.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# RDoc Documentation
|
|
2
|
+
|
|
3
|
+
Use pure RDoc comments for public APIs (not YARD).
|
|
4
|
+
|
|
5
|
+
## Parameters
|
|
6
|
+
|
|
7
|
+
Use definition list syntax (`::`):
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
# Creates a new agent.
|
|
11
|
+
#
|
|
12
|
+
# name:: String - the agent name
|
|
13
|
+
# options:: Hash - optional configuration
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Return Values
|
|
17
|
+
|
|
18
|
+
Document with prose:
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
# Returns String - the agent identifier.
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Exceptions
|
|
25
|
+
|
|
26
|
+
Document with prose:
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
# Raises Riffer::ArgumentError if the name is invalid.
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Examples
|
|
33
|
+
|
|
34
|
+
Include usage examples as indented code blocks:
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
# Creates a new agent.
|
|
38
|
+
#
|
|
39
|
+
# agent = MyAgent.new
|
|
40
|
+
# agent.generate('Hello')
|
|
41
|
+
#
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Internal APIs
|
|
45
|
+
|
|
46
|
+
Mark internal APIs with `:nodoc:` to exclude from documentation:
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
def internal_method # :nodoc:
|
|
50
|
+
end
|
|
51
|
+
```
|
data/.agents/testing.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Testing
|
|
2
|
+
|
|
3
|
+
## Framework
|
|
4
|
+
|
|
5
|
+
Use Minitest with the spec DSL for all tests.
|
|
6
|
+
|
|
7
|
+
## Test Structure
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
# frozen_string_literal: true
|
|
11
|
+
|
|
12
|
+
require "test_helper"
|
|
13
|
+
|
|
14
|
+
describe Riffer::Feature do
|
|
15
|
+
describe "#method_name" do
|
|
16
|
+
before do
|
|
17
|
+
# setup code
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "does something expected" do
|
|
21
|
+
result = Riffer::Feature.method_name(args)
|
|
22
|
+
assert_equal expected, result
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "handles edge case" do
|
|
26
|
+
result = Riffer::Feature.method_name(edge_case_args)
|
|
27
|
+
assert_equal edge_case_expected, result
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Guidelines
|
|
34
|
+
|
|
35
|
+
- Test files go in `test/` directory with `*_test.rb` suffix
|
|
36
|
+
- Use `before`/`after` blocks for setup and cleanup
|
|
37
|
+
- Stick to the single assertion rule where possible
|
|
38
|
+
- Test edge cases and error conditions
|
|
39
|
+
- Use Minitest assertions: `assert_equal`, `assert_instance_of`, `refute_nil`, etc.
|
|
40
|
+
|
|
41
|
+
## VCR Cassettes
|
|
42
|
+
|
|
43
|
+
Record external API interactions in `test/fixtures/vcr_cassettes/`.
|
|
44
|
+
|
|
45
|
+
## Running Tests
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Run all tests
|
|
49
|
+
bundle exec rake test
|
|
50
|
+
|
|
51
|
+
# Run a single test file
|
|
52
|
+
bundle exec ruby -Ilib:test test/riffer/agent_test.rb
|
|
53
|
+
|
|
54
|
+
# Run a specific test by name
|
|
55
|
+
bundle exec ruby -Ilib:test test/riffer/agent_test.rb --name "test_something"
|
|
56
|
+
```
|
data/AGENTS.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Riffer
|
|
2
|
+
|
|
3
|
+
Ruby gem framework for building AI-powered agents with LLM provider adapters.
|
|
4
|
+
|
|
5
|
+
## Quick Reference
|
|
6
|
+
|
|
7
|
+
- **Ruby**: 3.2.0+
|
|
8
|
+
- **Lint + Test**: `bundle exec rake`
|
|
9
|
+
- **Autoloading**: Zeitwerk (file paths must match module/class names)
|
|
10
|
+
- **Model format**: `provider/model` (e.g., `openai/gpt-4`)
|
|
11
|
+
|
|
12
|
+
## Topic Guides
|
|
13
|
+
|
|
14
|
+
- [Architecture](.agents/architecture.md) - Core components and project structure
|
|
15
|
+
- [Testing](.agents/testing.md) - Minitest spec DSL and VCR cassettes
|
|
16
|
+
- [Code Style](.agents/code-style.md) - StandardRB and comment conventions
|
|
17
|
+
- [RDoc](.agents/rdoc.md) - Documentation format for public APIs
|
|
18
|
+
- [Providers](.agents/providers.md) - Adding new LLM provider adapters
|
|
19
|
+
|
|
20
|
+
## Commands
|
|
21
|
+
|
|
22
|
+
| Command | Description |
|
|
23
|
+
|---------|-------------|
|
|
24
|
+
| `bundle exec rake` | Run tests + lint (default) |
|
|
25
|
+
| `bundle exec rake test` | Run tests only |
|
|
26
|
+
| `bundle exec rake standard` | Check code style |
|
|
27
|
+
| `bundle exec rake standard:fix` | Auto-fix style issues |
|
|
28
|
+
| `bin/console` | Interactive console |
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ 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](https://github.com/janeapp/riffer/compare/riffer/v0.7.0...riffer/v0.8.0) (2026-01-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add anthropic provider support ([#89](https://github.com/janeapp/riffer/issues/89)) ([338674e](https://github.com/janeapp/riffer/commit/338674e794535b2559ce4dca5d36e09e9512b94c))
|
|
14
|
+
* add on_message callback for real-time message emission ([#87](https://github.com/janeapp/riffer/issues/87)) ([92e6f91](https://github.com/janeapp/riffer/commit/92e6f919b9facee9a2fb6234c1bdd69b525dbf21))
|
|
15
|
+
* add timeout functionality to tools ([#86](https://github.com/janeapp/riffer/issues/86)) ([3b7d9af](https://github.com/janeapp/riffer/commit/3b7d9afeed829001de0f6524694c193d54f1e7af))
|
|
16
|
+
* better docs ([#84](https://github.com/janeapp/riffer/issues/84)) ([630580a](https://github.com/janeapp/riffer/commit/630580ae08a86dfa5ab1f75ebb229db7cff6344d))
|
|
17
|
+
|
|
18
|
+
## [0.7.0](https://github.com/janeapp/riffer/compare/riffer/v0.6.1...riffer/v0.7.0) (2026-01-21)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* tool calling support ([#82](https://github.com/janeapp/riffer/issues/82)) ([0b2676a](https://github.com/janeapp/riffer/commit/0b2676a77e93b3fd55041e66a5c8c0ab6762e3d2))
|
|
24
|
+
|
|
8
25
|
## [0.6.1](https://github.com/janeapp/riffer/compare/riffer/v0.6.0...riffer/v0.6.1) (2026-01-16)
|
|
9
26
|
|
|
10
27
|
|
data/README.md
CHANGED
|
@@ -2,24 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The all-in-one Ruby framework for building AI-powered applications and agents.
|
|
4
4
|
|
|
5
|
-
[](https://badge.fury.io/rb/riffer)
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
Riffer is a comprehensive Ruby framework designed to simplify the development of AI-powered applications and agents. It provides a complete toolkit for integrating artificial intelligence capabilities into your Ruby projects.
|
|
10
|
-
|
|
11
|
-
Key concepts:
|
|
12
|
-
|
|
13
|
-
- **Agents** – orchestrate messages, LLM calls, and tool execution (`Riffer::Agent`).
|
|
14
|
-
- **Providers** – adapters that implement text generation and streaming (`Riffer::Providers::*`).
|
|
15
|
-
- **Messages** – typed message objects for system, user, assistant, and tool messages (`Riffer::Messages::*`).
|
|
16
|
-
|
|
17
|
-
## Features
|
|
18
|
-
|
|
19
|
-
- Minimal, well-documented core for building AI agents
|
|
20
|
-
- Provider abstraction (OpenAI) for pluggable providers
|
|
21
|
-
- Streaming support and structured stream events
|
|
22
|
-
- Message converters and helpers for robust message handling
|
|
5
|
+
[](https://badge.fury.io/rb/riffer)
|
|
23
6
|
|
|
24
7
|
## Requirements
|
|
25
8
|
|
|
@@ -39,43 +22,50 @@ Or add to your application's Gemfile:
|
|
|
39
22
|
gem 'riffer'
|
|
40
23
|
```
|
|
41
24
|
|
|
42
|
-
Install the development branch directly from GitHub:
|
|
43
|
-
|
|
44
|
-
```ruby
|
|
45
|
-
gem 'riffer', git: 'https://github.com/janeapp/riffer.git'
|
|
46
|
-
```
|
|
47
|
-
|
|
48
25
|
## Quick Start
|
|
49
26
|
|
|
50
|
-
Basic usage with the OpenAI provider:
|
|
51
|
-
|
|
52
27
|
```ruby
|
|
53
28
|
require 'riffer'
|
|
54
29
|
|
|
55
|
-
# Configure
|
|
30
|
+
# Configure your provider
|
|
56
31
|
Riffer.configure do |config|
|
|
57
32
|
config.openai.api_key = ENV['OPENAI_API_KEY']
|
|
58
33
|
end
|
|
59
34
|
|
|
35
|
+
# Define an agent
|
|
60
36
|
class EchoAgent < Riffer::Agent
|
|
61
|
-
model 'openai/gpt-
|
|
37
|
+
model 'openai/gpt-4o'
|
|
62
38
|
instructions 'You are an assistant that repeats what the user says.'
|
|
63
39
|
end
|
|
64
40
|
|
|
41
|
+
# Use the agent
|
|
65
42
|
agent = EchoAgent.new
|
|
66
43
|
puts agent.generate('Hello world')
|
|
67
|
-
# => "Hello world"
|
|
68
44
|
```
|
|
69
45
|
|
|
70
|
-
|
|
46
|
+
## Documentation
|
|
71
47
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
48
|
+
For comprehensive documentation, see the [docs](docs/) directory:
|
|
49
|
+
|
|
50
|
+
- [Overview](docs/01_OVERVIEW.md) - Core concepts and architecture
|
|
51
|
+
- [Getting Started](docs/02_GETTING_STARTED.md) - Installation and first steps
|
|
52
|
+
- [Agents](docs/03_AGENTS.md) - Building AI agents
|
|
53
|
+
- [Tools](docs/04_TOOLS.md) - Creating tools for agents
|
|
54
|
+
- [Messages](docs/05_MESSAGES.md) - Message types and formats
|
|
55
|
+
- [Stream Events](docs/06_STREAM_EVENTS.md) - Streaming responses
|
|
56
|
+
- [Configuration](docs/07_CONFIGURATION.md) - Framework configuration
|
|
57
|
+
- [Providers](docs_providers/01_PROVIDERS.md) - LLM provider adapters
|
|
58
|
+
|
|
59
|
+
### API Reference
|
|
60
|
+
|
|
61
|
+
Generate the full API documentation with:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
bundle exec rake docs
|
|
77
65
|
```
|
|
78
66
|
|
|
67
|
+
Then open `doc/index.html` in your browser.
|
|
68
|
+
|
|
79
69
|
## Development
|
|
80
70
|
|
|
81
71
|
After checking out the repo, run:
|
|
@@ -121,4 +111,4 @@ Licensed under the MIT License. See `LICENSE.txt` for details.
|
|
|
121
111
|
|
|
122
112
|
## Maintainers
|
|
123
113
|
|
|
124
|
-
- Jake Bottrall
|
|
114
|
+
- Jake Bottrall - https://github.com/bottrall
|
data/Rakefile
CHANGED
|
@@ -14,7 +14,7 @@ RDoc::Task.new do |rdoc|
|
|
|
14
14
|
rdoc.main = "README.md"
|
|
15
15
|
|
|
16
16
|
# Explicitly include top-level docs and the library
|
|
17
|
-
rdoc.rdoc_files.include("README.md", "CHANGELOG.md", "LICENSE.txt")
|
|
17
|
+
rdoc.rdoc_files.include("README.md", "CHANGELOG.md", "LICENSE.txt", "docs/**/*.md", "docs_providers/**/*.md")
|
|
18
18
|
rdoc.rdoc_files.include("lib/**/*.rb")
|
|
19
19
|
|
|
20
20
|
# Use Markdown where available and ensure UTF-8
|
data/docs/01_OVERVIEW.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
Riffer is a Ruby framework for building AI-powered applications and agents. It provides a complete toolkit for integrating Large Language Models (LLMs) into your Ruby projects.
|
|
4
|
+
|
|
5
|
+
## Core Concepts
|
|
6
|
+
|
|
7
|
+
### Agent
|
|
8
|
+
|
|
9
|
+
The Agent is the central orchestrator for AI interactions. It manages messages, calls the LLM provider, and handles tool execution.
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
class MyAgent < Riffer::Agent
|
|
13
|
+
model 'openai/gpt-4o'
|
|
14
|
+
instructions 'You are a helpful assistant.'
|
|
15
|
+
end
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
See [Agents](03_AGENTS.md) for details.
|
|
19
|
+
|
|
20
|
+
### Tool
|
|
21
|
+
|
|
22
|
+
Tools are callable functions that agents can invoke to interact with external systems. They have structured parameter definitions and automatic validation.
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
class WeatherTool < Riffer::Tool
|
|
26
|
+
description "Gets the weather for a city"
|
|
27
|
+
|
|
28
|
+
params do
|
|
29
|
+
required :city, String, description: "The city name"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def call(context:, city:)
|
|
33
|
+
WeatherAPI.fetch(city)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
See [Tools](04_TOOLS.md) for details.
|
|
39
|
+
|
|
40
|
+
### Provider
|
|
41
|
+
|
|
42
|
+
Providers are adapters that connect to LLM services. Riffer supports:
|
|
43
|
+
|
|
44
|
+
- **OpenAI** - GPT models via the OpenAI API
|
|
45
|
+
- **Amazon Bedrock** - Claude and other models via AWS Bedrock
|
|
46
|
+
- **Test** - Mock provider for testing
|
|
47
|
+
|
|
48
|
+
See [Providers](providers/01_PROVIDERS.md) for details.
|
|
49
|
+
|
|
50
|
+
### Messages
|
|
51
|
+
|
|
52
|
+
Messages represent the conversation between user and assistant. Riffer uses strongly-typed message objects:
|
|
53
|
+
|
|
54
|
+
- `Riffer::Messages::System` - System instructions
|
|
55
|
+
- `Riffer::Messages::User` - User input
|
|
56
|
+
- `Riffer::Messages::Assistant` - LLM responses
|
|
57
|
+
- `Riffer::Messages::Tool` - Tool execution results
|
|
58
|
+
|
|
59
|
+
See [Messages](05_MESSAGES.md) for details.
|
|
60
|
+
|
|
61
|
+
### Stream Events
|
|
62
|
+
|
|
63
|
+
When streaming responses, Riffer emits typed events:
|
|
64
|
+
|
|
65
|
+
- `TextDelta` - Incremental text chunks
|
|
66
|
+
- `TextDone` - Complete text
|
|
67
|
+
- `ToolCallDelta` - Incremental tool call arguments
|
|
68
|
+
- `ToolCallDone` - Complete tool call
|
|
69
|
+
|
|
70
|
+
See [Stream Events](06_STREAM_EVENTS.md) for details.
|
|
71
|
+
|
|
72
|
+
## Architecture
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
User Request
|
|
76
|
+
|
|
|
77
|
+
v
|
|
78
|
+
+------------+
|
|
79
|
+
| Agent | <-- Manages conversation flow
|
|
80
|
+
+------------+
|
|
81
|
+
|
|
|
82
|
+
v
|
|
83
|
+
+------------+
|
|
84
|
+
| Provider | <-- Calls LLM API
|
|
85
|
+
+------------+
|
|
86
|
+
|
|
|
87
|
+
v
|
|
88
|
+
+------------+
|
|
89
|
+
| LLM | <-- Returns response
|
|
90
|
+
+------------+
|
|
91
|
+
|
|
|
92
|
+
v
|
|
93
|
+
+------------+
|
|
94
|
+
| Tool? | <-- Execute if tool call present
|
|
95
|
+
+------------+
|
|
96
|
+
|
|
|
97
|
+
v
|
|
98
|
+
Response
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Next Steps
|
|
102
|
+
|
|
103
|
+
- [Getting Started](02_GETTING_STARTED.md) - Quick start guide
|
|
104
|
+
- [Agents](03_AGENTS.md) - Agent configuration and usage
|
|
105
|
+
- [Tools](04_TOOLS.md) - Creating tools
|
|
106
|
+
- [Configuration](07_CONFIGURATION.md) - Global configuration
|