Skip to content

Commit 2ba9134

Browse files
committed
feat(Media): Update attachment handling to return mime_type for unsupported types
1 parent c7cdd5f commit 2ba9134

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

lib/ruby_llm/attachment.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ def type
5858
return :image if image?
5959
return :audio if audio?
6060
return :pdf if pdf?
61+
return :text if text?
6162

62-
:text
63+
:unknown
6364
end
6465

6566
def image?

lib/ruby_llm/providers/anthropic/media.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def format_content(content)
2222
when :text
2323
parts << format_text_file(attachment)
2424
else
25-
raise UnsupportedAttachmentError, attachment.type
25+
raise UnsupportedAttachmentError, attachment.mime_type
2626
end
2727
end
2828

lib/ruby_llm/providers/gemini/media.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ def format_content(content)
1414
parts << format_text(content.text) if content.text
1515

1616
content.attachments.each do |attachment|
17-
parts << case attachment.type
18-
when :text
19-
format_text_file(attachment)
20-
else
21-
format_attachment(attachment)
22-
end
17+
case attachment.type
18+
when :text
19+
parts << format_text_file(attachment)
20+
when :unknown
21+
raise UnsupportedAttachmentError, attachment.mime_type
22+
else
23+
parts << format_attachment(attachment)
24+
end
2325
end
2426

2527
parts

lib/ruby_llm/providers/ollama/media.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def format_content(content)
2626
when :text
2727
parts << format_text_file(attachment)
2828
else
29-
raise UnsupportedAttachmentError, attachment.type
29+
raise UnsupportedAttachmentError, attachment.mime_type
3030
end
3131
end
3232

0 commit comments

Comments
 (0)