foobara-anthropic-api 1.0.5 → 1.0.7
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/src/foobara/ai/anthropic_api/base_command.rb +4 -4
- data/src/foobara/ai/anthropic_api/create_message.rb +5 -7
- data/src/foobara/ai/anthropic_api/get_page_of_models.rb +5 -1
- data/src/foobara/ai/anthropic_api/types/message_result/content.rb +11 -2
- data/src/foobara/ai/anthropic_api/types/message_result/usage.rb +11 -0
- data/src/foobara/ai/anthropic_api/types/message_result.rb +9 -0
- data/src/foobara/ai/anthropic_api/types/model.rb +6 -0
- data/src/foobara/ai/anthropic_api.rb +1 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eda96d5cdb535c70b4b794742575e31fbdb084f081480372b6212b94dc514053
|
|
4
|
+
data.tar.gz: d13ebe86723cb1685e47ffdbb65965fa28d8835189d374548c1f91d8bca35b69
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a49028e521f5ee955f7636cca01b5be45036fb89faf7c6d1fcdde9ebd2629c183af4a9f9790a24c58a110e437dde7a71880fc49d23bc6379e6316389f410699
|
|
7
|
+
data.tar.gz: 6a80261967d7d9cc57e140b5b9c62e9c523d8fef3b5ebdcd9eca5f6966ea0542baad19069303d7b20ad1940c7a6a7974e1166094714d874b93c19657f0d2ae05
|
|
@@ -47,16 +47,16 @@ module Foobara
|
|
|
47
47
|
case response.code
|
|
48
48
|
when "429"
|
|
49
49
|
# TODO: figure out how to test this code path
|
|
50
|
-
# :
|
|
50
|
+
# simplecov:disable
|
|
51
51
|
sleep 2 ** failures
|
|
52
52
|
issue_http_request(failures + 1)
|
|
53
|
-
# :
|
|
53
|
+
# simplecov:enable
|
|
54
54
|
when "529"
|
|
55
|
-
# :
|
|
55
|
+
# simplecov:disable
|
|
56
56
|
failures += 1
|
|
57
57
|
sleep failures
|
|
58
58
|
issue_http_request(failures)
|
|
59
|
-
# :
|
|
59
|
+
# simplecov:enable
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
end
|
|
@@ -12,7 +12,6 @@ module Foobara
|
|
|
12
12
|
max_tokens :integer, default: 1024
|
|
13
13
|
model :model_enum, default: AnthropicApi.default_llm_model
|
|
14
14
|
messages [Types::Message]
|
|
15
|
-
temperature :float
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
result Types::MessageResult
|
|
@@ -20,11 +19,6 @@ module Foobara
|
|
|
20
19
|
def build_request_body
|
|
21
20
|
body = { model:, max_tokens:, messages: }
|
|
22
21
|
|
|
23
|
-
temp = inputs[:temperature]
|
|
24
|
-
if temp
|
|
25
|
-
body[:temperature] = temp
|
|
26
|
-
end
|
|
27
|
-
|
|
28
22
|
sys = inputs[:system]
|
|
29
23
|
if sys
|
|
30
24
|
body[:system] = sys
|
|
@@ -34,7 +28,11 @@ module Foobara
|
|
|
34
28
|
end
|
|
35
29
|
|
|
36
30
|
def build_result
|
|
37
|
-
Types::MessageResult.new(
|
|
31
|
+
Types::MessageResult.new(
|
|
32
|
+
response_body,
|
|
33
|
+
# Set this to false to discover new attributes
|
|
34
|
+
ignore_unexpected_attributes: true
|
|
35
|
+
)
|
|
38
36
|
end
|
|
39
37
|
end
|
|
40
38
|
end
|
|
@@ -25,7 +25,11 @@ module Foobara
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def build_result
|
|
28
|
-
Types::PageOfModels.new(
|
|
28
|
+
Types::PageOfModels.new(
|
|
29
|
+
response_body,
|
|
30
|
+
# Set this to false to discover new attributes
|
|
31
|
+
ignore_unexpected_attributes: true
|
|
32
|
+
)
|
|
29
33
|
end
|
|
30
34
|
end
|
|
31
35
|
end
|
|
@@ -4,9 +4,18 @@ module Foobara
|
|
|
4
4
|
module Types
|
|
5
5
|
class MessageResult < Foobara::Model
|
|
6
6
|
class Content < Foobara::Model
|
|
7
|
+
# TODO: we either need to support inheritance better (maybe it already works?) or better validations.
|
|
8
|
+
# The issue is that we will have "text" if it's actually text but could also be "thinking"
|
|
7
9
|
attributes do
|
|
8
|
-
|
|
9
|
-
type :string, :required, one_of: ["text"]
|
|
10
|
+
# TODO: scared to explicitly put one_of: because Anthropic might just drop in new values.
|
|
11
|
+
type :string, :required # , one_of: ["text", "thinking"]
|
|
12
|
+
|
|
13
|
+
# Only present when type is "text"
|
|
14
|
+
text :string
|
|
15
|
+
|
|
16
|
+
# Only present when type is "thinking"
|
|
17
|
+
thinking :string
|
|
18
|
+
signature :string
|
|
10
19
|
end
|
|
11
20
|
end
|
|
12
21
|
end
|
|
@@ -7,6 +7,17 @@ module Foobara
|
|
|
7
7
|
attributes do
|
|
8
8
|
input_tokens :integer, :required
|
|
9
9
|
output_tokens :integer, :required
|
|
10
|
+
|
|
11
|
+
# TODO: no clue if this can actually be null
|
|
12
|
+
cache_creation_input_tokens :integer, :allow_nil
|
|
13
|
+
# TODO: no clue if this can actually be null
|
|
14
|
+
cache_read_input_tokens :integer, :allow_nil
|
|
15
|
+
# TODO: type this
|
|
16
|
+
cache_creation :duckture, :allow_nil
|
|
17
|
+
# TODO: appears to be some kind of enum. No clue if it can be null
|
|
18
|
+
service_tier :string, :allow_nil
|
|
19
|
+
# TODO: appears to be some kind of enum. No clue if it can be null
|
|
20
|
+
inference_geo :string, :allow_nil
|
|
10
21
|
end
|
|
11
22
|
end
|
|
12
23
|
end
|
|
@@ -15,6 +15,15 @@ module Foobara
|
|
|
15
15
|
stop_sequence :string, :allow_nil
|
|
16
16
|
type :string, :required, one_of: ["message"]
|
|
17
17
|
usage Usage
|
|
18
|
+
|
|
19
|
+
# TODO: type this, no clue what it is (but it can definitely be null)
|
|
20
|
+
stop_details :duck
|
|
21
|
+
# TODO: type this, no clue what it is (but it can definitely be null)
|
|
22
|
+
container :duck
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def text
|
|
26
|
+
content.find { it.type == "text" }.text
|
|
18
27
|
end
|
|
19
28
|
end
|
|
20
29
|
end
|
|
@@ -8,6 +8,12 @@ module Foobara
|
|
|
8
8
|
display_name :string, :required
|
|
9
9
|
type :string, :required
|
|
10
10
|
created_at :datetime, :required
|
|
11
|
+
# TODO: unclear if this can be null
|
|
12
|
+
max_input_tokens :integer, :allow_nil
|
|
13
|
+
# TODO: unclear if this can be null
|
|
14
|
+
max_tokens :integer, :allow_nil
|
|
15
|
+
# TODO: properly type this
|
|
16
|
+
capabilities :duckture, :allow_nil
|
|
11
17
|
end
|
|
12
18
|
end
|
|
13
19
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foobara-anthropic-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Miles Georgi
|
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
101
|
version: '0'
|
|
102
102
|
requirements: []
|
|
103
|
-
rubygems_version:
|
|
103
|
+
rubygems_version: 4.0.20
|
|
104
104
|
specification_version: 4
|
|
105
105
|
summary: No description. Add one.
|
|
106
106
|
test_files: []
|