ruby_llm 1.3.0 → 1.3.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/README.md +13 -9
- data/lib/ruby_llm/active_record/acts_as.rb +1 -0
- data/lib/ruby_llm/aliases.json +8 -0
- data/lib/ruby_llm/configuration.rb +1 -0
- data/lib/ruby_llm/models.json +979 -839
- data/lib/ruby_llm/providers/anthropic/tools.rb +5 -4
- data/lib/ruby_llm/providers/bedrock/streaming/prelude_handling.rb +3 -3
- data/lib/ruby_llm/providers/openai/capabilities.rb +4 -1
- data/lib/ruby_llm/providers/openai/chat.rb +12 -8
- data/lib/ruby_llm/tool.rb +8 -8
- data/lib/ruby_llm/version.rb +1 -1
- data/lib/ruby_llm.rb +1 -1
- data/lib/tasks/models_docs.rake +13 -7
- metadata +1 -1
@@ -14,12 +14,13 @@ module RubyLLM
|
|
14
14
|
def format_tool_call(msg)
|
15
15
|
tool_call = msg.tool_calls.values.first
|
16
16
|
|
17
|
+
content = []
|
18
|
+
content << Media.format_text(msg.content) unless msg.content.nil? || msg.content.empty?
|
19
|
+
content << format_tool_use_block(tool_call)
|
20
|
+
|
17
21
|
{
|
18
22
|
role: 'assistant',
|
19
|
-
content:
|
20
|
-
Media.format_text(msg.content),
|
21
|
-
format_tool_use_block(tool_call)
|
22
|
-
]
|
23
|
+
content:
|
23
24
|
}
|
24
25
|
end
|
25
26
|
|
@@ -30,7 +30,7 @@ module RubyLLM
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def valid_lengths?(total_length, headers_length)
|
33
|
-
|
33
|
+
valid_length_constraints?(total_length, headers_length)
|
34
34
|
end
|
35
35
|
|
36
36
|
def calculate_positions(offset, total_length, headers_length)
|
@@ -67,7 +67,7 @@ module RubyLLM
|
|
67
67
|
|
68
68
|
def valid_prelude_at_position?(chunk, pos)
|
69
69
|
lengths = extract_potential_lengths(chunk, pos)
|
70
|
-
|
70
|
+
valid_length_constraints?(*lengths)
|
71
71
|
end
|
72
72
|
|
73
73
|
def extract_potential_lengths(chunk, pos)
|
@@ -77,7 +77,7 @@ module RubyLLM
|
|
77
77
|
]
|
78
78
|
end
|
79
79
|
|
80
|
-
def
|
80
|
+
def valid_length_constraints?(total_length, headers_length)
|
81
81
|
return false if total_length.nil? || headers_length.nil?
|
82
82
|
return false if total_length <= 0 || total_length > 1_000_000
|
83
83
|
return false if headers_length <= 0 || headers_length >= total_length
|
@@ -215,10 +215,13 @@ module RubyLLM
|
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
218
|
-
def normalize_temperature(temperature, model_id)
|
218
|
+
def self.normalize_temperature(temperature, model_id)
|
219
219
|
if model_id.match?(/^o\d/)
|
220
220
|
RubyLLM.logger.debug "Model #{model_id} requires temperature=1.0, ignoring provided value"
|
221
221
|
1.0
|
222
|
+
elsif model_id.match?(/-search/)
|
223
|
+
RubyLLM.logger.debug "Model #{model_id} does not accept temperature parameter, removing"
|
224
|
+
nil
|
222
225
|
else
|
223
226
|
temperature
|
224
227
|
end
|
@@ -12,18 +12,22 @@ module RubyLLM
|
|
12
12
|
module_function
|
13
13
|
|
14
14
|
def render_payload(messages, tools:, temperature:, model:, stream: false)
|
15
|
-
{
|
15
|
+
payload = {
|
16
16
|
model: model,
|
17
17
|
messages: format_messages(messages),
|
18
|
-
temperature: temperature,
|
19
18
|
stream: stream
|
20
|
-
}
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
}
|
20
|
+
|
21
|
+
# Only include temperature if it's not nil (some models don't accept it)
|
22
|
+
payload[:temperature] = temperature unless temperature.nil?
|
23
|
+
|
24
|
+
if tools.any?
|
25
|
+
payload[:tools] = tools.map { |_, tool| tool_for(tool) }
|
26
|
+
payload[:tool_choice] = 'auto'
|
26
27
|
end
|
28
|
+
|
29
|
+
payload[:stream_options] = { include_usage: true } if stream
|
30
|
+
payload
|
27
31
|
end
|
28
32
|
|
29
33
|
def parse_completion_response(response)
|
data/lib/ruby_llm/tool.rb
CHANGED
@@ -49,14 +49,14 @@ module RubyLLM
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def name
|
52
|
-
self.class.name
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
52
|
+
klass_name = self.class.name
|
53
|
+
normalized = klass_name.to_s.dup.force_encoding('UTF-8').unicode_normalize(:nfkd)
|
54
|
+
normalized.encode('ASCII', replace: '')
|
55
|
+
.gsub(/[^a-zA-Z0-9_-]/, '-')
|
56
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
57
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
58
|
+
.downcase
|
59
|
+
.delete_suffix('_tool')
|
60
60
|
end
|
61
61
|
|
62
62
|
def description
|
data/lib/ruby_llm/version.rb
CHANGED
data/lib/ruby_llm.rb
CHANGED
data/lib/tasks/models_docs.rake
CHANGED
@@ -30,7 +30,7 @@ def generate_models_markdown
|
|
30
30
|
# Available Models
|
31
31
|
{: .no_toc }
|
32
32
|
|
33
|
-
This guide lists all models available in RubyLLM, automatically generated from the current model registry.
|
33
|
+
This guide lists all models available in RubyLLM, automatically generated from the current [model registry](https://github.com/crmne/ruby_llm/blob/main/lib/ruby_llm/models.json).
|
34
34
|
{: .fs-6 .fw-300 }
|
35
35
|
|
36
36
|
## Table of contents
|
@@ -41,15 +41,21 @@ def generate_models_markdown
|
|
41
41
|
|
42
42
|
---
|
43
43
|
|
44
|
-
##
|
44
|
+
## How Model Data Works
|
45
45
|
|
46
|
-
|
46
|
+
RubyLLM's model registry combines data from multiple sources:
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
- **OpenAI, Anthropic, DeepSeek, Gemini**: Data from [Parsera](https://api.parsera.org/v1/llm-specs)
|
49
|
+
- **OpenRouter**: Direct from OpenRouter's API
|
50
|
+
- **Other providers**: Defined in `capabilities.rb` files
|
51
51
|
|
52
|
-
|
52
|
+
## Contributing Model Updates
|
53
|
+
|
54
|
+
**For major providers** (OpenAI, Anthropic, DeepSeek, Gemini): File issues with [Parsera](https://github.com/parsera-labs/api-llm-specs/issues) for public model data corrections.
|
55
|
+
|
56
|
+
**For other providers**: Edit `lib/ruby_llm/providers/<provider>/capabilities.rb` then run `rake models:update`.
|
57
|
+
|
58
|
+
See the [Contributing Guide](https://github.com/crmne/ruby_llm/blob/main/CONTRIBUTING.md) for details.
|
53
59
|
|
54
60
|
## Last Updated
|
55
61
|
{: .d-inline-block }
|