2023-08-30 02:15:03 -04:00
|
|
|
#frozen_string_literal: true
|
|
|
|
|
2024-01-04 08:44:07 -05:00
|
|
|
RSpec.describe DiscourseAi::AiBot::Tools::DbSchema do
|
|
|
|
let(:bot_user) { User.find(DiscourseAi::AiBot::EntryPoint::GPT3_5_TURBO_ID) }
|
2024-01-29 14:04:25 -05:00
|
|
|
let(:llm) { DiscourseAi::Completions::Llm.proxy("open_ai:gpt-3.5-turbo") }
|
2024-01-04 08:44:07 -05:00
|
|
|
|
|
|
|
before { SiteSetting.ai_bot_enabled = true }
|
2023-08-30 02:15:03 -04:00
|
|
|
describe "#process" do
|
|
|
|
it "returns rich schema for tables" do
|
2024-01-04 08:44:07 -05:00
|
|
|
result = described_class.new({ tables: "posts,topics" }).invoke(bot_user, llm)
|
|
|
|
|
2023-08-30 02:15:03 -04:00
|
|
|
expect(result[:schema_info]).to include("raw text")
|
|
|
|
expect(result[:schema_info]).to include("views integer")
|
|
|
|
expect(result[:schema_info]).to include("posts")
|
|
|
|
expect(result[:schema_info]).to include("topics")
|
|
|
|
|
2023-10-27 01:21:09 -04:00
|
|
|
expect(result[:tables]).to eq("posts,topics")
|
2023-08-30 02:15:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|