ruby_llm-providers-groq 2.0.0.pre.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 +7 -0
- data/.flayignore +1 -0
- data/.github/workflows/ci.yml +30 -0
- data/.github/workflows/gitleaks.yml +22 -0
- data/.github/workflows/release.yml +36 -0
- data/.overcommit.yml +31 -0
- data/.rspec +2 -0
- data/.rubocop.yml +29 -0
- data/Archspec.rb +14 -0
- data/LICENSE +21 -0
- data/README.md +57 -0
- data/lib/ruby_llm/providers/groq.rb +70 -0
- data/models.json +218 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_groq_openai_gpt_oss_120b_can_handle_a_multi_turn_conversation.yml +153 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_groq_openai_gpt_oss_120b_can_have_a_basic_conversation.yml +75 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_groq_openai_gpt_oss_120b_can_use_tools.yml +153 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_groq_openai_gpt_oss_120b_returns_structured_output.yml +80 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_groq_openai_gpt_oss_120b_returns_the_raw_response.yml +79 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_groq_openai_gpt_oss_120b_supports_streaming_responses.yml +252 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_groq_qwen_qwen3_8_27b_can_handle_a_multi_turn_conversation.yml +160 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_groq_qwen_qwen3_8_27b_can_have_a_basic_conversation.yml +77 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_groq_qwen_qwen3_8_27b_can_use_tools.yml +152 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_groq_qwen_qwen3_8_27b_returns_structured_output.yml +77 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_groq_qwen_qwen3_8_27b_returns_the_raw_response.yml +77 -0
- data/spec/fixtures/vcr_cassettes/rubyllm_chat_groq_qwen_qwen3_8_27b_supports_streaming_responses.yml +126 -0
- data/spec/ruby_llm/chat_schema_spec.rb +30 -0
- data/spec/ruby_llm/chat_spec.rb +35 -0
- data/spec/ruby_llm/chat_streaming_spec.rb +22 -0
- data/spec/ruby_llm/chat_tools_spec.rb +31 -0
- data/spec/ruby_llm/embedding_spec.rb +49 -0
- data/spec/ruby_llm/image_spec.rb +23 -0
- data/spec/ruby_llm/models_spec.rb +11 -0
- data/spec/ruby_llm/moderation_spec.rb +22 -0
- data/spec/ruby_llm/providers/groq_spec.rb +32 -0
- data/spec/ruby_llm/rerank_spec.rb +23 -0
- data/spec/ruby_llm/speech_spec.rb +25 -0
- data/spec/ruby_llm/video_spec.rb +27 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/support/models.rb +22 -0
- data/spec/support/rubyllm_configuration.rb +14 -0
- data/spec/support/vcr_configuration.rb +16 -0
- metadata +105 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Moderation, :live do
|
|
6
|
+
include_context 'with configured RubyLLM'
|
|
7
|
+
|
|
8
|
+
each_model(MODERATION_MODELS) do |provider, model|
|
|
9
|
+
it "#{provider}/#{model} moderates content" do
|
|
10
|
+
moderation = RubyLLM.moderate(
|
|
11
|
+
'This is a safe message',
|
|
12
|
+
model: model,
|
|
13
|
+
provider: provider,
|
|
14
|
+
assume_model_exists: true
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
expect(moderation).to be_a(described_class)
|
|
18
|
+
expect(moderation.results).to all(be_a(RubyLLM::Moderation::Result))
|
|
19
|
+
expect(moderation.flagged?).to be_in([true, false])
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Providers::Groq do
|
|
6
|
+
subject(:provider) { described_class.new(config) }
|
|
7
|
+
|
|
8
|
+
let(:config) do
|
|
9
|
+
RubyLLM::Configuration.new.tap do |provider_config|
|
|
10
|
+
provider_config.groq_api_key = 'test-key'
|
|
11
|
+
provider_config.groq_api_base = 'https://example.test/v1'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'is registered with RubyLLM' do
|
|
16
|
+
expect(RubyLLM::Provider.resolve(:groq)).to eq(described_class)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'registers a default protocol' do
|
|
20
|
+
expect(described_class.protocols).to include(responses: described_class::Responses)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'declares provider configuration' do
|
|
24
|
+
expect(described_class.configuration_options).to eq(%i[groq_api_key groq_api_base])
|
|
25
|
+
expect(described_class.configuration_requirements).to eq(%i[groq_api_key])
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'uses configured API base and bearer token' do
|
|
29
|
+
expect(provider.api_base).to eq('https://example.test/v1')
|
|
30
|
+
expect(provider.headers).to eq('Authorization' => 'Bearer test-key')
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Rerank, :live do
|
|
6
|
+
include_context 'with configured RubyLLM'
|
|
7
|
+
|
|
8
|
+
each_model(RERANK_MODELS) do |provider, model|
|
|
9
|
+
it "#{provider}/#{model} orders documents by relevance" do
|
|
10
|
+
rerank = RubyLLM.rerank(
|
|
11
|
+
'What is the capital of the United States?',
|
|
12
|
+
['Carson City is the capital of Nevada.', 'Washington, D.C. is the capital of the United States.'],
|
|
13
|
+
model: model,
|
|
14
|
+
provider: provider,
|
|
15
|
+
assume_model_exists: true
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
expect(rerank.results.first.document).to include('Washington')
|
|
19
|
+
expect(rerank.results.first.score).to be > rerank.results.last.score
|
|
20
|
+
expect(rerank.results.map(&:index)).to contain_exactly(0, 1)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Speech, :live do
|
|
6
|
+
include_context 'with configured RubyLLM'
|
|
7
|
+
|
|
8
|
+
each_model(SPEECH_MODELS) do |provider, model, model_info|
|
|
9
|
+
it "#{provider}/#{model} speaks" do
|
|
10
|
+
speech = RubyLLM.speak(
|
|
11
|
+
'Ruby is a programming language designed for developer happiness.',
|
|
12
|
+
model: model,
|
|
13
|
+
provider: provider,
|
|
14
|
+
assume_model_exists: true,
|
|
15
|
+
voice: model_info[:voice],
|
|
16
|
+
format: model_info[:format]
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
expect(speech.data).to be_a(String)
|
|
20
|
+
expect(speech.data.bytesize).to be > 1000
|
|
21
|
+
expect(speech.model).to eq(model)
|
|
22
|
+
expect(speech.mime_type).to start_with('audio/')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyLLM::Video, :live do
|
|
6
|
+
include_context 'with configured RubyLLM'
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
RubyLLM.config.video_generation_poll_interval = VCR.current_cassette&.recording? ? 5 : 0
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
each_model(VIDEO_GENERATION_MODELS) do |provider, model, model_info|
|
|
13
|
+
it "#{provider}/#{model} animates a video" do
|
|
14
|
+
video = RubyLLM.animate(
|
|
15
|
+
'a calm ocean wave at sunset',
|
|
16
|
+
model: model,
|
|
17
|
+
provider: provider,
|
|
18
|
+
assume_model_exists: true,
|
|
19
|
+
provider_options: model_info.fetch(:provider_options, {})
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
expect(video.mime_type).to include('video')
|
|
23
|
+
expect(video.url || video.data).not_to be_nil
|
|
24
|
+
expect(video.to_blob.bytesize).to be > 10_000
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'dotenv/load'
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
|
|
7
|
+
require 'vcr'
|
|
8
|
+
require 'ruby_llm/providers/groq'
|
|
9
|
+
require 'webmock/rspec'
|
|
10
|
+
|
|
11
|
+
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |file| require file }
|
|
12
|
+
|
|
13
|
+
RSpec.configure do |config|
|
|
14
|
+
config.disable_monkey_patching!
|
|
15
|
+
config.expect_with(:rspec) { |expectations| expectations.syntax = :expect }
|
|
16
|
+
config.order = :random
|
|
17
|
+
Kernel.srand config.seed
|
|
18
|
+
|
|
19
|
+
config.around(:each, :live) do |example|
|
|
20
|
+
cassette_name = example.full_description.downcase.gsub(/[^a-z0-9]+/, '_').delete_prefix('_').delete_suffix('_')
|
|
21
|
+
cassette_path = File.join(VCR.configuration.cassette_library_dir, "#{cassette_name}.yml")
|
|
22
|
+
|
|
23
|
+
VCR.use_cassette(cassette_name) { example.run }
|
|
24
|
+
FileUtils.rm_f(cassette_path) if example.exception
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Remove chat-derived matrices the model does not support and add real ids for the empty operation matrices.
|
|
4
|
+
# See RubyLLM's full live matrix and specs: https://github.com/crmne/ruby_llm/tree/main/spec
|
|
5
|
+
PROVIDER = :groq
|
|
6
|
+
CHAT_MODELS = [
|
|
7
|
+
{ provider: :groq, model: 'openai/gpt-oss-120b' },
|
|
8
|
+
{ provider: :groq, model: 'qwen/qwen3.8-27b' }
|
|
9
|
+
].freeze
|
|
10
|
+
TOOL_MODELS = CHAT_MODELS
|
|
11
|
+
STRUCTURED_OUTPUT_MODELS = CHAT_MODELS
|
|
12
|
+
|
|
13
|
+
EMBEDDING_MODELS = [].freeze
|
|
14
|
+
IMAGE_GENERATION_MODELS = [].freeze
|
|
15
|
+
SPEECH_MODELS = [].freeze
|
|
16
|
+
VIDEO_GENERATION_MODELS = [].freeze
|
|
17
|
+
MODERATION_MODELS = [].freeze
|
|
18
|
+
RERANK_MODELS = [].freeze
|
|
19
|
+
|
|
20
|
+
def each_model(models)
|
|
21
|
+
models.each { |model_info| yield model_info[:provider], model_info[:model], model_info }
|
|
22
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.shared_context 'with configured RubyLLM' do
|
|
4
|
+
before do
|
|
5
|
+
RubyLLM.configure do |config|
|
|
6
|
+
config.groq_api_key = ENV.fetch('GROQ_API_KEY', 'test')
|
|
7
|
+
config.groq_api_base = ENV.fetch('GROQ_API_BASE', 'https://api.groq.com/openai/v1')
|
|
8
|
+
config.max_retries = 0
|
|
9
|
+
config.retry_backoff_factor = 0
|
|
10
|
+
config.retry_interval = 0
|
|
11
|
+
config.retry_interval_randomness = 0
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
VCR.configure do |config|
|
|
4
|
+
config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
|
5
|
+
config.hook_into :webmock
|
|
6
|
+
config.default_cassette_options = { record: ENV['CI'] ? :none : :once }
|
|
7
|
+
config.allow_http_connections_when_no_cassette = true
|
|
8
|
+
config.filter_sensitive_data('<GROQ_API_KEY>') { ENV.fetch('GROQ_API_KEY', nil) }
|
|
9
|
+
config.filter_sensitive_data('https://api.groq.com/openai/v1') { ENV.fetch('GROQ_API_BASE', nil) }
|
|
10
|
+
|
|
11
|
+
config.before_record do |interaction|
|
|
12
|
+
next unless interaction.request.headers['Authorization']
|
|
13
|
+
|
|
14
|
+
interaction.request.headers['Authorization'] = ['Bearer <AUTH_TOKEN>']
|
|
15
|
+
end
|
|
16
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ruby_llm-providers-groq
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 2.0.0.pre.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Siarhiej Siamaška
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: ruby_llm
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.0'
|
|
19
|
+
- - ">="
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 2.0.0
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - "~>"
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '2.0'
|
|
29
|
+
- - ">="
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: 2.0.0
|
|
32
|
+
description: Adds Groq provider support to RubyLLM.
|
|
33
|
+
email:
|
|
34
|
+
- siarhei.siamashka@gmail.com
|
|
35
|
+
executables: []
|
|
36
|
+
extensions: []
|
|
37
|
+
extra_rdoc_files: []
|
|
38
|
+
files:
|
|
39
|
+
- ".flayignore"
|
|
40
|
+
- ".github/workflows/ci.yml"
|
|
41
|
+
- ".github/workflows/gitleaks.yml"
|
|
42
|
+
- ".github/workflows/release.yml"
|
|
43
|
+
- ".overcommit.yml"
|
|
44
|
+
- ".rspec"
|
|
45
|
+
- ".rubocop.yml"
|
|
46
|
+
- Archspec.rb
|
|
47
|
+
- LICENSE
|
|
48
|
+
- README.md
|
|
49
|
+
- lib/ruby_llm/providers/groq.rb
|
|
50
|
+
- models.json
|
|
51
|
+
- spec/fixtures/vcr_cassettes/rubyllm_chat_groq_openai_gpt_oss_120b_can_handle_a_multi_turn_conversation.yml
|
|
52
|
+
- spec/fixtures/vcr_cassettes/rubyllm_chat_groq_openai_gpt_oss_120b_can_have_a_basic_conversation.yml
|
|
53
|
+
- spec/fixtures/vcr_cassettes/rubyllm_chat_groq_openai_gpt_oss_120b_can_use_tools.yml
|
|
54
|
+
- spec/fixtures/vcr_cassettes/rubyllm_chat_groq_openai_gpt_oss_120b_returns_structured_output.yml
|
|
55
|
+
- spec/fixtures/vcr_cassettes/rubyllm_chat_groq_openai_gpt_oss_120b_returns_the_raw_response.yml
|
|
56
|
+
- spec/fixtures/vcr_cassettes/rubyllm_chat_groq_openai_gpt_oss_120b_supports_streaming_responses.yml
|
|
57
|
+
- spec/fixtures/vcr_cassettes/rubyllm_chat_groq_qwen_qwen3_8_27b_can_handle_a_multi_turn_conversation.yml
|
|
58
|
+
- spec/fixtures/vcr_cassettes/rubyllm_chat_groq_qwen_qwen3_8_27b_can_have_a_basic_conversation.yml
|
|
59
|
+
- spec/fixtures/vcr_cassettes/rubyllm_chat_groq_qwen_qwen3_8_27b_can_use_tools.yml
|
|
60
|
+
- spec/fixtures/vcr_cassettes/rubyllm_chat_groq_qwen_qwen3_8_27b_returns_structured_output.yml
|
|
61
|
+
- spec/fixtures/vcr_cassettes/rubyllm_chat_groq_qwen_qwen3_8_27b_returns_the_raw_response.yml
|
|
62
|
+
- spec/fixtures/vcr_cassettes/rubyllm_chat_groq_qwen_qwen3_8_27b_supports_streaming_responses.yml
|
|
63
|
+
- spec/ruby_llm/chat_schema_spec.rb
|
|
64
|
+
- spec/ruby_llm/chat_spec.rb
|
|
65
|
+
- spec/ruby_llm/chat_streaming_spec.rb
|
|
66
|
+
- spec/ruby_llm/chat_tools_spec.rb
|
|
67
|
+
- spec/ruby_llm/embedding_spec.rb
|
|
68
|
+
- spec/ruby_llm/image_spec.rb
|
|
69
|
+
- spec/ruby_llm/models_spec.rb
|
|
70
|
+
- spec/ruby_llm/moderation_spec.rb
|
|
71
|
+
- spec/ruby_llm/providers/groq_spec.rb
|
|
72
|
+
- spec/ruby_llm/rerank_spec.rb
|
|
73
|
+
- spec/ruby_llm/speech_spec.rb
|
|
74
|
+
- spec/ruby_llm/video_spec.rb
|
|
75
|
+
- spec/spec_helper.rb
|
|
76
|
+
- spec/support/models.rb
|
|
77
|
+
- spec/support/rubyllm_configuration.rb
|
|
78
|
+
- spec/support/vcr_configuration.rb
|
|
79
|
+
homepage: https://github.com/ssvb/ruby_llm-providers-groq
|
|
80
|
+
licenses:
|
|
81
|
+
- MIT
|
|
82
|
+
metadata:
|
|
83
|
+
homepage_uri: https://github.com/ssvb/ruby_llm-providers-groq
|
|
84
|
+
source_code_uri: https://github.com/ssvb/ruby_llm-providers-groq
|
|
85
|
+
changelog_uri: https://github.com/ssvb/ruby_llm-providers-groq/releases
|
|
86
|
+
bug_tracker_uri: https://github.com/ssvb/ruby_llm-providers-groq/issues
|
|
87
|
+
rubygems_mfa_required: 'true'
|
|
88
|
+
rdoc_options: []
|
|
89
|
+
require_paths:
|
|
90
|
+
- lib
|
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '3.3'
|
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
|
+
requirements:
|
|
98
|
+
- - ">="
|
|
99
|
+
- !ruby/object:Gem::Version
|
|
100
|
+
version: '0'
|
|
101
|
+
requirements: []
|
|
102
|
+
rubygems_version: 3.6.9
|
|
103
|
+
specification_version: 4
|
|
104
|
+
summary: RubyLLM provider for Groq.
|
|
105
|
+
test_files: []
|