ruby_llm-responses_api 0.5.3 → 0.5.4
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 688542f3b394d7ecfe8873cf6700d95da8c566230826a35d332a8e3bf1b08e7a
|
|
4
|
+
data.tar.gz: 5b12fd0f0728c273821956f315856dc966b0d8826a3663c86893710c377f2880
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e8203f307e819443cff01c51ebfc61cba907345e71782bc3f9286ba43a5f2e9b86612135a2fc4754ed6e3262b14a8187e2bda5c130fe434ba6389f5b2f5aa5e0
|
|
7
|
+
data.tar.gz: 05e88249b83ec50f67ff1e333f06df78cb9776f66419eefd14665548b2899ba63bfc605c78b74b6991d05d3d0ae369cd9a06b9b8d49f6106ea03eea3ed468f87
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ 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.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.5.4] - 2026-04-06
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Raise `UnsupportedAttachmentError` for unknown attachment types instead of sending a confusing placeholder to the LLM (PR #7 by @molily)
|
|
13
|
+
- Remove unused `Media#format_content` method (dead code cleanup)
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- Text file attachment support (`.txt`, `.csv`, `.html`, etc.) matching ruby_llm's standard OpenAI provider behavior (PR #7 by @molily)
|
|
18
|
+
- Consolidate attachment handling in `Media` module, removing duplicate logic from `Chat` (PR #7 by @molily)
|
|
19
|
+
|
|
8
20
|
## [0.5.3] - 2026-03-27
|
|
9
21
|
|
|
10
22
|
### Fixed
|
|
@@ -173,7 +173,7 @@ module RubyLLM
|
|
|
173
173
|
# Add attachments if present
|
|
174
174
|
if content.is_a?(RubyLLM::Content)
|
|
175
175
|
content.attachments.each do |attachment|
|
|
176
|
-
parts << format_attachment(attachment)
|
|
176
|
+
parts << Media.format_attachment(attachment)
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
179
|
|
|
@@ -195,43 +195,6 @@ module RubyLLM
|
|
|
195
195
|
parts
|
|
196
196
|
end
|
|
197
197
|
|
|
198
|
-
def format_attachment(attachment)
|
|
199
|
-
case attachment.type
|
|
200
|
-
when :image
|
|
201
|
-
if attachment.url?
|
|
202
|
-
{ type: 'input_image', image_url: attachment.source }
|
|
203
|
-
else
|
|
204
|
-
{ type: 'input_image', image_url: attachment.for_llm }
|
|
205
|
-
end
|
|
206
|
-
when :pdf
|
|
207
|
-
{
|
|
208
|
-
type: 'input_file',
|
|
209
|
-
filename: File.basename(attachment.source.to_s),
|
|
210
|
-
file_data: attachment.for_llm
|
|
211
|
-
}
|
|
212
|
-
when :audio
|
|
213
|
-
{
|
|
214
|
-
type: 'input_audio',
|
|
215
|
-
data: attachment.for_llm,
|
|
216
|
-
format: detect_audio_format(attachment.source)
|
|
217
|
-
}
|
|
218
|
-
else
|
|
219
|
-
{ type: 'input_text', text: "[Unsupported attachment: #{attachment.type}]" }
|
|
220
|
-
end
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
def detect_audio_format(source)
|
|
224
|
-
ext = File.extname(source.to_s).downcase
|
|
225
|
-
case ext
|
|
226
|
-
when '.mp3' then 'mp3'
|
|
227
|
-
when '.wav' then 'wav'
|
|
228
|
-
when '.webm' then 'webm'
|
|
229
|
-
when '.ogg' then 'ogg'
|
|
230
|
-
when '.flac' then 'flac'
|
|
231
|
-
else 'mp3'
|
|
232
|
-
end
|
|
233
|
-
end
|
|
234
|
-
|
|
235
198
|
def extract_text_content(content)
|
|
236
199
|
case content
|
|
237
200
|
when String
|
|
@@ -8,27 +8,6 @@ module RubyLLM
|
|
|
8
8
|
module Media
|
|
9
9
|
module_function
|
|
10
10
|
|
|
11
|
-
def format_content(content)
|
|
12
|
-
return content if content.is_a?(RubyLLM::Content::Raw)
|
|
13
|
-
return content unless content.is_a?(RubyLLM::Content)
|
|
14
|
-
|
|
15
|
-
parts = []
|
|
16
|
-
parts << format_text(content.text) if content.text && !content.text.empty?
|
|
17
|
-
|
|
18
|
-
content.attachments.each do |attachment|
|
|
19
|
-
parts << format_attachment(attachment)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# Return simple string for text-only content
|
|
23
|
-
return content.text if parts.length == 1 && parts.first[:type] == 'input_text'
|
|
24
|
-
|
|
25
|
-
parts
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def format_text(text)
|
|
29
|
-
{ type: 'input_text', text: text }
|
|
30
|
-
end
|
|
31
|
-
|
|
32
11
|
def format_attachment(attachment)
|
|
33
12
|
case attachment.type
|
|
34
13
|
when :image
|
|
@@ -37,8 +16,10 @@ module RubyLLM
|
|
|
37
16
|
format_pdf(attachment)
|
|
38
17
|
when :audio
|
|
39
18
|
format_audio(attachment)
|
|
19
|
+
when :text
|
|
20
|
+
format_text_file(attachment)
|
|
40
21
|
else
|
|
41
|
-
|
|
22
|
+
raise UnsupportedAttachmentError, attachment.type
|
|
42
23
|
end
|
|
43
24
|
end
|
|
44
25
|
|
|
@@ -72,10 +53,10 @@ module RubyLLM
|
|
|
72
53
|
}
|
|
73
54
|
end
|
|
74
55
|
|
|
75
|
-
def
|
|
56
|
+
def format_text_file(text_file)
|
|
76
57
|
{
|
|
77
58
|
type: 'input_text',
|
|
78
|
-
text:
|
|
59
|
+
text: text_file.for_llm
|
|
79
60
|
}
|
|
80
61
|
end
|
|
81
62
|
|
|
@@ -39,7 +39,7 @@ RubyLLM::Providers::OpenAIResponses::ModelRegistry.register_all!
|
|
|
39
39
|
module RubyLLM
|
|
40
40
|
# ResponsesAPI namespace for direct access to helpers and version
|
|
41
41
|
module ResponsesAPI
|
|
42
|
-
VERSION = '0.5.
|
|
42
|
+
VERSION = '0.5.4'
|
|
43
43
|
|
|
44
44
|
# Shorthand access to built-in tool helpers
|
|
45
45
|
BuiltInTools = Providers::OpenAIResponses::BuiltInTools
|