Class: Multiwoven::Integrations::Source::VertexModel::Client

Inherits:
SourceConnector
  • Object
show all
Defined in:
lib/multiwoven/integrations/source/google_vertex_model/client.rb

Instance Method Summary collapse

Instance Method Details

#check_connection(connection_config) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/multiwoven/integrations/source/google_vertex_model/client.rb', line 7

def check_connection(connection_config)
  connection_config = connection_config.with_indifferent_access
  create_connection(connection_config)
  @client.get_endpoint(name: build_url(GOOGLE_VERTEX_MODEL_NAME, connection_config))
  ConnectionStatus.new(status: ConnectionStatusType["succeeded"]).to_multiwoven_message
rescue StandardError => e
  ConnectionStatus.new(status: ConnectionStatusType["failed"], message: e.message).to_multiwoven_message
end

#discover(_connection_config = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/multiwoven/integrations/source/google_vertex_model/client.rb', line 16

def discover(_connection_config = nil)
  catalog_json = read_json(CATALOG_SPEC_PATH)
  catalog = build_catalog(catalog_json)
  catalog.to_multiwoven_message
rescue StandardError => e
  handle_exception(e, {
                     context: "GOOGLE:VERTEX MODEL:DISCOVER:EXCEPTION",
                     type: "error"
                   })
end

#read(sync_config) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/multiwoven/integrations/source/google_vertex_model/client.rb', line 27

def read(sync_config)
  connection_config = sync_config.source.connection_specification
  connection_config = connection_config.with_indifferent_access
  # The server checks the ConnectorQueryType.
  # If it's "ai_ml," the server calculates the payload and passes it as a query in the sync config model protocol.
  # This query is then sent to the AI/ML model.
  payload = JSON.parse(sync_config.model.query)
  run_model(connection_config, payload)
rescue StandardError => e
  handle_exception(e, {
                     context: "GOOGLE:VERTEX MODEL:READ:EXCEPTION",
                     type: "error"
                   })
end