Skip to content

Commit faa12a0

Browse files
committed
Using RubyLLM new with_params to replace crmne/ruby_llm#131
1 parent 8f10a27 commit faa12a0

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ gem "wechat", git: "https://git.thape.com.cn/Eric-Guo/wechat.git", branch: :main
4646
gem "rake"
4747

4848
# bundle config local.ruby_llm /Users/$(whoami)/git/oss/ruby_llm/
49-
gem "ruby_llm", git: "https://git.thape.com.cn/ai/ruby_llm.git", branch: :WithResponseFormat2
49+
gem "ruby_llm", git: "https://git.thape.com.cn/ai/ruby_llm.git", branch: :dify_api
5050
gem "uri"
5151
gem "faraday-net_http"
5252
gem "net-http", "~> 0.4.1"

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ GIT
1414

1515
GIT
1616
remote: https://git.thape.com.cn/ai/ruby_llm.git
17-
revision: f0fc8ffb2cc76548448d1a8fd28849c58eff7d9c
18-
branch: WithResponseFormat2
17+
revision: 4bef85c4fa1e59f7cf6d6c44685097593ced0cdf
18+
branch: dify_api
1919
specs:
2020
ruby_llm (1.3.2beta1)
2121
base64

app/models/guest_message.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ class GuestMessage < ApplicationRecord
44
after_create :auto_fill_spam_score
55

66
def auto_fill_spam_score
7-
update_column(:spam_score, ai_spam_score)
7+
spam_score = JSON.parse(ai_spam_score)["result"]
8+
update_column(:spam_score, spam_score)
89
end
910

1011
def ai_spam_score
@@ -48,7 +49,7 @@ def ai_spam_score
4849

4950
chat = RubyLLM.chat
5051
chat.with_instructions system_prompt
51-
chat.with_response_format(type: :object, properties: {result: {type: :integer}})
52+
chat.with_params(response_format: { type: 'json_object' })
5253
response = chat.ask "#{name} from company #{company} (#{contact_details}) leaving message:\n\n#{message}"
5354
response.content
5455
end

0 commit comments

Comments
 (0)