multiwoven-integrations 0.41.4 → 0.41.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/multiwoven/integrations/core/base_connector.rb +49 -1
- data/lib/multiwoven/integrations/core/open_router_catalog.rb +15 -1
- data/lib/multiwoven/integrations/rollout.rb +1 -1
- data/lib/multiwoven/integrations/source/aisquared/client.rb +1 -1
- data/lib/multiwoven/integrations/source/anthropic/client.rb +1 -1
- data/lib/multiwoven/integrations/source/aws_sagemaker_model/client.rb +1 -1
- data/lib/multiwoven/integrations/source/databrics_model/client.rb +1 -1
- data/lib/multiwoven/integrations/source/generic_open_ai/client.rb +1 -1
- data/lib/multiwoven/integrations/source/http_model/client.rb +1 -1
- data/lib/multiwoven/integrations/source/open_ai/client.rb +1 -1
- data/lib/multiwoven/integrations/source/watsonx_ai/client.rb +7 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6c53fd23ba288ab3578c1c23581ceff400328eda9c010f05e1f5a60509fddf2f
|
|
4
|
+
data.tar.gz: 88d651895e365873ed1abdd6bcaa88190edd1aadf217dbf0c61640d7d3fff85e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0ff426493d73236e35bd1a989bb78816b3d330320f21b2c14fe933e289403115bf920fed3cd962099808dcd04747ab22b153690c184a5732d87b2e12dc2c9825
|
|
7
|
+
data.tar.gz: 55aa60ff60a337f75934c9c77410161c18e96589edeca97985e514089abd03022faf399b056dc0cfee255ba1c735ed2be7ad9bf9b7ea2d9faecc3f5b882e9a84
|
|
@@ -7,6 +7,8 @@ module Multiwoven
|
|
|
7
7
|
include Utils
|
|
8
8
|
include Constants
|
|
9
9
|
|
|
10
|
+
MAX_ERROR_MESSAGE_LENGTH = 500
|
|
11
|
+
|
|
10
12
|
def connector_spec
|
|
11
13
|
@connector_spec ||= ConnectorSpecification.from_json(keys_to_symbols(read_json(CONNECTOR_SPEC_PATH)).to_json)
|
|
12
14
|
end
|
|
@@ -86,10 +88,56 @@ module Multiwoven
|
|
|
86
88
|
end
|
|
87
89
|
|
|
88
90
|
def failure_status(error)
|
|
89
|
-
message = error
|
|
91
|
+
message = case error
|
|
92
|
+
when Exception then error.message
|
|
93
|
+
when String then error.presence
|
|
94
|
+
else error&.to_s
|
|
95
|
+
end
|
|
96
|
+
message = "failed" if message.blank?
|
|
97
|
+
|
|
90
98
|
ConnectionStatus.new(status: ConnectionStatusType["failed"], message: message).to_multiwoven_message
|
|
91
99
|
end
|
|
92
100
|
|
|
101
|
+
def failure_status_from_response(response)
|
|
102
|
+
failure_status(http_error_message(response))
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def http_error_message(response)
|
|
106
|
+
return "failed" if response.nil?
|
|
107
|
+
|
|
108
|
+
body = response.body.to_s
|
|
109
|
+
return readable_error_body(body, response) if body.blank?
|
|
110
|
+
|
|
111
|
+
json_error_message(JSON.parse(body)).presence || readable_error_body(body, response)
|
|
112
|
+
rescue StandardError
|
|
113
|
+
readable_error_body(body.to_s, response)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def json_error_message(payload)
|
|
117
|
+
return nil unless payload.is_a?(Hash)
|
|
118
|
+
|
|
119
|
+
error = payload["error"] || payload["errors"]
|
|
120
|
+
error = error.first if error.is_a?(Array)
|
|
121
|
+
description = payload["error_description"].presence
|
|
122
|
+
|
|
123
|
+
detailed_error_message(error, description) || payload["message"].presence || description
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def detailed_error_message(error, description)
|
|
127
|
+
case error
|
|
128
|
+
when Hash then error["message"].presence || error["detail"].presence
|
|
129
|
+
when String then description || error.presence
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def readable_error_body(body, response)
|
|
134
|
+
text = body.to_s.scrub.strip
|
|
135
|
+
return text.truncate(MAX_ERROR_MESSAGE_LENGTH) if text.present? && !text.start_with?("<")
|
|
136
|
+
|
|
137
|
+
code = response.respond_to?(:code) ? response.code.to_s : nil
|
|
138
|
+
code.present? ? "HTTP #{code}" : "failed"
|
|
139
|
+
end
|
|
140
|
+
|
|
93
141
|
def auth_headers(access_token)
|
|
94
142
|
{
|
|
95
143
|
"Accept" => "application/json",
|
|
@@ -123,7 +123,21 @@ module Multiwoven
|
|
|
123
123
|
|
|
124
124
|
(acc[slug.downcase] ||= []) << normalize(raw, slug.downcase)
|
|
125
125
|
end
|
|
126
|
-
grouped.transform_values { |models| sort_models(models) }
|
|
126
|
+
grouped.transform_values { |models| sort_models(without_routing_variants(models)) }
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def without_routing_variants(models)
|
|
130
|
+
plain, variants = models.partition { |model| !model[:id].to_s.include?(":") }
|
|
131
|
+
folded = variants
|
|
132
|
+
.sort_by { |model| [-model.dig(:pricing, :input).to_f, model[:id].to_s] }
|
|
133
|
+
.map do |model|
|
|
134
|
+
model.merge(
|
|
135
|
+
id: model[:id].to_s.split(":").first,
|
|
136
|
+
openrouter_id: model[:openrouter_id].to_s.split(":").first
|
|
137
|
+
)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
(plain + folded).uniq { |model| model[:id] }
|
|
127
141
|
end
|
|
128
142
|
|
|
129
143
|
# Newest first: a live list has no curation.
|
|
@@ -8,7 +8,7 @@ module Multiwoven::Integrations::Source
|
|
|
8
8
|
|
|
9
9
|
def check_connection(connection_config)
|
|
10
10
|
response = make_request(lightning_embedding_url, HTTP_POST, connection_config[:request_format], connection_config)
|
|
11
|
-
success?(response) ? success_status :
|
|
11
|
+
success?(response) ? success_status : failure_status_from_response(response)
|
|
12
12
|
rescue StandardError => e
|
|
13
13
|
handle_exception(e, { context: "AISQUARED_BOLT:CHECK_CONNECTION:EXCEPTION", type: "error" })
|
|
14
14
|
failure_status(e)
|
|
@@ -8,7 +8,7 @@ module Multiwoven::Integrations::Source
|
|
|
8
8
|
def check_connection(connection_config)
|
|
9
9
|
connection_config = prepare_config(connection_config)
|
|
10
10
|
response = make_request(ANTHROPIC_URL, HTTP_POST, connection_config[:request_format], connection_config)
|
|
11
|
-
success?(response) ? success_status :
|
|
11
|
+
success?(response) ? success_status : failure_status_from_response(response)
|
|
12
12
|
rescue StandardError => e
|
|
13
13
|
handle_exception(e, { context: "ANTHROPIC:CHECK_CONNECTION:EXCEPTION", type: "error" })
|
|
14
14
|
failure_status(e)
|
|
@@ -11,7 +11,7 @@ module Multiwoven::Integrations::Source
|
|
|
11
11
|
if response.endpoint_status == "InService"
|
|
12
12
|
success_status
|
|
13
13
|
else
|
|
14
|
-
failure_status
|
|
14
|
+
failure_status("Endpoint status is #{response.endpoint_status.presence || "unknown"}")
|
|
15
15
|
end
|
|
16
16
|
rescue StandardError => e
|
|
17
17
|
ConnectionStatus.new(status: ConnectionStatusType["failed"], message: e.message).to_multiwoven_message
|
|
@@ -15,7 +15,7 @@ module Multiwoven::Integrations::Source
|
|
|
15
15
|
if success?(response)
|
|
16
16
|
success_status
|
|
17
17
|
else
|
|
18
|
-
|
|
18
|
+
failure_status_from_response(response)
|
|
19
19
|
end
|
|
20
20
|
rescue StandardError => e
|
|
21
21
|
ConnectionStatus.new(status: ConnectionStatusType["failed"], message: e.message).to_multiwoven_message
|
|
@@ -13,7 +13,7 @@ module Multiwoven::Integrations::Source
|
|
|
13
13
|
headers: auth_headers(connection_config[:api_key]),
|
|
14
14
|
config: connection_config[:config]
|
|
15
15
|
)
|
|
16
|
-
success?(response) ? success_status :
|
|
16
|
+
success?(response) ? success_status : failure_status_from_response(response)
|
|
17
17
|
rescue StandardError => e
|
|
18
18
|
handle_exception(e, { context: "#{log_context}:CHECK_CONNECTION:EXCEPTION", type: "error" })
|
|
19
19
|
failure_status(e)
|
|
@@ -13,7 +13,7 @@ module Multiwoven::Integrations::Source
|
|
|
13
13
|
headers: connection_config[:headers],
|
|
14
14
|
config: connection_config[:config]
|
|
15
15
|
)
|
|
16
|
-
success?(response) ? success_status :
|
|
16
|
+
success?(response) ? success_status : failure_status_from_response(response)
|
|
17
17
|
rescue StandardError => e
|
|
18
18
|
handle_exception(e, { context: "HTTP MODEL:CHECK_CONNECTION:EXCEPTION", type: "error" })
|
|
19
19
|
failure_status(e)
|
|
@@ -13,7 +13,7 @@ module Multiwoven::Integrations::Source
|
|
|
13
13
|
headers: auth_headers(connection_config[:api_key]),
|
|
14
14
|
config: connection_config[:config]
|
|
15
15
|
)
|
|
16
|
-
success?(response) ? success_status :
|
|
16
|
+
success?(response) ? success_status : failure_status_from_response(response)
|
|
17
17
|
rescue StandardError => e
|
|
18
18
|
handle_exception(e, { context: "OPEN AI:CHECK_CONNECTION:EXCEPTION", type: "error" })
|
|
19
19
|
failure_status(e)
|
|
@@ -51,12 +51,17 @@ module Multiwoven::Integrations::Source
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def evaluate_deployment_status(response, deployment_id)
|
|
54
|
+
return failure_status_from_response(response) unless success?(response)
|
|
55
|
+
|
|
54
56
|
response_body = JSON.parse(response.body)
|
|
55
57
|
deployment_status = response_body["resources"]&.find { |res| res.dig("metadata", "id") == deployment_id }
|
|
56
58
|
|
|
57
|
-
return failure_status unless deployment_status
|
|
59
|
+
return failure_status("Deployment #{deployment_id} not found") unless deployment_status
|
|
60
|
+
|
|
61
|
+
state = deployment_status.dig("entity", "status", "state")
|
|
62
|
+
return success_status if state == "ready"
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
failure_status("Deployment status is #{state.presence || "unknown"}")
|
|
60
65
|
end
|
|
61
66
|
|
|
62
67
|
def prepare_config_and_payload(sync_config)
|