omniai-anthropic 2.0.0 → 2.4.0
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/omniai/anthropic/chat/{media_serializer.rb → file_serializer.rb} +3 -3
- data/lib/omniai/anthropic/chat/stream.rb +2 -2
- data/lib/omniai/anthropic/chat/url_serializer.rb +22 -0
- data/lib/omniai/anthropic/chat.rb +3 -3
- data/lib/omniai/anthropic/computer.rb +3 -5
- data/lib/omniai/anthropic/version.rb +1 -1
- data/lib/omniai/anthropic.rb +1 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 432b0a2b669699038fc1076023ba872101dc9af116ca55968104edc02e18f0a4
|
4
|
+
data.tar.gz: f037d7e7deeed2342828729babca7697150ed8c715aaf3feb054e7a174e2c21f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 649fa09f24264c7e17491a014954fb6a23141660c4777c0b2841cf4b1ac6ec0ae16512a571976cc56b952d98743da46ed8ea4e5e8862e01d0d23e5b5cd6f33d0
|
7
|
+
data.tar.gz: db8f841a61981bacebd413590bcc61437d8a580311c489f895f51a55a1649848cd7b02899dc25a6f3f4c12d870f626ed110c7db8fefb3dff8a80ba1f5635879f
|
@@ -3,13 +3,13 @@
|
|
3
3
|
module OmniAI
|
4
4
|
module Anthropic
|
5
5
|
class Chat
|
6
|
-
# Overrides
|
7
|
-
module
|
6
|
+
# Overrides file serialize / deserialize.
|
7
|
+
module FileSerializer
|
8
8
|
# @param media [OmniAI::Chat::Media]
|
9
9
|
# @return [Hash]
|
10
10
|
def self.serialize(media, *)
|
11
11
|
{
|
12
|
-
type: media.kind, # i.e. 'image' / 'video' / 'audio' / ...
|
12
|
+
type: media.kind, # i.e. 'image' / 'video' / 'audio' / 'document' / ...
|
13
13
|
source: {
|
14
14
|
type: "base64",
|
15
15
|
media_type: media.type, # i.e. 'image/jpeg' / 'video/ogg' / 'audio/mpeg' / ...
|
@@ -127,7 +127,7 @@ module OmniAI
|
|
127
127
|
content = @data["content"][index]
|
128
128
|
content["text"] += data["delta"]["text"]
|
129
129
|
|
130
|
-
block&.call(OmniAI::Chat::Delta.new(text:
|
130
|
+
block&.call(OmniAI::Chat::Delta.new(text:))
|
131
131
|
end
|
132
132
|
|
133
133
|
# Handler for Type::CONTENT_BLOCK_DELTA w/ ContentBlockDeltaType::INPUT_JSON_DELTA
|
@@ -144,7 +144,7 @@ module OmniAI
|
|
144
144
|
|
145
145
|
# Handler for Type::CONTENT_BLOCK_STOP
|
146
146
|
#
|
147
|
-
# @param
|
147
|
+
# @param data [Hash]
|
148
148
|
def content_block_stop(data)
|
149
149
|
index = data["index"]
|
150
150
|
content = @data["content"][index]
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OmniAI
|
4
|
+
module Anthropic
|
5
|
+
class Chat
|
6
|
+
# Overrides url serialize / deserialize.
|
7
|
+
module URLSerializer
|
8
|
+
# @param url [OmniAI::Chat::Media]
|
9
|
+
# @return [Hash]
|
10
|
+
def self.serialize(url, *)
|
11
|
+
{
|
12
|
+
type: url.kind, # i.e. 'image' / 'video' / 'audio' / 'document' / ...
|
13
|
+
source: {
|
14
|
+
type: "url",
|
15
|
+
url: url.uri,
|
16
|
+
},
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -42,8 +42,8 @@ module OmniAI
|
|
42
42
|
CONTEXT = Context.build do |context|
|
43
43
|
context.serializers[:tool] = ToolSerializer.method(:serialize)
|
44
44
|
|
45
|
-
context.serializers[:file] =
|
46
|
-
context.serializers[:url] =
|
45
|
+
context.serializers[:file] = FileSerializer.method(:serialize)
|
46
|
+
context.serializers[:url] = URLSerializer.method(:serialize)
|
47
47
|
|
48
48
|
context.serializers[:choice] = ChoiceSerializer.method(:serialize)
|
49
49
|
context.deserializers[:choice] = ChoiceSerializer.method(:deserialize)
|
@@ -70,7 +70,7 @@ module OmniAI
|
|
70
70
|
model: @model,
|
71
71
|
messages:,
|
72
72
|
system:,
|
73
|
-
stream:
|
73
|
+
stream: stream? || nil,
|
74
74
|
temperature: @temperature,
|
75
75
|
tools: tools_payload,
|
76
76
|
}).compact
|
@@ -93,8 +93,8 @@ module OmniAI
|
|
93
93
|
# @return [Array<Hash>]
|
94
94
|
def perform(action:, text: nil, coordinate: nil) # rubocop:disable Metrics/CyclomaticComplexity
|
95
95
|
case action
|
96
|
-
when Action::KEY then key(text:
|
97
|
-
when Action::TYPE then type(text:
|
96
|
+
when Action::KEY then key(text:)
|
97
|
+
when Action::TYPE then type(text:)
|
98
98
|
when Action::CURSOR_POSITION then mouse_location
|
99
99
|
when Action::LEFT_CLICK then click(button: Button::LEFT)
|
100
100
|
when Action::MIDDLE_CLICK then click(button: Button::MIDDLE)
|
@@ -117,8 +117,6 @@ module OmniAI
|
|
117
117
|
"stdout=#{stdout.inspect} stderr=#{stderr.inspect} status=#{status}"
|
118
118
|
end
|
119
119
|
|
120
|
-
# @param cmd [String]
|
121
|
-
#
|
122
120
|
# @return [String]
|
123
121
|
def xdotool(...)
|
124
122
|
shell("xdotool", ...)
|
@@ -182,7 +180,7 @@ module OmniAI
|
|
182
180
|
tempfile.rewind
|
183
181
|
data = Base64.encode64(tempfile.read)
|
184
182
|
|
185
|
-
{ type: "base64", media_type: "image/png", data:
|
183
|
+
{ type: "base64", media_type: "image/png", data: }
|
186
184
|
ensure
|
187
185
|
tempfile.close
|
188
186
|
tempfile.unlink
|
data/lib/omniai/anthropic.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniai-anthropic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Sylvestre
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-04-08 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: event_stream_parser
|
@@ -29,14 +29,14 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '2.
|
32
|
+
version: '2.4'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '2.
|
39
|
+
version: '2.4'
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: zeitwerk
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,8 +64,8 @@ files:
|
|
64
64
|
- lib/omniai/anthropic/chat.rb
|
65
65
|
- lib/omniai/anthropic/chat/choice_serializer.rb
|
66
66
|
- lib/omniai/anthropic/chat/content_serializer.rb
|
67
|
+
- lib/omniai/anthropic/chat/file_serializer.rb
|
67
68
|
- lib/omniai/anthropic/chat/function_serializer.rb
|
68
|
-
- lib/omniai/anthropic/chat/media_serializer.rb
|
69
69
|
- lib/omniai/anthropic/chat/message_serializer.rb
|
70
70
|
- lib/omniai/anthropic/chat/response_serializer.rb
|
71
71
|
- lib/omniai/anthropic/chat/stream.rb
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/omniai/anthropic/chat/tool_call_result_serializer.rb
|
74
74
|
- lib/omniai/anthropic/chat/tool_call_serializer.rb
|
75
75
|
- lib/omniai/anthropic/chat/tool_serializer.rb
|
76
|
+
- lib/omniai/anthropic/chat/url_serializer.rb
|
76
77
|
- lib/omniai/anthropic/client.rb
|
77
78
|
- lib/omniai/anthropic/computer.rb
|
78
79
|
- lib/omniai/anthropic/config.rb
|