DEV: Update rubocop-discourse to version 3.8.0 (#641)

This commit is contained in:
Loïc Guitaut 2024-05-28 11:15:42 +02:00 committed by GitHub
parent 309280cbb6
commit dd4e305ff7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 38 additions and 29 deletions

View File

@ -1,7 +1,7 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
activesupport (7.1.3.2) activesupport (7.1.3.3)
base64 base64
bigdecimal bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
@ -13,27 +13,28 @@ GEM
tzinfo (~> 2.0) tzinfo (~> 2.0)
ast (2.4.2) ast (2.4.2)
base64 (0.2.0) base64 (0.2.0)
bigdecimal (3.1.6) bigdecimal (3.1.8)
concurrent-ruby (1.2.3) concurrent-ruby (1.2.3)
connection_pool (2.4.1) connection_pool (2.4.1)
drb (2.2.1) drb (2.2.1)
i18n (1.14.1) i18n (1.14.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
json (2.7.1) json (2.7.2)
language_server-protocol (3.17.0.3) language_server-protocol (3.17.0.3)
minitest (5.22.2) minitest (5.23.1)
mutex_m (0.2.0) mutex_m (0.2.0)
parallel (1.24.0) parallel (1.24.0)
parser (3.3.0.5) parser (3.3.1.0)
ast (~> 2.4.1) ast (~> 2.4.1)
racc racc
prettier_print (1.2.1) prettier_print (1.2.1)
racc (1.7.3) racc (1.8.0)
rack (3.0.11)
rainbow (3.1.1) rainbow (3.1.1)
regexp_parser (2.9.0) regexp_parser (2.9.2)
rexml (3.2.8) rexml (3.2.8)
strscan (>= 3.0.9) strscan (>= 3.0.9)
rubocop (1.61.0) rubocop (1.64.0)
json (~> 2.3) json (~> 2.3)
language_server-protocol (>= 3.17.0) language_server-protocol (>= 3.17.0)
parallel (~> 1.10) parallel (~> 1.10)
@ -41,25 +42,34 @@ GEM
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0) regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0) rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0) unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.1) rubocop-ast (1.31.3)
parser (>= 3.3.0.4) parser (>= 3.3.1.0)
rubocop-capybara (2.20.0) rubocop-capybara (2.20.0)
rubocop (~> 1.41) rubocop (~> 1.41)
rubocop-discourse (3.7.1) rubocop-discourse (3.8.0)
activesupport (>= 6.1) activesupport (>= 6.1)
rubocop (>= 1.59.0) rubocop (>= 1.59.0)
rubocop-capybara (>= 2.0.0) rubocop-capybara (>= 2.0.0)
rubocop-factory_bot (>= 2.0.0) rubocop-factory_bot (>= 2.0.0)
rubocop-rails (>= 2.25.0)
rubocop-rspec (>= 2.25.0) rubocop-rspec (>= 2.25.0)
rubocop-factory_bot (2.25.1) rubocop-factory_bot (2.25.1)
rubocop (~> 1.41) rubocop (~> 1.41)
rubocop-rspec (2.27.1) rubocop-rails (2.25.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (2.29.2)
rubocop (~> 1.40) rubocop (~> 1.40)
rubocop-capybara (~> 2.17) rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22) rubocop-factory_bot (~> 2.22)
rubocop-rspec_rails (~> 2.28)
rubocop-rspec_rails (2.28.3)
rubocop (~> 1.40)
ruby-progressbar (1.13.0) ruby-progressbar (1.13.0)
strscan (3.1.0) strscan (3.1.0)
syntax_tree (6.2.0) syntax_tree (6.2.0)
@ -76,4 +86,4 @@ DEPENDENCIES
syntax_tree syntax_tree
BUNDLED WITH BUNDLED WITH
2.5.4 2.5.10

View File

@ -12,7 +12,7 @@ module Jobs
topic = target.is_a?(Topic) ? target : target.topic topic = target.is_a?(Topic) ? target : target.topic
post = target.is_a?(Post) ? target : target.first_post post = target.is_a?(Post) ? target : target.first_post
return unless topic.present? && post.present? return if topic.blank? || post.blank?
return if topic.private_message? && !SiteSetting.ai_embeddings_generate_for_pms return if topic.private_message? && !SiteSetting.ai_embeddings_generate_for_pms
return if post.raw.blank? return if post.raw.blank?

View File

@ -2,8 +2,8 @@
class ModelAccuracy < ActiveRecord::Base class ModelAccuracy < ActiveRecord::Base
def self.adjust_model_accuracy(new_status, reviewable) def self.adjust_model_accuracy(new_status, reviewable)
return unless %i[approved rejected].include?(new_status) return if %i[approved rejected].exclude?(new_status)
return unless [ReviewableAiPost, ReviewableAiChatMessage].include?(reviewable.class) return if [ReviewableAiPost, ReviewableAiChatMessage].exclude?(reviewable.class)
verdicts = reviewable.payload.to_h["verdicts"] || {} verdicts = reviewable.payload.to_h["verdicts"] || {}

View File

@ -3,7 +3,7 @@
class MigrateEmbeddingsFromDedicatedDatabase < ActiveRecord::Migration[7.0] class MigrateEmbeddingsFromDedicatedDatabase < ActiveRecord::Migration[7.0]
def up def up
return unless SiteSetting.ai_embeddings_enabled return unless SiteSetting.ai_embeddings_enabled
return unless SiteSetting.ai_embeddings_pg_connection_string.present? return if SiteSetting.ai_embeddings_pg_connection_string.blank?
truncation = DiscourseAi::Embeddings::Strategies::Truncation.new truncation = DiscourseAi::Embeddings::Strategies::Truncation.new

View File

@ -13,8 +13,8 @@ module DiscourseAi
plugin.on(:chat_message_created) do |message, channel, user, extra| plugin.on(:chat_message_created) do |message, channel, user, extra|
next unless SiteSetting.composer_ai_helper_enabled next unless SiteSetting.composer_ai_helper_enabled
next unless SiteSetting.ai_helper_automatic_chat_thread_title next unless SiteSetting.ai_helper_automatic_chat_thread_title
next unless extra[:thread].present? next if extra[:thread].blank?
next unless extra[:thread].title.blank? next if extra[:thread].title.present?
reply_count = extra[:thread].replies.count reply_count = extra[:thread].replies.count

View File

@ -171,7 +171,7 @@ module DiscourseAi
SiteSetting.ai_embeddings_semantic_search_hyde_model, SiteSetting.ai_embeddings_semantic_search_hyde_model,
).generate(prompt, user: @guardian.user, feature_name: "semantic_search_hyde") ).generate(prompt, user: @guardian.user, feature_name: "semantic_search_hyde")
Nokogiri::HTML5.fragment(llm_response).at("ai")&.text&.presence || llm_response Nokogiri::HTML5.fragment(llm_response).at("ai")&.text.presence || llm_response
end end
private private

View File

@ -49,7 +49,7 @@ module DiscourseAi
def topic_truncation(topic, tokenizer, max_length) def topic_truncation(topic, tokenizer, max_length)
text = +topic_information(topic) text = +topic_information(topic)
if topic&.topic_embed&.embed_content_cache&.present? if topic&.topic_embed&.embed_content_cache.present?
text << Nokogiri::HTML5.fragment(topic.topic_embed.embed_content_cache).text text << Nokogiri::HTML5.fragment(topic.topic_embed.embed_content_cache).text
text << "\n\n" text << "\n\n"
end end
@ -66,7 +66,7 @@ module DiscourseAi
def post_truncation(post, tokenizer, max_length) def post_truncation(post, tokenizer, max_length)
text = +topic_information(post.topic) text = +topic_information(post.topic)
if post.is_first_post? && post.topic&.topic_embed&.embed_content_cache&.present? if post.is_first_post? && post.topic&.topic_embed&.embed_content_cache.present?
text << Nokogiri::HTML5.fragment(post.topic.topic_embed.embed_content_cache).text text << Nokogiri::HTML5.fragment(post.topic.topic_embed.embed_content_cache).text
else else
text << Nokogiri::HTML5.fragment(post.cooked).text text << Nokogiri::HTML5.fragment(post.cooked).text

View File

@ -1,10 +1,9 @@
{ {
"name": "discourse-ai",
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"@discourse/lint-configs": "^1.3.4", "@discourse/lint-configs": "1.3.9",
"ember-template-lint": "^5.13.0", "ember-template-lint": "6.0.0",
"eslint": "^8.56.0", "eslint": "8.57.0",
"prettier": "^2.8.8" "prettier": "2.8.8"
} }
} }