Class: Outhad::Integrations::Source::Qdrant::Client
- Inherits:
-
VectorSourceConnector
- Object
- VectorSourceConnector
- Outhad::Integrations::Source::Qdrant::Client
- Defined in:
- lib/outhad/integrations/source/qdrant/client.rb
Instance Method Summary collapse
- #check_connection(connection_config) ⇒ Object
- #discover(_connection_config = nil) ⇒ Object
- #search(vector_search_config) ⇒ Object
Instance Method Details
#check_connection(connection_config) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/outhad/integrations/source/qdrant/client.rb', line 7 def check_connection(connection_config) connection_config = connection_config.with_indifferent_access create_connection(connection_config) response = Outhad::Integrations::Core::HttpClient.request( @host, HTTP_GET, headers: auth_headers(@api_key) ) if success?(response) success_status else failure_status(nil) end rescue StandardError => e handle_exception(e, { context: "QDRANT:CHECK_CONNECTION:EXCEPTION", type: "error" }) failure_status(e) end |
#discover(_connection_config = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/outhad/integrations/source/qdrant/client.rb', line 28 def discover(_connection_config = nil) catalog_json = read_json(CATALOG_SPEC_PATH) catalog = build_catalog(catalog_json) catalog. rescue StandardError => e handle_exception(e, { context: "QDRANT:DISCOVER:EXCEPTION", type: "error" }) end |
#search(vector_search_config) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/outhad/integrations/source/qdrant/client.rb', line 39 def search(vector_search_config) connection_config = vector_search_config.source.connection_specification connection_config = connection_config.with_indifferent_access create_connection(connection_config) url = build_url(QDRANT_SEARCH_URL) body = { vector: vector_search_config[:vector], top: vector_search_config[:limit] } response = Outhad::Integrations::Core::HttpClient.request( url, HTTP_POST, headers: { "Content-Type" => "application/json", "api-key" => @api_key }, payload: body ) response = JSON.parse(response.body).with_indifferent_access records = response[:result] || [] records.map do |row| RecordMessage.new(data: row, emitted_at: Time.now.to_i). end rescue StandardError => e handle_exception(e, { context: "QDRANT:SEARCH:EXCEPTION", type: "error" }) end |