mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-03-08 10:20:07 +00:00
This change-set connects GPT based chat with the forum it runs on. Allowing it to perform search, lookup tags and categories and summarize topics. The integration is currently restricted to public portions of the forum. Changes made: - Do not run ai reply job for small actions - Improved composable system prompt - Trivial summarizer for topics - Image generator - Google command for searching via Google - Corrected trimming of posts raw (was replacing with numbers) - Bypass of problem specs The feature works best with GPT-4 --------- Co-authored-by: Roman Rizzi <rizziromanalejandro@gmail.com>
36 lines
1.1 KiB
Ruby
36 lines
1.1 KiB
Ruby
#frozen_string_literal: true
|
|
|
|
require_relative "../../../../support/openai_completions_inference_stubs"
|
|
|
|
RSpec.describe DiscourseAi::AiBot::Commands::SummarizeCommand do
|
|
fab!(:bot_user) { User.find(DiscourseAi::AiBot::EntryPoint::GPT3_5_TURBO_ID) }
|
|
fab!(:bot) { DiscourseAi::AiBot::Bot.as(bot_user) }
|
|
|
|
describe "#process" do
|
|
it "can generate correct info" do
|
|
post = Fabricate(:post)
|
|
|
|
summarizer = described_class.new(bot, post)
|
|
info = summarizer.process("#{post.topic_id} why did it happen?")
|
|
|
|
expect(info).to include("why did it happen?")
|
|
expect(info).to include(post.raw)
|
|
expect(info).to include(post.user.username)
|
|
end
|
|
|
|
it "protects hidden data" do
|
|
category = Fabricate(:category)
|
|
category.set_permissions({})
|
|
category.save!
|
|
|
|
topic = Fabricate(:topic, category_id: category.id)
|
|
post = Fabricate(:post, topic: topic)
|
|
|
|
summarizer = described_class.new(bot, post)
|
|
info = summarizer.process("#{post.topic_id} why did it happen?")
|
|
|
|
expect(info).not_to include(post.raw)
|
|
end
|
|
end
|
|
end
|