Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Don't regenerate up to date gists #843

Merged
merged 1 commit into from
Oct 18, 2024
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
6 changes: 4 additions & 2 deletions app/jobs/regular/hot_topics_gist_batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ def execute(args)
summarizer = DiscourseAi::Summarization.topic_gist(topic)
gist = summarizer.existing_summary

summarizer.delete_cached_summaries! if gist && gist.outdated
if gist.blank? || gist.outdated
summarizer.delete_cached_summaries!

summarizer.summarize(Discourse.system_user)
summarizer.summarize(Discourse.system_user)
end
end
end
end
Expand Down
9 changes: 7 additions & 2 deletions spec/jobs/regular/hot_topics_gist_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@
end

it "does nothing if the gist is up to date" do
subject.execute({})
updated_gist = "They updated me :("

DiscourseAi::Completions::Llm.with_prepared_responses([updated_gist]) do
subject.execute({})
end

gist = AiSummary.gist.find_by(target: topic_1)
expect(gist.summarized_text).to eq(ai_gist.summarized_text)
expect(AiSummary.gist.where(target: topic_1).count).to eq(1)
expect(gist.summarized_text).not_to eq(updated_gist)
expect(gist.original_content_sha).to eq(ai_gist.original_content_sha)
end

Expand Down