activeagent 1.0.0.rc1 → 1.0.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.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -1
  3. data/lib/active_agent/providers/_base_provider.rb +92 -82
  4. data/lib/active_agent/providers/anthropic/_types.rb +2 -2
  5. data/lib/active_agent/providers/anthropic/request.rb +135 -81
  6. data/lib/active_agent/providers/anthropic/transforms.rb +353 -0
  7. data/lib/active_agent/providers/anthropic_provider.rb +96 -53
  8. data/lib/active_agent/providers/common/messages/_types.rb +37 -1
  9. data/lib/active_agent/providers/common/responses/base.rb +118 -70
  10. data/lib/active_agent/providers/common/usage.rb +385 -0
  11. data/lib/active_agent/providers/concerns/instrumentation.rb +263 -0
  12. data/lib/active_agent/providers/log_subscriber.rb +64 -246
  13. data/lib/active_agent/providers/mock_provider.rb +23 -23
  14. data/lib/active_agent/providers/ollama/chat/request.rb +214 -35
  15. data/lib/active_agent/providers/ollama/chat/transforms.rb +135 -0
  16. data/lib/active_agent/providers/ollama/embedding/request.rb +160 -47
  17. data/lib/active_agent/providers/ollama/embedding/transforms.rb +160 -0
  18. data/lib/active_agent/providers/ollama_provider.rb +0 -1
  19. data/lib/active_agent/providers/open_ai/_base.rb +3 -2
  20. data/lib/active_agent/providers/open_ai/chat/_types.rb +13 -1
  21. data/lib/active_agent/providers/open_ai/chat/request.rb +132 -186
  22. data/lib/active_agent/providers/open_ai/chat/transforms.rb +364 -0
  23. data/lib/active_agent/providers/open_ai/chat_provider.rb +57 -36
  24. data/lib/active_agent/providers/open_ai/embedding/_types.rb +13 -2
  25. data/lib/active_agent/providers/open_ai/embedding/request.rb +38 -70
  26. data/lib/active_agent/providers/open_ai/embedding/transforms.rb +88 -0
  27. data/lib/active_agent/providers/open_ai/responses/_types.rb +1 -7
  28. data/lib/active_agent/providers/open_ai/responses/request.rb +100 -134
  29. data/lib/active_agent/providers/open_ai/responses/transforms.rb +228 -0
  30. data/lib/active_agent/providers/open_ai/responses_provider.rb +77 -30
  31. data/lib/active_agent/providers/open_ai_provider.rb +0 -3
  32. data/lib/active_agent/providers/open_router/_types.rb +27 -1
  33. data/lib/active_agent/providers/open_router/options.rb +49 -1
  34. data/lib/active_agent/providers/open_router/request.rb +232 -66
  35. data/lib/active_agent/providers/open_router/requests/_types.rb +0 -1
  36. data/lib/active_agent/providers/open_router/requests/messages/_types.rb +37 -40
  37. data/lib/active_agent/providers/open_router/requests/messages/content/file.rb +19 -3
  38. data/lib/active_agent/providers/open_router/requests/messages/content/files/details.rb +15 -4
  39. data/lib/active_agent/providers/open_router/requests/plugin.rb +19 -3
  40. data/lib/active_agent/providers/open_router/requests/plugins/pdf_config.rb +30 -8
  41. data/lib/active_agent/providers/open_router/requests/prediction.rb +17 -0
  42. data/lib/active_agent/providers/open_router/requests/provider_preferences/max_price.rb +41 -7
  43. data/lib/active_agent/providers/open_router/requests/provider_preferences.rb +60 -19
  44. data/lib/active_agent/providers/open_router/requests/response_format.rb +30 -2
  45. data/lib/active_agent/providers/open_router/transforms.rb +134 -0
  46. data/lib/active_agent/providers/open_router_provider.rb +9 -0
  47. data/lib/active_agent/version.rb +1 -1
  48. metadata +15 -159
  49. data/lib/active_agent/generation_provider/open_router/types.rb +0 -505
  50. data/lib/active_agent/generation_provider/xai_provider.rb +0 -144
  51. data/lib/active_agent/providers/anthropic/requests/_types.rb +0 -190
  52. data/lib/active_agent/providers/anthropic/requests/container_params.rb +0 -19
  53. data/lib/active_agent/providers/anthropic/requests/content/base.rb +0 -21
  54. data/lib/active_agent/providers/anthropic/requests/content/sources/base.rb +0 -22
  55. data/lib/active_agent/providers/anthropic/requests/context_management_config.rb +0 -18
  56. data/lib/active_agent/providers/anthropic/requests/messages/_types.rb +0 -189
  57. data/lib/active_agent/providers/anthropic/requests/messages/assistant.rb +0 -23
  58. data/lib/active_agent/providers/anthropic/requests/messages/base.rb +0 -63
  59. data/lib/active_agent/providers/anthropic/requests/messages/content/_types.rb +0 -143
  60. data/lib/active_agent/providers/anthropic/requests/messages/content/base.rb +0 -21
  61. data/lib/active_agent/providers/anthropic/requests/messages/content/document.rb +0 -26
  62. data/lib/active_agent/providers/anthropic/requests/messages/content/image.rb +0 -23
  63. data/lib/active_agent/providers/anthropic/requests/messages/content/redacted_thinking.rb +0 -21
  64. data/lib/active_agent/providers/anthropic/requests/messages/content/search_result.rb +0 -27
  65. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/_types.rb +0 -171
  66. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/base.rb +0 -22
  67. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_base64.rb +0 -25
  68. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_file.rb +0 -23
  69. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_text.rb +0 -25
  70. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_url.rb +0 -23
  71. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/image_base64.rb +0 -27
  72. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/image_file.rb +0 -23
  73. data/lib/active_agent/providers/anthropic/requests/messages/content/sources/image_url.rb +0 -23
  74. data/lib/active_agent/providers/anthropic/requests/messages/content/text.rb +0 -22
  75. data/lib/active_agent/providers/anthropic/requests/messages/content/thinking.rb +0 -23
  76. data/lib/active_agent/providers/anthropic/requests/messages/content/tool_result.rb +0 -24
  77. data/lib/active_agent/providers/anthropic/requests/messages/content/tool_use.rb +0 -28
  78. data/lib/active_agent/providers/anthropic/requests/messages/user.rb +0 -21
  79. data/lib/active_agent/providers/anthropic/requests/metadata.rb +0 -18
  80. data/lib/active_agent/providers/anthropic/requests/response_format.rb +0 -22
  81. data/lib/active_agent/providers/anthropic/requests/thinking_config/_types.rb +0 -60
  82. data/lib/active_agent/providers/anthropic/requests/thinking_config/base.rb +0 -20
  83. data/lib/active_agent/providers/anthropic/requests/thinking_config/disabled.rb +0 -16
  84. data/lib/active_agent/providers/anthropic/requests/thinking_config/enabled.rb +0 -20
  85. data/lib/active_agent/providers/anthropic/requests/tool_choice/_types.rb +0 -78
  86. data/lib/active_agent/providers/anthropic/requests/tool_choice/any.rb +0 -17
  87. data/lib/active_agent/providers/anthropic/requests/tool_choice/auto.rb +0 -17
  88. data/lib/active_agent/providers/anthropic/requests/tool_choice/base.rb +0 -20
  89. data/lib/active_agent/providers/anthropic/requests/tool_choice/none.rb +0 -16
  90. data/lib/active_agent/providers/anthropic/requests/tool_choice/tool.rb +0 -20
  91. data/lib/active_agent/providers/ollama/chat/requests/_types.rb +0 -3
  92. data/lib/active_agent/providers/ollama/chat/requests/messages/_types.rb +0 -116
  93. data/lib/active_agent/providers/ollama/chat/requests/messages/assistant.rb +0 -19
  94. data/lib/active_agent/providers/ollama/chat/requests/messages/user.rb +0 -19
  95. data/lib/active_agent/providers/ollama/embedding/requests/_types.rb +0 -83
  96. data/lib/active_agent/providers/ollama/embedding/requests/options.rb +0 -104
  97. data/lib/active_agent/providers/open_ai/chat/requests/_types.rb +0 -229
  98. data/lib/active_agent/providers/open_ai/chat/requests/audio.rb +0 -24
  99. data/lib/active_agent/providers/open_ai/chat/requests/messages/_types.rb +0 -123
  100. data/lib/active_agent/providers/open_ai/chat/requests/messages/assistant.rb +0 -42
  101. data/lib/active_agent/providers/open_ai/chat/requests/messages/base.rb +0 -78
  102. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/_types.rb +0 -133
  103. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/audio.rb +0 -35
  104. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/base.rb +0 -24
  105. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/file.rb +0 -26
  106. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/files/_types.rb +0 -60
  107. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/files/details.rb +0 -41
  108. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/image.rb +0 -37
  109. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/refusal.rb +0 -25
  110. data/lib/active_agent/providers/open_ai/chat/requests/messages/content/text.rb +0 -25
  111. data/lib/active_agent/providers/open_ai/chat/requests/messages/developer.rb +0 -25
  112. data/lib/active_agent/providers/open_ai/chat/requests/messages/function.rb +0 -25
  113. data/lib/active_agent/providers/open_ai/chat/requests/messages/system.rb +0 -25
  114. data/lib/active_agent/providers/open_ai/chat/requests/messages/tool.rb +0 -26
  115. data/lib/active_agent/providers/open_ai/chat/requests/messages/user.rb +0 -32
  116. data/lib/active_agent/providers/open_ai/chat/requests/prediction.rb +0 -46
  117. data/lib/active_agent/providers/open_ai/chat/requests/response_format.rb +0 -53
  118. data/lib/active_agent/providers/open_ai/chat/requests/stream_options.rb +0 -24
  119. data/lib/active_agent/providers/open_ai/chat/requests/tool_choice.rb +0 -26
  120. data/lib/active_agent/providers/open_ai/chat/requests/tools/_types.rb +0 -5
  121. data/lib/active_agent/providers/open_ai/chat/requests/tools/base.rb +0 -22
  122. data/lib/active_agent/providers/open_ai/chat/requests/tools/custom_tool.rb +0 -41
  123. data/lib/active_agent/providers/open_ai/chat/requests/tools/function_tool.rb +0 -51
  124. data/lib/active_agent/providers/open_ai/chat/requests/web_search_options.rb +0 -45
  125. data/lib/active_agent/providers/open_ai/embedding/requests/_types.rb +0 -49
  126. data/lib/active_agent/providers/open_ai/responses/requests/_types.rb +0 -231
  127. data/lib/active_agent/providers/open_ai/responses/requests/conversation.rb +0 -23
  128. data/lib/active_agent/providers/open_ai/responses/requests/inputs/_types.rb +0 -264
  129. data/lib/active_agent/providers/open_ai/responses/requests/inputs/assistant_message.rb +0 -22
  130. data/lib/active_agent/providers/open_ai/responses/requests/inputs/base.rb +0 -89
  131. data/lib/active_agent/providers/open_ai/responses/requests/inputs/code_interpreter_tool_call.rb +0 -30
  132. data/lib/active_agent/providers/open_ai/responses/requests/inputs/computer_tool_call.rb +0 -28
  133. data/lib/active_agent/providers/open_ai/responses/requests/inputs/computer_tool_call_output.rb +0 -33
  134. data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/_types.rb +0 -207
  135. data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/base.rb +0 -22
  136. data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_audio.rb +0 -26
  137. data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_file.rb +0 -28
  138. data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_image.rb +0 -28
  139. data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_text.rb +0 -25
  140. data/lib/active_agent/providers/open_ai/responses/requests/inputs/custom_tool_call.rb +0 -28
  141. data/lib/active_agent/providers/open_ai/responses/requests/inputs/custom_tool_call_output.rb +0 -27
  142. data/lib/active_agent/providers/open_ai/responses/requests/inputs/developer_message.rb +0 -20
  143. data/lib/active_agent/providers/open_ai/responses/requests/inputs/file_search_tool_call.rb +0 -25
  144. data/lib/active_agent/providers/open_ai/responses/requests/inputs/function_call_output.rb +0 -32
  145. data/lib/active_agent/providers/open_ai/responses/requests/inputs/function_tool_call.rb +0 -28
  146. data/lib/active_agent/providers/open_ai/responses/requests/inputs/image_gen_tool_call.rb +0 -27
  147. data/lib/active_agent/providers/open_ai/responses/requests/inputs/input_message.rb +0 -31
  148. data/lib/active_agent/providers/open_ai/responses/requests/inputs/item_reference.rb +0 -23
  149. data/lib/active_agent/providers/open_ai/responses/requests/inputs/local_shell_tool_call.rb +0 -26
  150. data/lib/active_agent/providers/open_ai/responses/requests/inputs/local_shell_tool_call_output.rb +0 -33
  151. data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_approval_request.rb +0 -30
  152. data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_approval_response.rb +0 -28
  153. data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_list_tools.rb +0 -29
  154. data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_tool_call.rb +0 -35
  155. data/lib/active_agent/providers/open_ai/responses/requests/inputs/output_message.rb +0 -35
  156. data/lib/active_agent/providers/open_ai/responses/requests/inputs/reasoning.rb +0 -33
  157. data/lib/active_agent/providers/open_ai/responses/requests/inputs/system_message.rb +0 -20
  158. data/lib/active_agent/providers/open_ai/responses/requests/inputs/tool_call_base.rb +0 -27
  159. data/lib/active_agent/providers/open_ai/responses/requests/inputs/tool_message.rb +0 -23
  160. data/lib/active_agent/providers/open_ai/responses/requests/inputs/user_message.rb +0 -20
  161. data/lib/active_agent/providers/open_ai/responses/requests/inputs/web_search_tool_call.rb +0 -24
  162. data/lib/active_agent/providers/open_ai/responses/requests/prompt_reference.rb +0 -23
  163. data/lib/active_agent/providers/open_ai/responses/requests/reasoning.rb +0 -23
  164. data/lib/active_agent/providers/open_ai/responses/requests/stream_options.rb +0 -20
  165. data/lib/active_agent/providers/open_ai/responses/requests/text/_types.rb +0 -89
  166. data/lib/active_agent/providers/open_ai/responses/requests/text/base.rb +0 -22
  167. data/lib/active_agent/providers/open_ai/responses/requests/text/json_object.rb +0 -20
  168. data/lib/active_agent/providers/open_ai/responses/requests/text/json_schema.rb +0 -48
  169. data/lib/active_agent/providers/open_ai/responses/requests/text/plain.rb +0 -20
  170. data/lib/active_agent/providers/open_ai/responses/requests/text.rb +0 -41
  171. data/lib/active_agent/providers/open_ai/responses/requests/tool_choice.rb +0 -26
  172. data/lib/active_agent/providers/open_ai/responses/requests/tools/_types.rb +0 -112
  173. data/lib/active_agent/providers/open_ai/responses/requests/tools/base.rb +0 -25
  174. data/lib/active_agent/providers/open_ai/responses/requests/tools/code_interpreter_tool.rb +0 -23
  175. data/lib/active_agent/providers/open_ai/responses/requests/tools/computer_tool.rb +0 -27
  176. data/lib/active_agent/providers/open_ai/responses/requests/tools/custom_tool.rb +0 -28
  177. data/lib/active_agent/providers/open_ai/responses/requests/tools/file_search_tool.rb +0 -27
  178. data/lib/active_agent/providers/open_ai/responses/requests/tools/function_tool.rb +0 -29
  179. data/lib/active_agent/providers/open_ai/responses/requests/tools/image_generation_tool.rb +0 -37
  180. data/lib/active_agent/providers/open_ai/responses/requests/tools/local_shell_tool.rb +0 -21
  181. data/lib/active_agent/providers/open_ai/responses/requests/tools/mcp_tool.rb +0 -41
  182. data/lib/active_agent/providers/open_ai/responses/requests/tools/web_search_preview_tool.rb +0 -24
  183. data/lib/active_agent/providers/open_ai/responses/requests/tools/web_search_tool.rb +0 -25
  184. data/lib/active_agent/providers/open_ai/schema.yml +0 -65937
  185. data/lib/active_agent/providers/open_router/requests/message.rb +0 -1
  186. data/lib/active_agent/providers/open_router/requests/messages/assistant.rb +0 -20
  187. data/lib/active_agent/providers/open_router/requests/messages/user.rb +0 -30
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
- require_relative "files/_types"
5
-
6
- module ActiveAgent
7
- module Providers
8
- module OpenAI
9
- module Chat
10
- module Requests
11
- module Messages
12
- module Content
13
- # File content part
14
- class File < Base
15
- attribute :type, :string, as: "file"
16
- attribute :file, Files::DetailsType.new
17
-
18
- validates :file, presence: true
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "details"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- module Messages
11
- module Content
12
- module Files
13
- # Type for the nested file object
14
- class DetailsType < ActiveModel::Type::Value
15
- def cast(value)
16
- case value
17
- when Details
18
- value
19
- when Hash
20
- Details.new(**value.deep_symbolize_keys)
21
- when String
22
- if value.start_with?("data:")
23
- Details.new(file_data: value)
24
- elsif value.match?(%r{\Ahttps?://})
25
- raise ArgumentError, "HTTP/S URLs are not supported. Use a base64 data instead"
26
- else
27
- Details.new(file_data: value)
28
- end
29
- when nil
30
- nil
31
- else
32
- raise ArgumentError, "Cannot cast #{value.class} to File::Details"
33
- end
34
- end
35
-
36
- def serialize(value)
37
- case value
38
- when Details
39
- value.serialize
40
- when Hash
41
- value
42
- when nil
43
- nil
44
- else
45
- raise ArgumentError, "Cannot serialize #{value.class}"
46
- end
47
- end
48
-
49
- def deserialize(value)
50
- cast(value)
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
58
- end
59
- end
60
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_agent/providers/common/model"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- module Messages
11
- module Content
12
- module Files
13
- # Represents the nested file object within File content part
14
- class Details < Common::BaseModel
15
- # The base64 encoded file data, used when passing the file to the model as a string
16
- attribute :file_data, :string
17
-
18
- # The ID of an uploaded file to use as input
19
- attribute :file_id, :string
20
-
21
- # The name of the file, used when passing the file to the model as a string
22
- attribute :filename, :string
23
-
24
- # Override serialize to strip data URI prefix from file_data
25
- def file_data=(value)
26
- # Strip data URI prefix from file_data if present
27
- if value&.match?(/\Adata:[^;]+;base64,/)
28
- value = value.sub(/\Adata:[^;]+;base64,/, "")
29
- end
30
-
31
- super(value)
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- module Messages
11
- module Content
12
- # Image content part
13
- class Image < Base
14
- attribute :type, :string, as: "image_url"
15
- attribute :image_url, default: -> { {} }
16
-
17
- validates :image_url, presence: true
18
-
19
- # Nested image_url object
20
- def image_url=(value)
21
- case value
22
- when Hash
23
- super(value.symbolize_keys)
24
- when String
25
- super({ url: value })
26
- else
27
- super(value)
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- module Messages
11
- module Content
12
- # Refusal content part (used in assistant messages)
13
- class Refusal < Base
14
- attribute :type, :string, as: "refusal"
15
- attribute :refusal, :string
16
-
17
- validates :refusal, presence: true
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- module Messages
11
- module Content
12
- # Text content part
13
- class Text < Base
14
- attribute :type, :string, as: "text"
15
- attribute :text, :string
16
-
17
- validates :text, presence: true
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
- require_relative "content/_types"
5
-
6
- module ActiveAgent
7
- module Providers
8
- module OpenAI
9
- module Chat
10
- module Requests
11
- module Messages
12
- # Developer message - instructions that the model should follow (o1 models and newer)
13
- class Developer < Base
14
- attribute :role, :string, as: "developer"
15
- attribute :content, Content::ContentsType.new # String or array of content parts
16
- attribute :name, :string # Optional name for the participant
17
-
18
- validates :content, presence: true
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- module Messages
11
- # Function message - result from a function call (deprecated)
12
- class Function < Base
13
- attribute :role, :string, as: "function"
14
- attribute :content, :string # Result of the function call
15
- attribute :name, :string # Name of the function that was called
16
-
17
- validates :content, presence: true
18
- validates :name, presence: true
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
- require_relative "content/_types"
5
-
6
- module ActiveAgent
7
- module Providers
8
- module OpenAI
9
- module Chat
10
- module Requests
11
- module Messages
12
- # System message - instructions that the model should follow (older models)
13
- class System < Base
14
- attribute :role, :string, as: "system"
15
- attribute :content, Content::ContentsType.new # String or array of content parts
16
- attribute :name, :string # Optional name for the participant
17
-
18
- validates :content, presence: true
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
- require_relative "content/_types"
5
-
6
- module ActiveAgent
7
- module Providers
8
- module OpenAI
9
- module Chat
10
- module Requests
11
- module Messages
12
- # Tool message - result from a tool call
13
- class Tool < Base
14
- attribute :role, :string, as: "tool"
15
- attribute :content, Content::ContentsType.new # String or array of content parts
16
- attribute :tool_call_id, :string # ID of the tool call this is a response to
17
-
18
- validates :content, presence: true
19
- validates :tool_call_id, presence: true
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
- require_relative "content/_types"
5
-
6
- module ActiveAgent
7
- module Providers
8
- module OpenAI
9
- module Chat
10
- module Requests
11
- module Messages
12
- # User message - messages sent by an end user
13
- class User < Base
14
- attribute :role, :string, as: "user"
15
- attribute :content, Content::ContentsType.new # String or array of content parts
16
- attribute :name, :string # Optional name for the participant
17
-
18
- validates :content, presence: true
19
-
20
- %i[text image document].each do |content_type|
21
- define_method(:"#{content_type}=") do |value|
22
- self.content ||= []
23
- self.content += [ { content_type => value } ]
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_agent/providers/common/model"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- class Prediction < Common::BaseModel
11
- # Type of predicted content (always "content")
12
- attribute :type, :string, default: "content"
13
-
14
- # Content that should be matched (string or array of content parts)
15
- attribute :content
16
-
17
- validates :type, inclusion: { in: %w[content] }, allow_nil: true
18
-
19
- # Validate content is present and in correct format
20
- validate :validate_content_format
21
-
22
- private
23
-
24
- def validate_content_format
25
- if content.blank?
26
- errors.add(:content, "must be present")
27
- return
28
- end
29
-
30
- # Content can be a string or an array of content parts
31
- if content.is_a?(Array)
32
- content.each do |part|
33
- unless part.is_a?(Hash) && part[:type].present?
34
- errors.add(:content, "array elements must be hashes with a 'type' field")
35
- end
36
- end
37
- elsif !content.is_a?(String)
38
- errors.add(:content, "must be a string or array of content parts")
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_agent/providers/common/model"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- class ResponseFormat < Common::BaseModel
11
- # Type of response format (text, json_schema, json_object)
12
- attribute :type, :string
13
-
14
- # JSON schema configuration (only for json_schema type)
15
- attribute :json_schema # Hash with name, description, schema, strict
16
-
17
- validates :type, inclusion: { in: %w[text json_schema json_object] }, allow_nil: true
18
-
19
- # Validate that json_schema is present when type is json_schema
20
- validate :validate_json_schema_presence
21
-
22
- private
23
-
24
- def validate_json_schema_presence
25
- if type == "json_schema" && json_schema.blank?
26
- errors.add(:json_schema, "must be present when type is 'json_schema'")
27
- end
28
-
29
- if json_schema.present? && json_schema.is_a?(Hash)
30
- validate_json_schema_structure
31
- end
32
- end
33
-
34
- def validate_json_schema_structure
35
- unless json_schema[:name].present?
36
- errors.add(:json_schema, "must include 'name' field")
37
- end
38
-
39
- if json_schema[:name].present? && json_schema[:name].length > 64
40
- errors.add(:json_schema, "name must be 64 characters or less")
41
- end
42
-
43
- # Name must match pattern: a-z, A-Z, 0-9, underscores and dashes
44
- if json_schema[:name].present? && json_schema[:name] !~ /^[a-zA-Z0-9_-]+$/
45
- errors.add(:json_schema, "name must contain only a-z, A-Z, 0-9, underscores and dashes")
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end
53
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_agent/providers/common/model"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- class StreamOptions < Common::BaseModel
11
- # Include usage information in the stream
12
- attribute :include_usage, :boolean
13
-
14
- # Include obfuscation in the stream
15
- attribute :include_obfuscation, :boolean
16
-
17
- validates :include_usage, inclusion: { in: [ true, false ] }, allow_nil: true
18
- validates :include_obfuscation, inclusion: { in: [ true, false ] }, allow_nil: true
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_agent/providers/common/model"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- # Tool choice configuration
11
- class ToolChoice < Common::BaseModel
12
- # Can be string ("none", "auto", "required") or object
13
- attribute :mode, :string
14
- attribute :type, :string
15
- attribute :function # Hash with name
16
- attribute :custom # Hash with name
17
- attribute :allowed_tools # Hash with mode and tools array
18
-
19
- validates :mode, inclusion: { in: %w[none auto required] }, allow_nil: true
20
- validates :type, inclusion: { in: %w[function custom allowed_tools] }, allow_nil: true
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
- require_relative "custom_tool"
5
- require_relative "function_tool"
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_agent/providers/common/model"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- module Tools
11
- # Base class for tools
12
- class Base < Common::BaseModel
13
- attribute :type, :string
14
-
15
- validates :type, inclusion: { in: %w[function custom] }
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- module Tools
11
- # Custom tool
12
- class CustomTool < Base
13
- attribute :type, :string, as: "custom"
14
- attribute :custom # Hash with name, description, format
15
-
16
- validate :validate_custom_structure
17
-
18
- private
19
-
20
- def validate_custom_structure
21
- if custom.blank?
22
- errors.add(:custom, "must be present")
23
- return
24
- end
25
-
26
- unless custom.is_a?(Hash)
27
- errors.add(:custom, "must be a hash")
28
- return
29
- end
30
-
31
- unless custom[:name].present?
32
- errors.add(:custom, "must include 'name' field")
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- module Tools
11
- # Function tool
12
- class FunctionTool < Base
13
- attribute :type, :string, as: "function"
14
- attribute :function # Hash with name, description, parameters, strict
15
-
16
- validate :validate_function_structure
17
-
18
- private
19
-
20
- def validate_function_structure
21
- if function.blank?
22
- errors.add(:function, "must be present")
23
- return
24
- end
25
-
26
- unless function.is_a?(Hash)
27
- errors.add(:function, "must be a hash")
28
- return
29
- end
30
-
31
- unless function[:name].present?
32
- errors.add(:function, "must include 'name' field")
33
- end
34
-
35
- if function[:name].present?
36
- if function[:name].length > 64
37
- errors.add(:function, "name must be 64 characters or less")
38
- end
39
-
40
- unless function[:name] =~ /^[a-zA-Z0-9_-]+$/
41
- errors.add(:function, "name must contain only a-z, A-Z, 0-9, underscores and dashes")
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_agent/providers/common/model"
4
-
5
- module ActiveAgent
6
- module Providers
7
- module OpenAI
8
- module Chat
9
- module Requests
10
- class WebSearchOptions < Common::BaseModel
11
- # Search context size (low, medium, high)
12
- attribute :search_context_size, :string
13
-
14
- # User location for search
15
- attribute :user_location # Hash with type and approximate
16
-
17
- validates :search_context_size, inclusion: { in: %w[low medium high] }, allow_nil: true
18
-
19
- # Validate user_location format
20
- validate :validate_user_location_format
21
-
22
- private
23
-
24
- def validate_user_location_format
25
- return if user_location.nil?
26
-
27
- unless user_location.is_a?(Hash)
28
- errors.add(:user_location, "must be a hash")
29
- return
30
- end
31
-
32
- unless user_location[:type] == "approximate"
33
- errors.add(:user_location, "type must be 'approximate'")
34
- end
35
-
36
- unless user_location[:approximate].is_a?(Hash)
37
- errors.add(:user_location, "must include 'approximate' hash")
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end