ruby_llm 1.8.0 → 1.8.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 +14 -2
- data/lib/generators/ruby_llm/chat_ui/chat_ui_generator.rb +14 -2
- data/lib/generators/ruby_llm/chat_ui/templates/jobs/chat_response_job.rb.tt +1 -1
- data/lib/generators/ruby_llm/chat_ui/templates/views/messages/_content.html.erb.tt +1 -0
- data/lib/generators/ruby_llm/chat_ui/templates/views/messages/_message.html.erb.tt +1 -1
- data/lib/ruby_llm/models.json +686 -840
- data/lib/ruby_llm/providers/openai/capabilities.rb +15 -7
- data/lib/ruby_llm/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8662c9b8b38e5941ea7e66882d59e8583989135285bc4b7eaaf5b83c8c2326e
|
4
|
+
data.tar.gz: 33c168dc4d68d4cffb18bb0761adc42da51288a43aee78633d30f669bffaa47f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f94e7adcf5b6f50aca97718c615d8dfa681a483da841ca8214f3970ca918a2a8e384f07a494dad9db83da269068a502ab8caf14a441a2ecb86909617e06fdf9
|
7
|
+
data.tar.gz: 8342ae03bb413eb4b65b55c73629b1729b319e96e6976172fcaaa8ed19231280b5773eb8acccf4f563d63c801a78a03b20be5552189f86a4a7e435fb426c354f
|
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
|
-
[](https://badge.fury.io/rb/ruby_llm)
|
13
13
|
[](https://github.com/testdouble/standard)
|
14
14
|
[](https://rubygems.org/gems/ruby_llm)
|
15
15
|
[](https://codecov.io/gh/crmne/ruby_llm)
|
@@ -69,6 +69,11 @@ RubyLLM.paint "a sunset over mountains in watercolor style"
|
|
69
69
|
RubyLLM.embed "Ruby is elegant and expressive"
|
70
70
|
```
|
71
71
|
|
72
|
+
```ruby
|
73
|
+
# Moderate content for safety
|
74
|
+
RubyLLM.moderate("Check if this text is safe").flagged? # => false
|
75
|
+
```
|
76
|
+
|
72
77
|
```ruby
|
73
78
|
# Let AI use your code
|
74
79
|
class Weather < RubyLLM::Tool
|
@@ -106,6 +111,7 @@ response = chat.with_schema(ProductSchema).ask "Analyze this product", with: "pr
|
|
106
111
|
* **Documents:** Extract from PDFs, CSVs, JSON, any file type
|
107
112
|
* **Image generation:** Create images with `RubyLLM.paint`
|
108
113
|
* **Embeddings:** Vector search with `RubyLLM.embed`
|
114
|
+
* **Moderation:** Content safety with `RubyLLM.moderate`
|
109
115
|
* **Tools:** Let AI call your Ruby methods
|
110
116
|
* **Structured output:** JSON schemas that just work
|
111
117
|
* **Streaming:** Real-time responses with blocks
|
@@ -133,7 +139,11 @@ end
|
|
133
139
|
## Rails
|
134
140
|
|
135
141
|
```bash
|
142
|
+
# Install database models
|
136
143
|
rails generate ruby_llm:install
|
144
|
+
|
145
|
+
# Add chat UI (optional)
|
146
|
+
rails generate ruby_llm:chat_ui
|
137
147
|
```
|
138
148
|
|
139
149
|
```ruby
|
@@ -141,10 +151,12 @@ class Chat < ApplicationRecord
|
|
141
151
|
acts_as_chat
|
142
152
|
end
|
143
153
|
|
144
|
-
chat = Chat.create!
|
154
|
+
chat = Chat.create! model: "claude-sonnet-4"
|
145
155
|
chat.ask "What's in this file?", with: "report.pdf"
|
146
156
|
```
|
147
157
|
|
158
|
+
Visit `http://localhost:3000/chats` for a ready-to-use chat interface!
|
159
|
+
|
148
160
|
## Documentation
|
149
161
|
|
150
162
|
[rubyllm.com](https://rubyllm.com)
|
@@ -56,6 +56,7 @@ module RubyLLM
|
|
56
56
|
# Message views
|
57
57
|
template 'views/messages/_message.html.erb',
|
58
58
|
"app/views/#{message_table_name}/_#{message_model_name.underscore}.html.erb"
|
59
|
+
template 'views/messages/_content.html.erb', "app/views/#{message_table_name}/_content.html.erb"
|
59
60
|
template 'views/messages/_form.html.erb', "app/views/#{message_table_name}/_form.html.erb"
|
60
61
|
template 'views/messages/create.turbo_stream.erb',
|
61
62
|
"app/views/#{message_table_name}/create.turbo_stream.erb"
|
@@ -99,12 +100,23 @@ module RubyLLM
|
|
99
100
|
chat_var = chat_model_name.underscore
|
100
101
|
broadcasting_code = "broadcasts_to ->(#{msg_var}) { \"#{chat_var}_\#{#{msg_var}.#{chat_var}_id}\" }"
|
101
102
|
|
102
|
-
|
103
|
-
|
103
|
+
broadcast_append_chunk_method = <<-RUBY
|
104
|
+
|
105
|
+
def broadcast_append_chunk(content)
|
106
|
+
broadcast_append_to "#{chat_var}_\#{#{chat_var}_id}",
|
107
|
+
target: "#{msg_var}_\#{id}_content",
|
108
|
+
partial: "#{message_table_name}/content",
|
109
|
+
locals: { content: content }
|
110
|
+
end
|
111
|
+
RUBY
|
112
|
+
|
113
|
+
inject_into_file "app/models/#{msg_var}.rb", before: "end\n" do
|
114
|
+
" #{broadcasting_code}\n#{broadcast_append_chunk_method}"
|
104
115
|
end
|
105
116
|
rescue Errno::ENOENT
|
106
117
|
say "#{message_model_name} model not found. Add broadcasting code to your model.", :yellow
|
107
118
|
say " #{broadcasting_code}", :yellow
|
119
|
+
say broadcast_append_chunk_method, :yellow
|
108
120
|
end
|
109
121
|
|
110
122
|
def display_post_install_message
|
@@ -5,7 +5,7 @@ class <%= chat_model_name %>ResponseJob < ApplicationJob
|
|
5
5
|
<%= chat_model_name.underscore %>.ask(content) do |chunk|
|
6
6
|
if chunk.content && !chunk.content.blank?
|
7
7
|
<%= message_model_name.underscore %> = <%= chat_model_name.underscore %>.<%= message_model_name.tableize %>.last
|
8
|
-
<%= message_model_name.underscore %>.
|
8
|
+
<%= message_model_name.underscore %>.broadcast_append_chunk(chunk.content)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%%= content %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<div style="font-weight: bold; margin-bottom: 5px;">
|
4
4
|
<%%= <%= message_model_name.underscore %>.role&.capitalize %>
|
5
5
|
</div>
|
6
|
-
<div style="white-space: pre-wrap;"><%%= <%= message_model_name.underscore %>.content %></div>
|
6
|
+
<div id="<%%= dom_id(<%= message_model_name.underscore %>) %>_content" style="white-space: pre-wrap;"><%%= <%= message_model_name.underscore %>.content %></div>
|
7
7
|
<div style="font-size: 0.85em; color: #666; margin-top: 5px;">
|
8
8
|
<%%= <%= message_model_name.underscore %>.created_at&.strftime("%I:%M %p") %>
|
9
9
|
</div>
|