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
|
2024-06-18 13:32:14 -04:00
|
|
|
let(:bot_user) { DiscourseAi::AiBot::EntryPoint.find_user_from_model("gpt-3.5-turbo") }
|
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-05-07 07:55:46 -04:00
|
|
|
result = described_class.new({ tables: "posts,topics" }, bot_user: bot_user, llm: llm).invoke
|
2024-01-04 08:44:07 -05:00
|
|
|
|
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
|