Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/summarization/fold_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@ def summarize(user, &on_partial_blk)
summarize_chunks(initial_chunks, user, opts, &on_partial_blk)
end

clean_summary =
Nokogiri::HTML5.fragment(result[:summary]).css("ai")&.first&.text || result[:summary]

if persist_summaries
AiSummary.store!(
strategy.target,
strategy.type,
llm_model.name,
result[:summary],
clean_summary,
content_to_summarize[:contents].map { |c| c[:id] },
)
else
AiSummary.new(summarized_text: result[:summary])
AiSummary.new(summarized_text: clean_summary)
end
end

Expand Down
30 changes: 21 additions & 9 deletions lib/summarization/strategies/hot_topic_gists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,34 @@ def summarize_single_prompt(input, opts)
- Use the original language of the text.
- Begin directly with the main topic or issue, avoiding introductory phrases.
- Limit the summary to a maximum of 20 words.

Return the 20-word summary inside <ai></ai> tags.
TEXT

prompt.push(type: :user, content: <<~TEXT.strip)
context = +<<~TEXT
### Context:

The conversation began with the following statement:


#{opts[:content_title].present? ? "The discussion title is: " + opts[:content_title] + ".\n" : ""}

The conversation began with the following statement:

#{statements&.pop}

Subsequent discussion includes the following:
#{statements&.pop}\n
TEXT

if statements.present?
context << <<~TEXT
Subsequent discussion includes the following:

#{statements&.join}
#{statements&.join("\n")}

Your task is to focus on these latest messages, capturing their meaning in the context of the initial post.
Your task is to focus on these latest messages, capturing their meaning in the context of the initial statement.
TEXT
else
context << "Your task is to capture the meaning of the initial statement."
end

prompt.push(type: :user, content: <<~TEXT.strip)
#{context} Return the 20-word summary inside <ai></ai> tags.
TEXT

prompt
Expand Down