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-07-30 12:44:57 -04:00
|
|
|
fab!(:llm_model)
|
|
|
|
let(:bot_user) { DiscourseAi::AiBot::EntryPoint.find_user_from_model(llm_model.name) }
|
|
|
|
let(:llm) { DiscourseAi::Completions::Llm.proxy("custom:#{llm_model.id}") }
|
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
|