Class: Outhad::Integrations::Source::Anthropic::Client
- Inherits:
-
SourceConnector
- Object
- SourceConnector
- Outhad::Integrations::Source::Anthropic::Client
- Defined in:
- lib/outhad/integrations/source/anthropic/client.rb
Constant Summary collapse
- API_VERSION =
"2023-06-01"
Instance Method Summary collapse
- #check_connection(connection_config) ⇒ Object
- #discover(_connection_config = nil) ⇒ Object
- #read(sync_config) ⇒ Object
Instance Method Details
#check_connection(connection_config) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/outhad/integrations/source/anthropic/client.rb', line 8 def check_connection(connection_config) connection_config = prepare_config(connection_config) response = make_request(ANTHROPIC_URL, HTTP_POST, connection_config[:request_format], connection_config) success?(response) ? success_status : failure_status(nil) rescue StandardError => e handle_exception(e, { context: "ANTHROPIC:CHECK_CONNECTION:EXCEPTION", type: "error" }) failure_status(e) end |
#discover(_connection_config = nil) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/outhad/integrations/source/anthropic/client.rb', line 17 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: "ANTHROPIC:DISCOVER:EXCEPTION", type: "error" }) end |
#read(sync_config) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/outhad/integrations/source/anthropic/client.rb', line 25 def read(sync_config) # 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. connection_config = prepare_config(sync_config.source.connection_specification) stream = connection_config[:is_stream] ||= false payload = sync_config.model.query if stream run_model_stream(connection_config, payload) { || yield if block_given? } else run_model(connection_config, payload) end rescue StandardError => e handle_exception(e, { context: "ANTHROPIC:READ:EXCEPTION", type: "error" }) end |