FIX: Corner cases on post embedding and crawler related (#391)

* FIX: Simplify markup for crawler related

* FIX: Handle title-less topics when truncating for embeddings

* fix
This commit is contained in:
Rafael dos Santos Silva 2023-12-29 14:05:02 -03:00 committed by GitHub
parent 140359c2ef
commit c778592da4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 20 deletions

View File

@ -40,19 +40,6 @@
</div>
<% end %>
</div>
<% if t.pinned_until && (t.pinned_until > Time.zone.now) && (t.pinned_globally || t.category) && t.excerpt %>
<p class='excerpt'>
<%= t.excerpt.html_safe %>
</p>
<% end %>
</td>
<td class='posters'>
<% t.posters.each do |poster| %>
<a href="<%= Discourse.base_url %>/u/<%= poster.user.username %>" class="<%= poster.extras %>">
<%- poster_name_and_description = h(poster.name_and_description) %>
<img width="25" height="25" src="<%= poster.user.avatar_template.gsub('{size}', '25') %>" class="avatar" title='<%= poster_name_and_description %>' aria-label='<%= poster_name_and_description %>'>
</a>
<% end %>
</td>
<td class="replies">
<span class='posts' title='<%= t 'posts' %>'><%= t.posts_count - 1 %></span>

View File

@ -67,7 +67,7 @@ module DiscourseAi
topic = topic_view&.topic
return "" if !topic
related_topics ||= SemanticTopicQuery.new(nil).list_semantic_related_topics(topic).topics
related_topics = SemanticTopicQuery.new(nil).list_semantic_related_topics(topic).topics
return "" if related_topics.empty?

View File

@ -28,14 +28,20 @@ module DiscourseAi
def topic_information(topic)
info = +""
info << topic.title
info << "\n\n"
info << topic.category.name if topic&.category&.name
if SiteSetting.tagging_enabled
if topic&.title.present?
info << topic.title
info << "\n\n"
info << topic.tags.pluck(:name).join(", ")
end
info << "\n\n"
if topic&.category&.name.present?
info << topic.category.name
info << "\n\n"
end
if SiteSetting.tagging_enabled && topic&.tags.present?
info << topic.tags.pluck(:name).join(", ")
info << "\n\n"
end
info
end
def topic_truncation(topic, tokenizer, max_length)