tokenr-ruby 0.1.1 → 0.1.3
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/tokenr/client.rb +12 -3
- data/lib/tokenr/integrations/anthropic.rb +1 -1
- data/lib/tokenr/version.rb +1 -1
- 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: 15ea6965561601d93515ffdf3448f286976ad610bcb2374f225d30404fa6d008
|
|
4
|
+
data.tar.gz: d4e501b932db24625348ed27c82003e702dcf4e05ec32664e7bd1255eb13ac43
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 255f3b2269c15a41ad3e29c3f302dd79a2498e4098351afa8827db98cc8dde58d75b0acc625e899af24d68ce2bd892a2128e8471f8ac599b6a8aad2fe5555e2f
|
|
7
|
+
data.tar.gz: 9f46b51a1e802659dd855474f4fa1c67cbfc8a320560d16130c6ba6e87bb8c8ae84f62f635b8035c5454fbbcbaa2e0d83e8e44d9c4fa8393f9956a0e13588349
|
data/lib/tokenr/client.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "net/http"
|
|
4
4
|
require "json"
|
|
5
|
+
require "openssl"
|
|
5
6
|
require "uri"
|
|
6
7
|
|
|
7
8
|
module Tokenr
|
|
@@ -66,9 +67,17 @@ module Tokenr
|
|
|
66
67
|
def request(method, path, body = nil, params = {})
|
|
67
68
|
uri = build_uri(path, params)
|
|
68
69
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
69
|
-
http.use_ssl
|
|
70
|
-
http.open_timeout
|
|
71
|
-
http.read_timeout
|
|
70
|
+
http.use_ssl = uri.scheme == "https"
|
|
71
|
+
http.open_timeout = 5
|
|
72
|
+
http.read_timeout = 30
|
|
73
|
+
if http.use_ssl?
|
|
74
|
+
# Use VERIFY_PEER with an explicit cert store that has no CRL check flags.
|
|
75
|
+
# This keeps certificate chain validation while avoiding CRL fetch failures
|
|
76
|
+
# on servers whose CA certificates have CRL distribution points that are
|
|
77
|
+
# unreachable or return errors.
|
|
78
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
|
79
|
+
http.cert_store = OpenSSL::X509::Store.new.tap(&:set_default_paths)
|
|
80
|
+
end
|
|
72
81
|
|
|
73
82
|
req = build_request(method, uri, body)
|
|
74
83
|
handle_response(http.request(req))
|
|
@@ -39,7 +39,7 @@ module Tokenr
|
|
|
39
39
|
|
|
40
40
|
def messages(model:, messages:, **params)
|
|
41
41
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
42
|
-
response = client.messages(model: model, messages: messages, **params)
|
|
42
|
+
response = client.messages.create(model: model, messages: messages, **params)
|
|
43
43
|
latency = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1000).round
|
|
44
44
|
|
|
45
45
|
track_response(model, response, latency)
|
data/lib/tokenr/version.rb
CHANGED