mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-03-06 17:30:20 +00:00
This allows custom tools access to uploads and sophisticated searches using embedding. It introduces: - A shared front end for listing and uploading files (shared with personas) - Backend implementation of index.search function within a custom tool. Custom tools now may search through uploaded files function invoke(params) { return index.search(params.query) } This means that RAG implementers now may preload tools with knowledge and have high fidelity over the search. The search function support specifying max results specifying a subset of files to search (from uploads) Also - Improved documentation for tools (when creating a tool a preamble explains all the functionality) - uploads were a bit finicky, fixed an edge case where the UI would not show them as updated
37 lines
1015 B
Ruby
37 lines
1015 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe DiscourseAi::Admin::RagDocumentFragmentsController do
|
|
fab!(:admin)
|
|
fab!(:ai_persona)
|
|
|
|
before do
|
|
sign_in(admin)
|
|
|
|
SiteSetting.ai_embeddings_enabled = true
|
|
SiteSetting.ai_embeddings_discourse_service_api_endpoint = "http://test.com"
|
|
end
|
|
|
|
describe "GET #indexing_status_check" do
|
|
it "works for AiPersona" do
|
|
get "/admin/plugins/discourse-ai/rag-document-fragments/files/status.json?target_type=AiPersona&target_id=#{ai_persona.id}"
|
|
|
|
expect(response.parsed_body).to eq({})
|
|
expect(response.status).to eq(200)
|
|
end
|
|
end
|
|
|
|
describe "POST #upload_file" do
|
|
it "works" do
|
|
post "/admin/plugins/discourse-ai/rag-document-fragments/files/upload.json",
|
|
params: {
|
|
file: Rack::Test::UploadedFile.new(file_from_fixtures("spec.txt", "md")),
|
|
}
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
upload = Upload.last
|
|
expect(upload.original_filename).to end_with("spec.txt")
|
|
end
|
|
end
|
|
end
|