omniai 1.6.6 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +55 -3
- data/lib/omniai/chat/choice.rb +68 -0
- data/lib/omniai/chat/content.rb +10 -2
- data/lib/omniai/chat/file.rb +3 -3
- data/lib/omniai/chat/function.rb +57 -0
- data/lib/omniai/chat/message/builder.rb +67 -0
- data/lib/omniai/chat/message.rb +64 -45
- data/lib/omniai/chat/payload.rb +85 -0
- data/lib/omniai/chat/prompt.rb +30 -16
- data/lib/omniai/chat/response.rb +70 -0
- data/lib/omniai/chat/stream.rb +61 -0
- data/lib/omniai/chat/text.rb +2 -2
- data/lib/omniai/chat/tool_call.rb +54 -0
- data/lib/omniai/chat/tool_call_message.rb +61 -0
- data/lib/omniai/chat/tool_call_result.rb +51 -0
- data/lib/omniai/chat/url.rb +2 -2
- data/lib/omniai/chat/usage.rb +60 -0
- data/lib/omniai/chat.rb +61 -34
- data/lib/omniai/cli/embed_handler.rb +58 -0
- data/lib/omniai/cli.rb +8 -4
- data/lib/omniai/client.rb +10 -0
- data/lib/omniai/context.rb +55 -0
- data/lib/omniai/embed/response.rb +59 -0
- data/lib/omniai/embed/usage.rb +26 -0
- data/lib/omniai/embed.rb +80 -0
- data/lib/omniai/tool.rb +6 -2
- data/lib/omniai/version.rb +1 -1
- metadata +17 -17
- data/lib/omniai/chat/context.rb +0 -42
- data/lib/omniai/chat/response/choice.rb +0 -35
- data/lib/omniai/chat/response/chunk.rb +0 -15
- data/lib/omniai/chat/response/completion.rb +0 -15
- data/lib/omniai/chat/response/delta.rb +0 -11
- data/lib/omniai/chat/response/delta_choice.rb +0 -25
- data/lib/omniai/chat/response/function.rb +0 -25
- data/lib/omniai/chat/response/message.rb +0 -11
- data/lib/omniai/chat/response/message_choice.rb +0 -25
- data/lib/omniai/chat/response/part.rb +0 -38
- data/lib/omniai/chat/response/payload.rb +0 -72
- data/lib/omniai/chat/response/resource.rb +0 -22
- data/lib/omniai/chat/response/stream.rb +0 -27
- data/lib/omniai/chat/response/tool_call.rb +0 -30
- data/lib/omniai/chat/response/usage.rb +0 -35
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module OmniAI
|
4
|
-
class Chat
|
5
|
-
module Response
|
6
|
-
# A tool-call returned by the API.
|
7
|
-
class ToolCall < Resource
|
8
|
-
# @return [String]
|
9
|
-
def inspect
|
10
|
-
"#<#{self.class.name} id=#{id.inspect} type=#{type.inspect}>"
|
11
|
-
end
|
12
|
-
|
13
|
-
# @return [String]
|
14
|
-
def id
|
15
|
-
@data['id']
|
16
|
-
end
|
17
|
-
|
18
|
-
# @return [String]
|
19
|
-
def type
|
20
|
-
@data['type']
|
21
|
-
end
|
22
|
-
|
23
|
-
# @return [Function]
|
24
|
-
def function
|
25
|
-
@function ||= Function.new(data: @data['function']) if @data['function']
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module OmniAI
|
4
|
-
class Chat
|
5
|
-
module Response
|
6
|
-
# A usage returned by the API.
|
7
|
-
class Usage < Resource
|
8
|
-
# @return [String]
|
9
|
-
def inspect
|
10
|
-
properties = [
|
11
|
-
"input_tokens=#{input_tokens}",
|
12
|
-
"output_tokens=#{output_tokens}",
|
13
|
-
"total_tokens=#{total_tokens}",
|
14
|
-
]
|
15
|
-
"#<#{self.class.name} #{properties.join(' ')}>"
|
16
|
-
end
|
17
|
-
|
18
|
-
# @return [Integer]
|
19
|
-
def input_tokens
|
20
|
-
@data['input_tokens'] || @data['prompt_tokens']
|
21
|
-
end
|
22
|
-
|
23
|
-
# @return [Integer]
|
24
|
-
def output_tokens
|
25
|
-
@data['output_tokens'] || @data['completion_tokens']
|
26
|
-
end
|
27
|
-
|
28
|
-
# @return [Integer]
|
29
|
-
def total_tokens
|
30
|
-
@data['total_tokens'] || (input_tokens + output_tokens)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|