ruby_llm 1.7.1 → 1.8.0

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: ceecb8e7cd289f58ac1f76648306f61b54482a9b6f845a2f08b3303ee746a634
4
- data.tar.gz: 3c075c03ccd1d7b841b99b58a1a4cda9289370b8dea039070cd78ede2d18a41c
3
+ metadata.gz: def0767fe1f3e052f42bfddc4d3b69733d51cf8d39d057a08145307ef5f362a0
4
+ data.tar.gz: fba9605e4458efb173dff1d131f0124c8252c4d71ca7a23527eb0d0a2543c75a
5
5
  SHA512:
6
- metadata.gz: 16ac70cc9787c0d845b5ad4c62171cb225752f160506864b07fdb0b2c1b27adc147e9799a1f13e9d7a5169595d247e5b6bc0c1083dc523647aa13e750b1d6f9d
7
- data.tar.gz: 80543faec7119044c345f6751059e05e4cf76457ad3b288da38ea7c4e1338570fcbca1c8ad8e9dad84fb7ac5983998fd1ceba481b2e244d3542f59481a4d0e7f
6
+ metadata.gz: 622b3b02ba5fb0cc0c49d7bc2d515e92abd0fa5714db70c8b0af64868cee9229b05ddefa6a990ab5f3788e7e07589628bd9f347f921346449a2154575e1e1ac1
7
+ data.tar.gz: 890020ebc2817a3a388278510eaa2b31699eb660cce29ed1c19ebd5a67b3775f8ff83d9be58b31bac825719c6683d7ffcc321251a6f89dc58bafd135ea51ec25
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  Battle tested at [<picture><source media="(prefers-color-scheme: dark)" srcset="https://chatwithwork.com/logotype-dark.svg"><img src="https://chatwithwork.com/logotype.svg" alt="Chat with Work" height="30" align="absmiddle"></picture>](https://chatwithwork.com) — *Claude Code for your documents*
11
11
 
12
- [![Gem Version](https://badge.fury.io/rb/ruby_llm.svg?a=8)](https://badge.fury.io/rb/ruby_llm)
12
+ [![Gem Version](https://badge.fury.io/rb/ruby_llm.svg?a=9)](https://badge.fury.io/rb/ruby_llm)
13
13
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
14
14
  [![Gem Downloads](https://img.shields.io/gem/dt/ruby_llm)](https://rubygems.org/gems/ruby_llm)
15
15
  [![codecov](https://codecov.io/gh/crmne/ruby_llm/branch/main/graph/badge.svg?a=2)](https://codecov.io/gh/crmne/ruby_llm)
@@ -41,6 +41,7 @@ chat.ask "What's the best way to learn Ruby?"
41
41
  ```ruby
42
42
  # Analyze any file type
43
43
  chat.ask "What's in this image?", with: "ruby_conf.jpg"
44
+ chat.ask "What's happening in this video?", with: "video.mp4"
44
45
  chat.ask "Describe this meeting", with: "meeting.wav"
45
46
  chat.ask "Summarize this document", with: "contract.pdf"
46
47
  chat.ask "Explain this code", with: "app.rb"
@@ -100,7 +101,7 @@ response = chat.with_schema(ProductSchema).ask "Analyze this product", with: "pr
100
101
  ## Features
101
102
 
102
103
  * **Chat:** Conversational AI with `RubyLLM.chat`
103
- * **Vision:** Analyze images and screenshots
104
+ * **Vision:** Analyze images and videos
104
105
  * **Audio:** Transcribe and understand speech
105
106
  * **Documents:** Extract from PDFs, CSVs, JSON, any file type
106
107
  * **Image generation:** Create images with `RubyLLM.paint`
@@ -32,12 +32,12 @@ module RubyLLM
32
32
  migration_template 'create_chats_migration.rb.tt',
33
33
  "db/migrate/create_#{chat_table_name}.rb"
34
34
 
35
- # Then create messages table (must come before tool_calls due to foreign key)
35
+ # Then create messages table
36
36
  sleep 1 # Ensure different timestamp
37
37
  migration_template 'create_messages_migration.rb.tt',
38
38
  "db/migrate/create_#{message_table_name}.rb"
39
39
 
40
- # Then create tool_calls table (references messages)
40
+ # Then create tool_calls table
41
41
  sleep 1 # Ensure different timestamp
42
42
  migration_template 'create_tool_calls_migration.rb.tt',
43
43
  "db/migrate/create_#{tool_call_table_name}.rb"
@@ -46,6 +46,12 @@ module RubyLLM
46
46
  sleep 1 # Ensure different timestamp
47
47
  migration_template 'create_models_migration.rb.tt',
48
48
  "db/migrate/create_#{model_table_name}.rb"
49
+
50
+ # Add references to chats, tool_calls and messages.
51
+ sleep 1 # Ensure different timestamp
52
+ migration_template 'add_references_to_chats_tool_calls_and_messages_migration.rb.tt',
53
+ 'db/migrate/add_references_to_' \
54
+ "#{chat_table_name}_#{tool_call_table_name}_and_#{message_table_name}.rb"
49
55
  end
50
56
 
51
57
  def create_model_files
@@ -0,0 +1,9 @@
1
+ class AddReferencesTo<%= "#{chat_model_name.gsub('::', '').pluralize}#{tool_call_model_name.gsub('::', '').pluralize}And#{message_model_name.gsub('::', '').pluralize}" %> < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ add_reference :<%= chat_table_name %>, :<%= model_table_name.singularize %>, foreign_key: true
4
+ add_reference :<%= tool_call_table_name %>, :<%= message_table_name.singularize %>, null: false, foreign_key: true
5
+ add_reference :<%= message_table_name %>, :<%= chat_table_name.singularize %>, null: false, foreign_key: true
6
+ add_reference :<%= message_table_name %>, :<%= model_table_name.singularize %>, foreign_key: true
7
+ add_reference :<%= message_table_name %>, :<%= tool_call_table_name.singularize %>, foreign_key: true
8
+ end
9
+ end
@@ -1,7 +1,6 @@
1
1
  class Create<%= chat_model_name.gsub('::', '').pluralize %> < ActiveRecord::Migration<%= migration_version %>
2
2
  def change
3
3
  create_table :<%= chat_table_name %> do |t|
4
- t.references :<%= model_table_name.singularize %>, foreign_key: true
5
4
  t.timestamps
6
5
  end
7
6
  end
@@ -1,13 +1,10 @@
1
1
  class Create<%= message_model_name.gsub('::', '').pluralize %> < ActiveRecord::Migration<%= migration_version %>
2
2
  def change
3
3
  create_table :<%= message_table_name %> do |t|
4
- t.references :<%= chat_table_name.singularize %>, null: false, foreign_key: true
5
4
  t.string :role, null: false
6
5
  t.text :content
7
- t.references :<%= model_table_name.singularize %>, foreign_key: true
8
6
  t.integer :input_tokens
9
7
  t.integer :output_tokens
10
- t.references :<%= tool_call_table_name.singularize %>, foreign_key: true
11
8
  t.timestamps
12
9
  end
13
10
 
@@ -2,7 +2,6 @@
2
2
  class Create<%= tool_call_model_name.gsub('::', '').pluralize %> < ActiveRecord::Migration<%= migration_version %>
3
3
  def change
4
4
  create_table :<%= tool_call_table_name %> do |t|
5
- t.references :<%= message_table_name.singularize %>, null: false, foreign_key: true
6
5
  t.string :tool_call_id, null: false
7
6
  t.string :name, null: false
8
7
  t.<%= postgresql? ? 'jsonb' : 'json' %> :arguments, default: {}
@@ -76,6 +76,7 @@ module RubyLLM
76
76
 
77
77
  def type
78
78
  return :image if image?
79
+ return :video if video?
79
80
  return :audio if audio?
80
81
  return :pdf if pdf?
81
82
  return :text if text?
@@ -87,6 +88,10 @@ module RubyLLM
87
88
  RubyLLM::MimeType.image? mime_type
88
89
  end
89
90
 
91
+ def video?
92
+ RubyLLM::MimeType.video? mime_type
93
+ end
94
+
90
95
  def audio?
91
96
  RubyLLM::MimeType.audio? mime_type
92
97
  end
@@ -26,6 +26,7 @@ module RubyLLM
26
26
  # Default models
27
27
  :default_model,
28
28
  :default_embedding_model,
29
+ :default_moderation_model,
29
30
  :default_image_model,
30
31
  # Model registry
31
32
  :model_registry_class,
@@ -54,6 +55,7 @@ module RubyLLM
54
55
 
55
56
  @default_model = 'gpt-4.1-nano'
56
57
  @default_embedding_model = 'text-embedding-3-small'
58
+ @default_moderation_model = 'omni-moderation-latest'
57
59
  @default_image_model = 'gpt-image-1'
58
60
 
59
61
  @model_registry_class = 'Model'
@@ -15,6 +15,10 @@ module RubyLLM
15
15
  type.start_with?('image/')
16
16
  end
17
17
 
18
+ def video?(type)
19
+ type.start_with?('video/')
20
+ end
21
+
18
22
  def audio?(type)
19
23
  type.start_with?('audio/')
20
24
  end
@@ -56,6 +56,10 @@ module RubyLLM
56
56
  modalities.input.include?('image')
57
57
  end
58
58
 
59
+ def supports_video?
60
+ modalities.input.include?('video')
61
+ end
62
+
59
63
  def supports_functions?
60
64
  function_calling?
61
65
  end