omniai 1.6.6 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/README.md +55 -3
  4. data/lib/omniai/chat/choice.rb +68 -0
  5. data/lib/omniai/chat/content.rb +10 -2
  6. data/lib/omniai/chat/file.rb +3 -3
  7. data/lib/omniai/chat/function.rb +57 -0
  8. data/lib/omniai/chat/message/builder.rb +67 -0
  9. data/lib/omniai/chat/message.rb +64 -45
  10. data/lib/omniai/chat/payload.rb +85 -0
  11. data/lib/omniai/chat/prompt.rb +30 -16
  12. data/lib/omniai/chat/response.rb +70 -0
  13. data/lib/omniai/chat/stream.rb +61 -0
  14. data/lib/omniai/chat/text.rb +2 -2
  15. data/lib/omniai/chat/tool_call.rb +54 -0
  16. data/lib/omniai/chat/tool_call_message.rb +61 -0
  17. data/lib/omniai/chat/tool_call_result.rb +51 -0
  18. data/lib/omniai/chat/url.rb +2 -2
  19. data/lib/omniai/chat/usage.rb +60 -0
  20. data/lib/omniai/chat.rb +61 -34
  21. data/lib/omniai/cli/embed_handler.rb +58 -0
  22. data/lib/omniai/cli.rb +8 -4
  23. data/lib/omniai/client.rb +10 -0
  24. data/lib/omniai/context.rb +55 -0
  25. data/lib/omniai/embed/response.rb +59 -0
  26. data/lib/omniai/embed/usage.rb +26 -0
  27. data/lib/omniai/embed.rb +80 -0
  28. data/lib/omniai/tool.rb +6 -2
  29. data/lib/omniai/version.rb +1 -1
  30. metadata +17 -17
  31. data/lib/omniai/chat/context.rb +0 -42
  32. data/lib/omniai/chat/response/choice.rb +0 -35
  33. data/lib/omniai/chat/response/chunk.rb +0 -15
  34. data/lib/omniai/chat/response/completion.rb +0 -15
  35. data/lib/omniai/chat/response/delta.rb +0 -11
  36. data/lib/omniai/chat/response/delta_choice.rb +0 -25
  37. data/lib/omniai/chat/response/function.rb +0 -25
  38. data/lib/omniai/chat/response/message.rb +0 -11
  39. data/lib/omniai/chat/response/message_choice.rb +0 -25
  40. data/lib/omniai/chat/response/part.rb +0 -38
  41. data/lib/omniai/chat/response/payload.rb +0 -72
  42. data/lib/omniai/chat/response/resource.rb +0 -22
  43. data/lib/omniai/chat/response/stream.rb +0 -27
  44. data/lib/omniai/chat/response/tool_call.rb +0 -30
  45. 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