ruby_llm 1.0.1 → 1.1.0rc2
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/README.md +28 -12
- data/lib/ruby_llm/active_record/acts_as.rb +46 -7
- data/lib/ruby_llm/aliases.json +65 -0
- data/lib/ruby_llm/aliases.rb +56 -0
- data/lib/ruby_llm/chat.rb +12 -9
- data/lib/ruby_llm/configuration.rb +4 -0
- data/lib/ruby_llm/error.rb +15 -4
- data/lib/ruby_llm/models.json +1163 -303
- data/lib/ruby_llm/models.rb +40 -11
- data/lib/ruby_llm/provider.rb +32 -39
- data/lib/ruby_llm/providers/anthropic/capabilities.rb +8 -9
- data/lib/ruby_llm/providers/anthropic/chat.rb +31 -4
- data/lib/ruby_llm/providers/anthropic/streaming.rb +12 -6
- data/lib/ruby_llm/providers/anthropic.rb +4 -0
- data/lib/ruby_llm/providers/bedrock/capabilities.rb +168 -0
- data/lib/ruby_llm/providers/bedrock/chat.rb +108 -0
- data/lib/ruby_llm/providers/bedrock/models.rb +84 -0
- data/lib/ruby_llm/providers/bedrock/signing.rb +831 -0
- data/lib/ruby_llm/providers/bedrock/streaming/base.rb +46 -0
- data/lib/ruby_llm/providers/bedrock/streaming/content_extraction.rb +63 -0
- data/lib/ruby_llm/providers/bedrock/streaming/message_processing.rb +79 -0
- data/lib/ruby_llm/providers/bedrock/streaming/payload_processing.rb +90 -0
- data/lib/ruby_llm/providers/bedrock/streaming/prelude_handling.rb +91 -0
- data/lib/ruby_llm/providers/bedrock/streaming.rb +36 -0
- data/lib/ruby_llm/providers/bedrock.rb +99 -0
- data/lib/ruby_llm/providers/deepseek/chat.rb +17 -0
- data/lib/ruby_llm/providers/deepseek.rb +5 -0
- data/lib/ruby_llm/providers/gemini/capabilities.rb +50 -34
- data/lib/ruby_llm/providers/gemini/chat.rb +8 -15
- data/lib/ruby_llm/providers/gemini/images.rb +5 -10
- data/lib/ruby_llm/providers/gemini/streaming.rb +35 -76
- data/lib/ruby_llm/providers/gemini/tools.rb +12 -12
- data/lib/ruby_llm/providers/gemini.rb +4 -0
- data/lib/ruby_llm/providers/openai/capabilities.rb +146 -206
- data/lib/ruby_llm/providers/openai/streaming.rb +9 -13
- data/lib/ruby_llm/providers/openai.rb +4 -0
- data/lib/ruby_llm/streaming.rb +96 -0
- data/lib/ruby_llm/tool.rb +0 -3
- data/lib/ruby_llm/version.rb +1 -1
- data/lib/ruby_llm.rb +6 -3
- data/lib/tasks/browser_helper.rb +97 -0
- data/lib/tasks/capability_generator.rb +123 -0
- data/lib/tasks/capability_scraper.rb +224 -0
- data/lib/tasks/cli_helper.rb +22 -0
- data/lib/tasks/code_validator.rb +29 -0
- data/lib/tasks/model_updater.rb +66 -0
- data/lib/tasks/models.rake +28 -193
- data/lib/tasks/models_docs.rake +156 -0
- data/lib/tasks/vcr.rake +13 -30
- metadata +28 -19
- data/.github/workflows/cicd.yml +0 -158
- data/.github/workflows/docs.yml +0 -53
- data/.gitignore +0 -59
- data/.overcommit.yml +0 -26
- data/.rspec +0 -3
- data/.rubocop.yml +0 -10
- data/.yardopts +0 -12
- data/CONTRIBUTING.md +0 -207
- data/Gemfile +0 -33
- data/Rakefile +0 -9
- data/bin/console +0 -17
- data/bin/setup +0 -6
- data/ruby_llm.gemspec +0 -44
data/.github/workflows/cicd.yml
DELETED
@@ -1,158 +0,0 @@
|
|
1
|
-
name: CI
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ "main" ]
|
6
|
-
paths:
|
7
|
-
- 'lib/**'
|
8
|
-
- 'spec/**'
|
9
|
-
- 'Gemfile'
|
10
|
-
- 'Rakefile'
|
11
|
-
- 'ruby_llm.gemspec'
|
12
|
-
- '.github/workflows/cicd.yml'
|
13
|
-
pull_request:
|
14
|
-
branches: [ "main" ]
|
15
|
-
paths:
|
16
|
-
- 'lib/**'
|
17
|
-
- 'spec/**'
|
18
|
-
- 'Gemfile'
|
19
|
-
- 'Rakefile'
|
20
|
-
- 'ruby_llm.gemspec'
|
21
|
-
- '.github/workflows/cicd.yml'
|
22
|
-
workflow_call:
|
23
|
-
|
24
|
-
# Define default permissions for this workflow
|
25
|
-
permissions:
|
26
|
-
contents: read
|
27
|
-
packages: write # Needed for publishing to GitHub Packages
|
28
|
-
|
29
|
-
jobs:
|
30
|
-
test:
|
31
|
-
runs-on: ubuntu-latest
|
32
|
-
strategy:
|
33
|
-
matrix:
|
34
|
-
ruby-version: ['3.1']
|
35
|
-
|
36
|
-
steps:
|
37
|
-
- uses: actions/checkout@v4
|
38
|
-
|
39
|
-
- name: Set up Ruby
|
40
|
-
uses: ruby/setup-ruby@v1
|
41
|
-
with:
|
42
|
-
ruby-version: ${{ matrix.ruby-version }}
|
43
|
-
bundler-cache: true
|
44
|
-
|
45
|
-
- name: Install dependencies
|
46
|
-
run: bundle install
|
47
|
-
|
48
|
-
- name: Check code format
|
49
|
-
run: bundle exec rubocop
|
50
|
-
|
51
|
-
- name: Run tests
|
52
|
-
env:
|
53
|
-
# For PRs, we use VCR cassettes
|
54
|
-
# For main branch, we use real API keys for verification
|
55
|
-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
56
|
-
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
57
|
-
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
58
|
-
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
|
59
|
-
run: bundle exec rspec
|
60
|
-
|
61
|
-
- name: Upload coverage to Codecov
|
62
|
-
uses: codecov/codecov-action@v5
|
63
|
-
env:
|
64
|
-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
65
|
-
with:
|
66
|
-
files: ./coverage/coverage.xml
|
67
|
-
fail_ci_if_error: false
|
68
|
-
|
69
|
-
publish:
|
70
|
-
name: Build + Publish
|
71
|
-
needs: test
|
72
|
-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
73
|
-
runs-on: ubuntu-latest
|
74
|
-
permissions:
|
75
|
-
contents: read
|
76
|
-
packages: write
|
77
|
-
|
78
|
-
steps:
|
79
|
-
- uses: actions/checkout@v4
|
80
|
-
|
81
|
-
- name: Set up Ruby
|
82
|
-
uses: ruby/setup-ruby@v1
|
83
|
-
with:
|
84
|
-
ruby-version: '3.3'
|
85
|
-
bundler-cache: true
|
86
|
-
|
87
|
-
- name: Check if version has changed
|
88
|
-
id: check_version
|
89
|
-
run: |
|
90
|
-
VERSION=$(ruby -r ./lib/ruby_llm/version.rb -e "puts RubyLLM::VERSION")
|
91
|
-
echo "Current version: $VERSION"
|
92
|
-
|
93
|
-
# Try to fetch from RubyGems
|
94
|
-
PUBLISHED_VERSION=$(gem list ruby_llm -r | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' || echo "0.0.0")
|
95
|
-
echo "Published version: $PUBLISHED_VERSION"
|
96
|
-
|
97
|
-
if [ "$VERSION" = "$PUBLISHED_VERSION" ]; then
|
98
|
-
echo "Version has not changed, skipping publish"
|
99
|
-
echo "version_changed=false" >> $GITHUB_OUTPUT
|
100
|
-
else
|
101
|
-
echo "Version has changed from $PUBLISHED_VERSION to $VERSION"
|
102
|
-
echo "version_changed=true" >> $GITHUB_OUTPUT
|
103
|
-
fi
|
104
|
-
|
105
|
-
- name: Test with real APIs before publishing
|
106
|
-
if: steps.check_version.outputs.version_changed == 'true'
|
107
|
-
run: |
|
108
|
-
echo "Removing all VCR cassettes to test against real APIs..."
|
109
|
-
rm -rf spec/fixtures/vcr_cassettes
|
110
|
-
|
111
|
-
echo "Running tests with real API calls..."
|
112
|
-
env -u CI bundle exec rspec
|
113
|
-
env:
|
114
|
-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
115
|
-
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
116
|
-
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
117
|
-
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
|
118
|
-
|
119
|
-
- name: Publish to GPR
|
120
|
-
if: steps.check_version.outputs.version_changed == 'true'
|
121
|
-
run: |
|
122
|
-
mkdir -p $HOME/.gem
|
123
|
-
touch $HOME/.gem/credentials
|
124
|
-
chmod 0600 $HOME/.gem/credentials
|
125
|
-
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
126
|
-
gem build *.gemspec
|
127
|
-
output=$(gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem 2>&1) || {
|
128
|
-
echo "$output"
|
129
|
-
if echo "$output" | grep -q "already been pushed"; then
|
130
|
-
echo "Version already exists, skipping"
|
131
|
-
exit 0
|
132
|
-
else
|
133
|
-
exit 1
|
134
|
-
fi
|
135
|
-
}
|
136
|
-
env:
|
137
|
-
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
138
|
-
OWNER: ${{ github.repository_owner }}
|
139
|
-
|
140
|
-
- name: Publish to RubyGems
|
141
|
-
if: steps.check_version.outputs.version_changed == 'true'
|
142
|
-
run: |
|
143
|
-
mkdir -p $HOME/.gem
|
144
|
-
touch $HOME/.gem/credentials
|
145
|
-
chmod 0600 $HOME/.gem/credentials
|
146
|
-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
147
|
-
gem build *.gemspec
|
148
|
-
output=$(gem push *.gem 2>&1) || {
|
149
|
-
echo "$output"
|
150
|
-
if echo "$output" | grep -q "Repushing of gem versions is not allowed"; then
|
151
|
-
echo "Version already exists, skipping"
|
152
|
-
exit 0
|
153
|
-
else
|
154
|
-
exit 1
|
155
|
-
fi
|
156
|
-
}
|
157
|
-
env:
|
158
|
-
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/.github/workflows/docs.yml
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
name: Deploy docs
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [main]
|
6
|
-
paths:
|
7
|
-
- 'docs/**'
|
8
|
-
- '.github/workflows/docs.yml'
|
9
|
-
workflow_dispatch:
|
10
|
-
|
11
|
-
permissions:
|
12
|
-
contents: read
|
13
|
-
pages: write
|
14
|
-
id-token: write
|
15
|
-
|
16
|
-
concurrency:
|
17
|
-
group: "pages"
|
18
|
-
cancel-in-progress: false
|
19
|
-
|
20
|
-
jobs:
|
21
|
-
build:
|
22
|
-
runs-on: ubuntu-latest
|
23
|
-
steps:
|
24
|
-
- name: Checkout
|
25
|
-
uses: actions/checkout@v4
|
26
|
-
- name: Setup Ruby
|
27
|
-
uses: ruby/setup-ruby@v1
|
28
|
-
with:
|
29
|
-
ruby-version: '3.3'
|
30
|
-
bundler-cache: true
|
31
|
-
working-directory: docs
|
32
|
-
- name: Setup Pages
|
33
|
-
uses: actions/configure-pages@v4
|
34
|
-
- name: Build with Jekyll
|
35
|
-
working-directory: docs
|
36
|
-
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
|
37
|
-
env:
|
38
|
-
JEKYLL_ENV: production
|
39
|
-
- name: Upload artifact
|
40
|
-
uses: actions/upload-pages-artifact@v3
|
41
|
-
with:
|
42
|
-
path: docs/_site
|
43
|
-
|
44
|
-
deploy:
|
45
|
-
environment:
|
46
|
-
name: github-pages
|
47
|
-
url: ${{ steps.deployment.outputs.page_url }}
|
48
|
-
runs-on: ubuntu-latest
|
49
|
-
needs: build
|
50
|
-
steps:
|
51
|
-
- name: Deploy to GitHub Pages
|
52
|
-
id: deployment
|
53
|
-
uses: actions/deploy-pages@v4
|
data/.gitignore
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
/.config
|
4
|
-
/coverage/
|
5
|
-
/InstalledFiles
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/spec/examples.txt
|
9
|
-
/test/tmp/
|
10
|
-
/test/version_tmp/
|
11
|
-
/tmp/
|
12
|
-
.rspec_status
|
13
|
-
|
14
|
-
# Used by dotenv library to load environment variables.
|
15
|
-
.env
|
16
|
-
|
17
|
-
# Ignore Byebug command history file.
|
18
|
-
.byebug_history
|
19
|
-
|
20
|
-
## Specific to RubyMotion:
|
21
|
-
.dat*
|
22
|
-
.repl_history
|
23
|
-
build/
|
24
|
-
*.bridgesupport
|
25
|
-
build-iPhoneOS/
|
26
|
-
build-iPhoneSimulator/
|
27
|
-
|
28
|
-
## Specific to RubyMotion (use of CocoaPods):
|
29
|
-
#
|
30
|
-
# We recommend against adding the Pods directory to your .gitignore. However
|
31
|
-
# you should judge for yourself, the pros and cons are mentioned at:
|
32
|
-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
33
|
-
#
|
34
|
-
# vendor/Pods/
|
35
|
-
|
36
|
-
## Documentation cache and generated files:
|
37
|
-
/.yardoc/
|
38
|
-
/_yardoc/
|
39
|
-
/doc/
|
40
|
-
/rdoc/
|
41
|
-
|
42
|
-
## Environment normalization:
|
43
|
-
/.bundle/
|
44
|
-
/vendor/bundle
|
45
|
-
/lib/bundler/man/
|
46
|
-
|
47
|
-
# for a library or gem, you might want to ignore these files since the code is
|
48
|
-
# intended to run in multiple environments; otherwise, check them in:
|
49
|
-
Gemfile.lock
|
50
|
-
# .ruby-version
|
51
|
-
# .ruby-gemset
|
52
|
-
|
53
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
54
|
-
.rvmrc
|
55
|
-
|
56
|
-
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
57
|
-
# .rubocop-https?--*
|
58
|
-
|
59
|
-
repomix-output.*
|
data/.overcommit.yml
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
PreCommit:
|
2
|
-
RuboCop:
|
3
|
-
enabled: true
|
4
|
-
auto_correct: true
|
5
|
-
on_warn: fail # Treat all warnings as failures
|
6
|
-
|
7
|
-
Flay:
|
8
|
-
enabled: true
|
9
|
-
|
10
|
-
RSpec:
|
11
|
-
enabled: true
|
12
|
-
command: ['bundle', 'exec', 'rspec']
|
13
|
-
on_warn: fail
|
14
|
-
|
15
|
-
TrailingWhitespace:
|
16
|
-
enabled: true
|
17
|
-
auto_correct: true
|
18
|
-
exclude:
|
19
|
-
- '**/db/structure.sql' # Ignore trailing whitespace in generated files
|
20
|
-
|
21
|
-
PostCheckout:
|
22
|
-
ALL: # Special hook name that customizes all hooks of this type
|
23
|
-
quiet: true # Change all post-checkout hooks to only display output on failure
|
24
|
-
|
25
|
-
IndexTags:
|
26
|
-
enabled: true # Generate a tags file with `ctags` each time HEAD changes
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
data/.yardopts
DELETED
data/CONTRIBUTING.md
DELETED
@@ -1,207 +0,0 @@
|
|
1
|
-
# Contributing to RubyLLM
|
2
|
-
|
3
|
-
First off, thank you for considering contributing to RubyLLM! It's people like you that make RubyLLM such a great tool.
|
4
|
-
|
5
|
-
## Development Setup
|
6
|
-
|
7
|
-
Here's how to get started:
|
8
|
-
|
9
|
-
```bash
|
10
|
-
# Clone the repository
|
11
|
-
gh repo clone crmne/ruby_llm
|
12
|
-
cd ruby_llm
|
13
|
-
|
14
|
-
# Install dependencies
|
15
|
-
bundle install
|
16
|
-
|
17
|
-
# Set up git hooks
|
18
|
-
overcommit --install
|
19
|
-
|
20
|
-
# Run the tests (uses VCR cassettes)
|
21
|
-
bundle exec rspec
|
22
|
-
```
|
23
|
-
|
24
|
-
## Development Workflow
|
25
|
-
|
26
|
-
We recommend using GitHub CLI to simplify the workflow:
|
27
|
-
|
28
|
-
```bash
|
29
|
-
# Create a new branch for your feature
|
30
|
-
gh repo fork crmne/ruby_llm --clone
|
31
|
-
cd ruby_llm
|
32
|
-
|
33
|
-
# Find or make an issue for the feature on GitHub and then:
|
34
|
-
gh issue develop 123 --checkout # Substitute 123 with the issue number
|
35
|
-
|
36
|
-
# Make your changes and test them
|
37
|
-
# ...
|
38
|
-
|
39
|
-
# Commit your changes
|
40
|
-
git commit
|
41
|
-
|
42
|
-
# Create a PR
|
43
|
-
gh pr create --web
|
44
|
-
```
|
45
|
-
|
46
|
-
## Model Naming Convention & Provider Strategy
|
47
|
-
|
48
|
-
When adding new providers to RubyLLM, please follow these guidelines:
|
49
|
-
|
50
|
-
### Normalized Model IDs
|
51
|
-
|
52
|
-
We use a consistent approach separating **what** (model) from **where** (provider):
|
53
|
-
|
54
|
-
```ruby
|
55
|
-
# Default way (from the native provider)
|
56
|
-
chat = RubyLLM.chat(model: "claude-3-5-sonnet")
|
57
|
-
|
58
|
-
# Same model via different provider
|
59
|
-
chat = RubyLLM.chat(model: "claude-3-5-sonnet", provider: :bedrock)
|
60
|
-
```
|
61
|
-
|
62
|
-
### Implementing a Provider
|
63
|
-
|
64
|
-
If you're adding a new provider:
|
65
|
-
|
66
|
-
1. **Use normalized model IDs** - Don't include provider prefixes in the model ID itself
|
67
|
-
2. **Add provider mapping** - Map the normalized IDs to your provider's specific format internally
|
68
|
-
3. **Preserve capabilities** - Ensure models accessed through your provider report the same capabilities as their native counterparts
|
69
|
-
4. **Update models.json** - Include your provider's models in models.json
|
70
|
-
5. **Update aliases.json** - Add entries to aliases.json for models accessible through your provider
|
71
|
-
6. **Implement refresh mechanism** - Ensure your provider supports the `list_models` method for refreshing
|
72
|
-
|
73
|
-
### Model Aliases
|
74
|
-
|
75
|
-
For providers that use complex model identifiers (like Bedrock's `anthropic.claude-3-5-sonnet-20241022-v2:0:200k`), add mappings to the global aliases.json file:
|
76
|
-
|
77
|
-
```json
|
78
|
-
{
|
79
|
-
"claude-3-5-sonnet": {
|
80
|
-
"anthropic": "claude-3-5-sonnet-20241022",
|
81
|
-
"bedrock": "anthropic.claude-3-5-sonnet-20241022-v2:0:200k",
|
82
|
-
"openrouter": "anthropic/claude-3.5-sonnet"
|
83
|
-
},
|
84
|
-
"gpt-4o": {
|
85
|
-
"openai": "gpt-4o-2024-05-13",
|
86
|
-
"bedrock": "anthropic.gpt-4o-2024-05-13",
|
87
|
-
"openrouter": "openai/gpt-4o"
|
88
|
-
}
|
89
|
-
}
|
90
|
-
```
|
91
|
-
|
92
|
-
If a model can't be found with the provided ID and provider, a `ModelNotFoundError` will be raised with an informative message. Your implementation should make this error helpful by suggesting available alternatives.
|
93
|
-
|
94
|
-
When the same model has multiple versions and context windows e.g.
|
95
|
-
|
96
|
-
```
|
97
|
-
anthropic.claude-3-5-sonnet-20240620-v1:0
|
98
|
-
anthropic.claude-3-5-sonnet-20240620-v1:0:18k
|
99
|
-
anthropic.claude-3-5-sonnet-20240620-v1:0:200k
|
100
|
-
anthropic.claude-3-5-sonnet-20240620-v1:0:51k
|
101
|
-
anthropic.claude-3-5-sonnet-20241022-v2:0
|
102
|
-
anthropic.claude-3-5-sonnet-20241022-v2:0:18k
|
103
|
-
anthropic.claude-3-5-sonnet-20241022-v2:0:200k
|
104
|
-
anthropic.claude-3-5-sonnet-20241022-v2:0:51k
|
105
|
-
```
|
106
|
-
|
107
|
-
We default all aliases to the biggest context window, and the main alias (without date) to the latest version:
|
108
|
-
|
109
|
-
```json
|
110
|
-
"claude-3-5-sonnet": {
|
111
|
-
"anthropic": "claude-3-5-sonnet-20241022",
|
112
|
-
"bedrock": "anthropic.claude-3-5-sonnet-20241022-v2:0:200k",
|
113
|
-
"openrouter": "anthropic/claude-3.5-sonnet"
|
114
|
-
},
|
115
|
-
"claude-3-5-sonnet-20241022": {
|
116
|
-
"anthropic": "claude-3-5-sonnet-20241022",
|
117
|
-
"bedrock": "anthropic.claude-3-5-sonnet-20241022-v2:0:200k",
|
118
|
-
"openrouter": "anthropic/claude-3.5-sonnet"
|
119
|
-
},
|
120
|
-
"claude-3-5-sonnet-20240620": {
|
121
|
-
"anthropic": "claude-3-5-sonnet-20240620",
|
122
|
-
"bedrock": "anthropic.claude-3-5-sonnet-20240620-v1:0:200k"
|
123
|
-
},
|
124
|
-
```
|
125
|
-
|
126
|
-
## Running Tests
|
127
|
-
|
128
|
-
Tests automatically use VCR to record and replay HTTP interactions, so you don't need real API keys for testing:
|
129
|
-
|
130
|
-
```bash
|
131
|
-
# Run all tests (using existing VCR cassettes)
|
132
|
-
bundle exec rspec
|
133
|
-
|
134
|
-
# Run a specific test file
|
135
|
-
bundle exec rspec spec/ruby_llm/chat_spec.rb
|
136
|
-
```
|
137
|
-
|
138
|
-
### Recording VCR Cassettes
|
139
|
-
|
140
|
-
When you make changes that affect API interactions, you can record new VCR cassettes.
|
141
|
-
|
142
|
-
If you have keys for all providers:
|
143
|
-
|
144
|
-
```bash
|
145
|
-
# Re-record all cassettes
|
146
|
-
bundle exec rake vcr:record[all]
|
147
|
-
```
|
148
|
-
|
149
|
-
If you only have keys for specific providers (e.g., just OpenAI):
|
150
|
-
|
151
|
-
```bash
|
152
|
-
# Set the API keys you have
|
153
|
-
export OPENAI_API_KEY=your_openai_key
|
154
|
-
|
155
|
-
# Find and remove only cassettes for OpenAI, then run tests to re-record them
|
156
|
-
bundle exec rake vcr:record[openai]
|
157
|
-
|
158
|
-
# You can also specify multiple providers
|
159
|
-
bundle exec rake vcr:record[openai,anthropic]
|
160
|
-
```
|
161
|
-
|
162
|
-
Important: After recording new cassettes, please **manually check** them for any sensitive information that might have been missed by the automatic filters.
|
163
|
-
|
164
|
-
## Adding New Tests
|
165
|
-
|
166
|
-
Tests automatically create VCR cassettes based on their descriptions, so make sure your test descriptions are unique and descriptive.
|
167
|
-
|
168
|
-
## Coding Style
|
169
|
-
|
170
|
-
We follow the [Standard Ruby](https://github.com/testdouble/standard) style. Please ensure your contributions adhere to this style.
|
171
|
-
|
172
|
-
```bash
|
173
|
-
# Check your code style
|
174
|
-
bundle exec rubocop
|
175
|
-
|
176
|
-
# Auto-fix style issues where possible
|
177
|
-
bundle exec rubocop -A
|
178
|
-
```
|
179
|
-
|
180
|
-
## Documentation
|
181
|
-
|
182
|
-
When adding new features, please include documentation updates:
|
183
|
-
|
184
|
-
- Update relevant guides in the `docs/guides/` directory
|
185
|
-
- Add inline documentation using YARD comments
|
186
|
-
- Keep the README clean and focused on helping new users get started quickly
|
187
|
-
|
188
|
-
## Philosophy
|
189
|
-
|
190
|
-
RubyLLM follows certain design philosophies and conventions. Please refer to our [Philosophy Guide](https://rubyllm.com/philosophy) to ensure your contributions align with the project's vision.
|
191
|
-
|
192
|
-
## Discussions and Issues
|
193
|
-
|
194
|
-
- For questions and discussions, please use [GitHub Discussions](https://github.com/crmne/ruby_llm/discussions)
|
195
|
-
- For bugs and feature requests, please use [GitHub Issues](https://github.com/crmne/ruby_llm/issues)
|
196
|
-
|
197
|
-
## Release Process
|
198
|
-
|
199
|
-
Gem versioning follows [Semantic Versioning](https://semver.org/):
|
200
|
-
|
201
|
-
1. MAJOR version for incompatible API changes
|
202
|
-
2. MINOR version for backwards-compatible functionality
|
203
|
-
3. PATCH version for backwards-compatible bug fixes
|
204
|
-
|
205
|
-
Releases are handled by the maintainers through the CI/CD pipeline.
|
206
|
-
|
207
|
-
Thanks for helping make RubyLLM better!
|
data/Gemfile
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
gemspec
|
6
|
-
|
7
|
-
group :development do
|
8
|
-
# Rails integration dependencies
|
9
|
-
gem 'activerecord', '>= 6.0', '< 9.0'
|
10
|
-
gem 'activesupport', '>= 6.0', '< 9.0'
|
11
|
-
|
12
|
-
# Development dependencies
|
13
|
-
gem 'bundler', '>= 2.0'
|
14
|
-
gem 'codecov'
|
15
|
-
gem 'dotenv'
|
16
|
-
gem 'irb'
|
17
|
-
gem 'nokogiri'
|
18
|
-
gem 'overcommit', '>= 0.66'
|
19
|
-
gem 'pry', '>= 0.14'
|
20
|
-
gem 'rake', '>= 13.0'
|
21
|
-
gem 'rdoc'
|
22
|
-
gem 'reline'
|
23
|
-
gem 'rspec', '~> 3.12'
|
24
|
-
gem 'rubocop', '>= 1.0'
|
25
|
-
gem 'rubocop-rake', '>= 0.6'
|
26
|
-
gem 'rubocop-rspec'
|
27
|
-
gem 'simplecov', '>= 0.21'
|
28
|
-
gem 'simplecov-cobertura'
|
29
|
-
gem 'sqlite3'
|
30
|
-
gem 'vcr'
|
31
|
-
gem 'webmock', '~> 3.18'
|
32
|
-
gem 'yard', '>= 0.9'
|
33
|
-
end
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'bundler/setup'
|
5
|
-
require 'ruby_llm'
|
6
|
-
require 'dotenv/load'
|
7
|
-
|
8
|
-
require 'irb'
|
9
|
-
|
10
|
-
RubyLLM.configure do |config|
|
11
|
-
config.openai_api_key = ENV.fetch('OPENAI_API_KEY', nil)
|
12
|
-
config.anthropic_api_key = ENV.fetch('ANTHROPIC_API_KEY', nil)
|
13
|
-
config.gemini_api_key = ENV.fetch('GEMINI_API_KEY', nil)
|
14
|
-
config.deepseek_api_key = ENV.fetch('DEEPSEEK_API_KEY', nil)
|
15
|
-
end
|
16
|
-
|
17
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/ruby_llm.gemspec
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'lib/ruby_llm/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = 'ruby_llm'
|
7
|
-
spec.version = RubyLLM::VERSION
|
8
|
-
spec.authors = ['Carmine Paolino']
|
9
|
-
spec.email = ['carmine@paolino.me']
|
10
|
-
|
11
|
-
spec.summary = 'Beautiful Ruby interface to modern AI'
|
12
|
-
spec.description = 'A delightful Ruby way to work with AI. Chat in text, analyze and generate images, understand ' \
|
13
|
-
'audio, and use tools through a unified interface to OpenAI, Anthropic, Google, and DeepSeek. ' \
|
14
|
-
'Built for developer happiness with automatic token counting, proper streaming, and Rails ' \
|
15
|
-
'integration. No wrapping your head around multiple APIs - just clean Ruby code that works.'
|
16
|
-
spec.homepage = 'https://rubyllm.com'
|
17
|
-
spec.license = 'MIT'
|
18
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 3.1.0')
|
19
|
-
|
20
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
21
|
-
spec.metadata['source_code_uri'] = 'https://github.com/crmne/ruby_llm'
|
22
|
-
spec.metadata['changelog_uri'] = "#{spec.metadata['source_code_uri']}/commits/main"
|
23
|
-
spec.metadata['documentation_uri'] = spec.homepage
|
24
|
-
spec.metadata['bug_tracker_uri'] = "#{spec.metadata['source_code_uri']}/issues"
|
25
|
-
|
26
|
-
spec.metadata['rubygems_mfa_required'] = 'true'
|
27
|
-
|
28
|
-
# Specify which files should be added to the gem when it is released.
|
29
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
31
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|docs)/}) }
|
32
|
-
end
|
33
|
-
spec.bindir = 'exe'
|
34
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
-
spec.require_paths = ['lib']
|
36
|
-
|
37
|
-
# Runtime dependencies
|
38
|
-
spec.add_dependency 'base64'
|
39
|
-
spec.add_dependency 'event_stream_parser', '~> 1'
|
40
|
-
spec.add_dependency 'faraday', '~> 2'
|
41
|
-
spec.add_dependency 'faraday-multipart', '~> 1'
|
42
|
-
spec.add_dependency 'faraday-retry', '~> 2'
|
43
|
-
spec.add_dependency 'zeitwerk', '~> 2'
|
44
|
-
end
|