feat: Interface to validate response_source (#8894)

- This PR adds a UI to validate the response source quality quickly. It also helps to test with sample questions and update responses in the database when missing.

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Sojan Jose
2024-02-26 20:20:12 +05:30
committed by GitHub
parent 77e463990a
commit 773be6f8ec
23 changed files with 514 additions and 57 deletions

View File

@@ -25,4 +25,9 @@ class ResponseSource < ApplicationRecord
has_many :responses, dependent: :destroy_async
accepts_nested_attributes_for :response_documents
def get_responses(query)
embedding = Openai::EmbeddingsService.new.get_embedding(query)
responses.active.nearest_neighbors(:embedding, embedding, distance: 'cosine').first(5)
end
end