apologist 1.2.1 → 1.3.1

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/.fern/metadata.json +2 -2
  3. data/.fern/replay.lock +48 -1
  4. data/README.md +1 -3
  5. data/lib/Apologist/benchmarks/client.rb +2 -1
  6. data/lib/Apologist/benchmarks/types/benchmark_run_request_content.rb +1 -1
  7. data/lib/Apologist/benchmarks/types/benchmark_run_request_content_one_item.rb +15 -0
  8. data/lib/Apologist/channels/client.rb +41 -14
  9. data/lib/Apologist/channels/types/chatwoot_webhook_payload.rb +35 -0
  10. data/lib/Apologist/channels/types/chatwoot_webhook_payload_account.rb +11 -0
  11. data/lib/Apologist/channels/types/chatwoot_webhook_payload_conversation.rb +18 -0
  12. data/lib/Apologist/channels/types/chatwoot_webhook_payload_conversation_account.rb +11 -0
  13. data/lib/Apologist/channels/types/chatwoot_webhook_payload_sender.rb +16 -0
  14. data/lib/Apologist/chat/client.rb +103 -6
  15. data/lib/Apologist/chat/types/anonymize_completion_request.rb +11 -0
  16. data/lib/Apologist/chat/types/anonymize_completion_response.rb +11 -0
  17. data/lib/Apologist/chat/types/chat_completion_request.rb +75 -0
  18. data/lib/Apologist/chat/types/chat_completion_request_logprobs.rb +15 -0
  19. data/lib/Apologist/chat/types/chat_completion_request_metadata.rb +33 -0
  20. data/lib/Apologist/chat/types/chat_completion_request_reasoning_effort.rb +15 -0
  21. data/lib/Apologist/chat/types/chat_completion_request_response_format.rb +13 -0
  22. data/lib/Apologist/chat/types/chat_completion_request_response_format_json_schema.rb +19 -0
  23. data/lib/Apologist/chat/types/chat_completion_request_response_format_type.rb +17 -0
  24. data/lib/Apologist/chat/types/chat_completion_request_tool_choice.rb +15 -0
  25. data/lib/Apologist/chat/types/chat_completion_request_tool_choice_zero.rb +15 -0
  26. data/lib/Apologist/chat/types/chat_completion_request_verbosity.rb +16 -0
  27. data/lib/Apologist/chat/types/list_chat_completions_request.rb +6 -0
  28. data/lib/Apologist/chat/types/scrub_completion_request.rb +11 -0
  29. data/lib/Apologist/chat/types/scrub_completion_response.rb +11 -0
  30. data/lib/Apologist/client.rb +1 -1
  31. data/lib/Apologist/ct_as/client.rb +3 -5
  32. data/lib/Apologist/ct_as/types/cta_match_request.rb +27 -0
  33. data/lib/Apologist/evaluators/types/evaluator_request_content.rb +2 -1
  34. data/lib/Apologist/evaluators/types/evaluator_request_content_one_item.rb +15 -0
  35. data/lib/Apologist/types/chatwoot_conversation_meta.rb +11 -0
  36. data/lib/Apologist/types/chatwoot_conversation_meta_sender.rb +11 -0
  37. data/lib/Apologist/types/completion_redact_response.rb +16 -0
  38. data/lib/Apologist/types/{chat_completion_request_reasoning_effort.rb → completion_redact_response_mode.rb} +3 -4
  39. data/lib/Apologist/types/user_flag.rb +2 -0
  40. data/lib/Apologist/types/webhook_evaluation.rb +1 -1
  41. data/lib/Apologist/types/webhook_event_info_key.rb +1 -0
  42. data/lib/Apologist/types/webhook_payload.rb +6 -2
  43. data/lib/Apologist/types/webhook_payload_trace.rb +13 -0
  44. data/lib/Apologist/version.rb +1 -1
  45. data/lib/Apologist.rb +29 -14
  46. data/reference.md +586 -24
  47. metadata +29 -14
  48. data/lib/Apologist/channels/types/receive_chatwoot_webhook_request.rb +0 -17
  49. data/lib/Apologist/types/chat_completion_request.rb +0 -11
  50. data/lib/Apologist/types/chat_completion_request_logprobs.rb +0 -13
  51. data/lib/Apologist/types/chat_completion_request_metadata.rb +0 -31
  52. data/lib/Apologist/types/chat_completion_request_response_format.rb +0 -11
  53. data/lib/Apologist/types/chat_completion_request_response_format_json_schema.rb +0 -17
  54. data/lib/Apologist/types/chat_completion_request_response_format_type.rb +0 -15
  55. data/lib/Apologist/types/chat_completion_request_tool_choice.rb +0 -13
  56. data/lib/Apologist/types/chat_completion_request_tool_choice_zero.rb +0 -13
  57. data/lib/Apologist/types/chat_completion_request_verbosity.rb +0 -14
  58. data/lib/Apologist/types/cta_match_request.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 175685e51865fc14342e47a473e42329ffc5299500247a844cc8e7269ffcd1e0
4
- data.tar.gz: 5e227474cc2f01cf206b85fbfdd9a52b7f8b81ece6f0ebe282e35db49f899c97
3
+ metadata.gz: b8b35bf0de9553ecf5f3863ad050defcb16905a2c92c92168a0cbd1b3606ce54
4
+ data.tar.gz: 15551174479fe50af048668359c683598acbd87b20b057644387ef2a533055a8
5
5
  SHA512:
6
- metadata.gz: 1fcc758726ab2c0c52430cd5cb853e650845624fe195c32d377d8a4487d271c64f936835ab00e552873dc6f186972fa9c13c7c834f9e68c095c2578f25d44fe7
7
- data.tar.gz: '0648f4ed132d31840f9a5eb5fedcf61c933108bf71e9dafc00434a1d7f7d5e09a4c12aafcf5e338007b6499ec9b772dd05a3fb167cd1f83877bc09d4952d51fa'
6
+ metadata.gz: 01f32e355d1c00e28e9b6282ecd7178946a3590930c933ac17578697e7788b887c2ced00c66321f49e33b00524ce1d5ac2f1ab3e38db2bc13a98a63f03fafd8d
7
+ data.tar.gz: 50c1e0f1c8668fb62c381baf9abbb5ae319df4ef6547268f66d1a6e9f5c9b43206d82e0aadb6b071d273474dfc7e249a7a3753d89f236368f500996abd8659f1
data/.fern/metadata.json CHANGED
@@ -6,9 +6,9 @@
6
6
  "moduleName": "Apologist",
7
7
  "clientModuleName": "AgentClient"
8
8
  },
9
- "originGitCommit": "4af5bf08f559e976f40a4e68bcf7cb0e46fec955",
9
+ "originGitCommit": "aa8fb4b4d05d7116588d03dfe64ebe361e8ba59b",
10
10
  "originGitCommitIsDirty": false,
11
11
  "invokedBy": "ci",
12
12
  "ciProvider": "github",
13
- "sdkVersion": "1.2.1"
13
+ "sdkVersion": "1.3.1"
14
14
  }
data/.fern/replay.lock CHANGED
@@ -24,7 +24,13 @@ generations:
24
24
  cli_version: unknown
25
25
  generator_versions:
26
26
  fernapi/fern-ruby-sdk: 1.20.2
27
- current_generation: 9f892528827622170ef9dbf8ae8bd2af9b36ab49
27
+ - commit_sha: 7d05601bdc8364b2c806f2430d711872f9998785
28
+ tree_hash: 52b7e8fc3358219c2c094920c3c14d346089bc4d
29
+ timestamp: 2026-09-02T05:19:15.396Z
30
+ cli_version: unknown
31
+ generator_versions:
32
+ fernapi/fern-ruby-sdk: 1.20.2
33
+ current_generation: 7d05601bdc8364b2c806f2430d711872f9998785
28
34
  patches:
29
35
  - id: patch-b2534827
30
36
  content_hash: sha256:c0e690c52123f547bfb10b269e15cdf8fc30efc06f659245a89b685ad5f01e00
@@ -107,3 +113,44 @@ patches:
107
113
  VERSION = "1.1.0"
108
114
  end
109
115
  status: unresolved
116
+ - id: patch-2afb3d61
117
+ content_hash: sha256:bf60971fdebd9e1e58cef417a761dad3a542dbda181e544a9f55b65463c8b2fa
118
+ original_commit: 2afb3d61ed0a4036a725ca29901a58d546ff2d89
119
+ original_message: Release 1.2.0.
120
+ original_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
121
+ base_generation: 9b9deb35199497354dd4ebe77eaa3d2dd758a68e
122
+ files:
123
+ - lib/Apologist/version.rb
124
+ patch_content: |+
125
+ From 2afb3d61ed0a4036a725ca29901a58d546ff2d89 Mon Sep 17 00:00:00 2001
126
+ From: "github-actions[bot]"
127
+ <41898282+github-actions[bot]@users.noreply.github.com>
128
+ Date: Sun, 16 Aug 2026 19:28:11 +0000
129
+ Subject: [PATCH] Release 1.2.0.
130
+
131
+ ---
132
+ lib/Apologist/version.rb | 2 +-
133
+ 1 file changed, 1 insertion(+), 1 deletion(-)
134
+
135
+ diff --git a/lib/Apologist/version.rb b/lib/Apologist/version.rb
136
+ index f86c00b..cb12f87 100644
137
+ --- a/lib/Apologist/version.rb
138
+ +++ b/lib/Apologist/version.rb
139
+ @@ -1,5 +1,5 @@
140
+ # frozen_string_literal: true
141
+
142
+ module Apologist
143
+ - VERSION = "1.1.1"
144
+ + VERSION = "1.2.0"
145
+ end
146
+ --
147
+ 2.52.0
148
+
149
+ theirs_snapshot:
150
+ lib/Apologist/version.rb: |
151
+ # frozen_string_literal: true
152
+
153
+ module Apologist
154
+ VERSION = "1.2.0"
155
+ end
156
+ status: unresolved
data/README.md CHANGED
@@ -30,9 +30,7 @@ require "apologist"
30
30
 
31
31
  client = Apologist::AgentClient.new(api_key: "<value>")
32
32
 
33
- client.chat.create_chat_completion(request: {
34
- key: "value"
35
- })
33
+ client.chat.create_chat_completion(traceparent: "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
36
34
  ```
37
35
 
38
36
  ## Environments
@@ -74,7 +74,8 @@ module Apologist
74
74
  end
75
75
 
76
76
  # Executes a benchmark run and returns the aggregated result with nested evaluators, questions, and a flat
77
- # evaluations array.
77
+ # evaluations array. A run that cannot finish inside one request returns 202 with `completed_at` null and
78
+ # continues in the background. Poll Get a benchmark run until `completed_at` is set.
78
79
  #
79
80
  # @param request_options [Hash]
80
81
  # @param params [Apologist::Benchmarks::Types::BenchmarkRunRequest]
@@ -9,7 +9,7 @@ module Apologist
9
9
 
10
10
  member -> { String }
11
11
 
12
- member -> { Internal::Types::Array[Object] }
12
+ member -> { Internal::Types::Array[Apologist::Benchmarks::Types::BenchmarkRunRequestContentOneItem] }
13
13
  end
14
14
  end
15
15
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Benchmarks
5
+ module Types
6
+ class BenchmarkRunRequestContentOneItem < Internal::Types::Model
7
+ extend Apologist::Internal::Types::Union
8
+
9
+ member -> { String }
10
+
11
+ member -> { Apologist::Types::ChatMessage }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -54,29 +54,56 @@ module Apologist
54
54
  # times out in about 5 seconds) and processes events asynchronously.
55
55
  #
56
56
  # @param request_options [Hash]
57
- # @param params [Hash]
57
+ # @param params [Apologist::Channels::Types::ChatwootWebhookPayload]
58
58
  # @option request_options [String] :base_url
59
59
  # @option request_options [Hash{String => Object}] :additional_headers
60
60
  # @option request_options [Hash{String => Object}] :additional_query_parameters
61
61
  # @option request_options [Hash{String => Object}] :additional_body_parameters
62
62
  # @option request_options [Integer] :timeout_in_seconds
63
- # @option params [String] :id
63
+ # @option params [String] :channel_id
64
64
  # @option params [String, nil] :chatwoot_signature
65
65
  # @option params [String, nil] :chatwoot_timestamp
66
66
  #
67
67
  # @example
68
68
  # client.channels.receive_chatwoot_webhook(
69
- # id: "id",
70
- # body: {
71
- # key: "value"
69
+ # channel_id: "91",
70
+ # chatwoot_signature: "sha256=2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
71
+ # chatwoot_timestamp: "1710000000",
72
+ # event: "message_created",
73
+ # id: 9001,
74
+ # content: "Hello from Messenger",
75
+ # message_type: "incoming",
76
+ # private: false,
77
+ # account: {
78
+ # id: 7
79
+ # },
80
+ # sender: {
81
+ # id: 55,
82
+ # name: "Pat",
83
+ # type: "contact"
84
+ # },
85
+ # conversation: {
86
+ # id: 42,
87
+ # status: "pending",
88
+ # account: {
89
+ # id: 7
90
+ # },
91
+ # meta: {
92
+ # assignee_type: "AgentBot",
93
+ # sender: {
94
+ # id: 55,
95
+ # name: "Pat"
96
+ # }
97
+ # }
72
98
  # }
73
99
  # )
74
100
  #
75
101
  # @return [untyped]
76
102
  def receive_chatwoot_webhook(request_options: {}, **params)
77
103
  params = Apologist::Internal::Types::Utils.normalize_keys(params)
78
- path_param_names = %i[id]
79
- body_params = params.except(*path_param_names)
104
+ request_data = Apologist::Channels::Types::ChatwootWebhookPayload.new(params).to_h
105
+ non_body_param_names = %w[channelId X-Chatwoot-Signature X-Chatwoot-Timestamp]
106
+ body = request_data.except(*non_body_param_names)
80
107
 
81
108
  headers = {}
82
109
  headers["X-Chatwoot-Signature"] = params[:chatwoot_signature] if params[:chatwoot_signature]
@@ -85,9 +112,9 @@ module Apologist
85
112
  request = Apologist::Internal::JSON::Request.new(
86
113
  base_url: request_options[:base_url],
87
114
  method: "POST",
88
- path: "channels/#{URI.encode_uri_component(params[:id].to_s)}/chatwoot",
115
+ path: "channels/#{URI.encode_uri_component(params[:channel_id].to_s)}/chatwoot",
89
116
  headers: headers,
90
- body: body_params,
117
+ body: body,
91
118
  request_options: request_options
92
119
  )
93
120
  begin
@@ -495,8 +522,8 @@ module Apologist
495
522
  raise error_class.new(response.body, code: code)
496
523
  end
497
524
 
498
- # Handles the Meta WhatsApp Cloud API webhook verification handshake, echoing `hub.challenge` when
499
- # `hub.verify_token` matches the channel's configured token.
525
+ # Handles the Meta WhatsApp Cloud API webhook verification handshake. Requires an `api_key` query parameter or
526
+ # `x-api-key` header, then echoes `hub.challenge` when `hub.verify_token` matches the channel's configured token.
500
527
  #
501
528
  # @param request_options [Hash]
502
529
  # @param params [Hash]
@@ -544,9 +571,9 @@ module Apologist
544
571
  raise error_class.new(response.body, code: code)
545
572
  end
546
573
 
547
- # Receives WhatsApp Cloud API message events for the channel. Payload shape is defined by Meta. Signature
548
- # verification via `x-hub-signature-256` is used when the channel has an App Secret configured; otherwise the
549
- # webhook relies on URL secrecy and/or an `api_key` query parameter.
574
+ # Receives WhatsApp Cloud API message events for the channel. Payload shape is defined by Meta. An `api_key` query
575
+ # parameter or `x-api-key` header is required. Signature verification via `x-hub-signature-256` is also required
576
+ # when the channel has an App Secret configured.
550
577
  #
551
578
  # @param request_options [Hash]
552
579
  # @param params [Hash]
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ class ChatwootWebhookPayload < Internal::Types::Model
7
+ field :channel_id, -> { String }, optional: false, nullable: false, api_name: "channelId"
8
+
9
+ field :chatwoot_signature, -> { String }, optional: true, nullable: false, api_name: "X-Chatwoot-Signature"
10
+
11
+ field :chatwoot_timestamp, -> { String }, optional: true, nullable: false, api_name: "X-Chatwoot-Timestamp"
12
+
13
+ field :event, -> { String }, optional: true, nullable: false
14
+
15
+ field :id, -> { Integer }, optional: true, nullable: false
16
+
17
+ field :content, -> { String }, optional: true, nullable: false
18
+
19
+ field :message_type, -> { String }, optional: true, nullable: false
20
+
21
+ field :private, -> { Internal::Types::Boolean }, optional: true, nullable: false
22
+
23
+ field :account, -> { Apologist::Channels::Types::ChatwootWebhookPayloadAccount }, optional: true, nullable: false
24
+
25
+ field :sender, -> { Apologist::Channels::Types::ChatwootWebhookPayloadSender }, optional: true, nullable: false
26
+
27
+ field :conversation, -> { Apologist::Channels::Types::ChatwootWebhookPayloadConversation }, optional: true, nullable: false
28
+
29
+ field :status, -> { String }, optional: true, nullable: false
30
+
31
+ field :meta, -> { Apologist::Types::ChatwootConversationMeta }, optional: true, nullable: false
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ class ChatwootWebhookPayloadAccount < Internal::Types::Model
7
+ field :id, -> { Integer }, optional: true, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ # Nested on message events. Conversation events send `id`, `status`, and `meta` at the top level instead.
7
+ class ChatwootWebhookPayloadConversation < Internal::Types::Model
8
+ field :id, -> { Integer }, optional: true, nullable: false
9
+
10
+ field :status, -> { String }, optional: true, nullable: false
11
+
12
+ field :account, -> { Apologist::Channels::Types::ChatwootWebhookPayloadConversationAccount }, optional: true, nullable: false
13
+
14
+ field :meta, -> { Apologist::Types::ChatwootConversationMeta }, optional: true, nullable: false
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ class ChatwootWebhookPayloadConversationAccount < Internal::Types::Model
7
+ field :id, -> { Integer }, optional: true, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ # Present on message events.
7
+ class ChatwootWebhookPayloadSender < Internal::Types::Model
8
+ field :id, -> { Integer }, optional: true, nullable: false
9
+
10
+ field :name, -> { String }, optional: true, nullable: false
11
+
12
+ field :type, -> { String }, optional: true, nullable: false
13
+ end
14
+ end
15
+ end
16
+ end
@@ -38,9 +38,12 @@ module Apologist
38
38
  # @option params [String, nil] :user_id
39
39
  # @option params [String, nil] :min_timestamp
40
40
  # @option params [String, nil] :max_timestamp
41
+ # @option params [String, nil] :traceparent
42
+ # @option params [String, nil] :tracestate
43
+ # @option params [String, nil] :baggage
41
44
  #
42
45
  # @example
43
- # client.chat.list_chat_completions
46
+ # client.chat.list_chat_completions(traceparent: "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
44
47
  #
45
48
  # @return [Apologist::Chat::Types::ListChatCompletionsResponse]
46
49
  def list_chat_completions(request_options: {}, **params)
@@ -65,10 +68,16 @@ module Apologist
65
68
  query_params["min_timestamp"] = params[:min_timestamp] if params.key?(:min_timestamp)
66
69
  query_params["max_timestamp"] = params[:max_timestamp] if params.key?(:max_timestamp)
67
70
 
71
+ headers = {}
72
+ headers["traceparent"] = params[:traceparent] if params[:traceparent]
73
+ headers["tracestate"] = params[:tracestate] if params[:tracestate]
74
+ headers["baggage"] = params[:baggage] if params[:baggage]
75
+
68
76
  request = Apologist::Internal::JSON::Request.new(
69
77
  base_url: request_options[:base_url],
70
78
  method: "GET",
71
79
  path: "chat/completions",
80
+ headers: headers,
72
81
  query: query_params,
73
82
  request_options: request_options
74
83
  )
@@ -90,26 +99,37 @@ module Apologist
90
99
  # responses.
91
100
  #
92
101
  # @param request_options [Hash]
93
- # @param params [Apologist::Types::ChatCompletionRequest]
102
+ # @param params [Apologist::Chat::Types::ChatCompletionRequest]
94
103
  # @option request_options [String] :base_url
95
104
  # @option request_options [Hash{String => Object}] :additional_headers
96
105
  # @option request_options [Hash{String => Object}] :additional_query_parameters
97
106
  # @option request_options [Hash{String => Object}] :additional_body_parameters
98
107
  # @option request_options [Integer] :timeout_in_seconds
108
+ # @option params [String, nil] :traceparent
109
+ # @option params [String, nil] :tracestate
110
+ # @option params [String, nil] :baggage
99
111
  #
100
112
  # @example
101
- # client.chat.create_chat_completion(request: {
102
- # key: "value"
103
- # })
113
+ # client.chat.create_chat_completion(traceparent: "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
104
114
  #
105
115
  # @return [Apologist::Types::ChatCompletionResponse]
106
116
  def create_chat_completion(request_options: {}, **params)
107
117
  params = Apologist::Internal::Types::Utils.normalize_keys(params)
118
+ request_data = Apologist::Chat::Types::ChatCompletionRequest.new(params).to_h
119
+ non_body_param_names = %w[traceparent tracestate baggage]
120
+ body = request_data.except(*non_body_param_names)
121
+
122
+ headers = {}
123
+ headers["traceparent"] = params[:traceparent] if params[:traceparent]
124
+ headers["tracestate"] = params[:tracestate] if params[:tracestate]
125
+ headers["baggage"] = params[:baggage] if params[:baggage]
126
+
108
127
  request = Apologist::Internal::JSON::Request.new(
109
128
  base_url: request_options[:base_url],
110
129
  method: "POST",
111
130
  path: "chat/completions",
112
- body: Apologist::Types::ChatCompletionRequest.new(params).to_h,
131
+ headers: headers,
132
+ body: body,
113
133
  request_options: request_options
114
134
  )
115
135
  begin
@@ -303,6 +323,83 @@ module Apologist
303
323
  end
304
324
  end
305
325
 
326
+ # Replaces this chat completion's message-adjacent text with a placeholder. Conversation rows, identifiers, likes,
327
+ # flags, and analytics identity stay in place. Repeat calls finish leftover rows.
328
+ #
329
+ # @param request_options [Hash]
330
+ # @param params [Hash]
331
+ # @option request_options [String] :base_url
332
+ # @option request_options [Hash{String => Object}] :additional_headers
333
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
334
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
335
+ # @option request_options [Integer] :timeout_in_seconds
336
+ # @option params [String] :id
337
+ #
338
+ # @example
339
+ # client.chat.scrub_completion(id: "id")
340
+ #
341
+ # @return [Apologist::Chat::Types::ScrubCompletionResponse]
342
+ def scrub_completion(request_options: {}, **params)
343
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
344
+ request = Apologist::Internal::JSON::Request.new(
345
+ base_url: request_options[:base_url],
346
+ method: "POST",
347
+ path: "chat/completions/#{URI.encode_uri_component(params[:id].to_s)}/scrub",
348
+ request_options: request_options
349
+ )
350
+ begin
351
+ response = @client.send(request)
352
+ rescue Net::HTTPRequestTimeout
353
+ raise Apologist::Errors::TimeoutError
354
+ end
355
+ code = response.code.to_i
356
+ if code.between?(200, 299)
357
+ Apologist::Chat::Types::ScrubCompletionResponse.load(response.body)
358
+ else
359
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
360
+ raise error_class.new(response.body, code: code)
361
+ end
362
+ end
363
+
364
+ # Redacts detected personal data in this chat completion's message-adjacent text with regex, then an optional
365
+ # hosted redaction service when the Agent has that option on. Conversation rows, identifiers, likes, flags, and
366
+ # analytics identity stay in place. Repeat calls finish leftover rows and skip text that is already redacted.
367
+ #
368
+ # @param request_options [Hash]
369
+ # @param params [Hash]
370
+ # @option request_options [String] :base_url
371
+ # @option request_options [Hash{String => Object}] :additional_headers
372
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
373
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
374
+ # @option request_options [Integer] :timeout_in_seconds
375
+ # @option params [String] :id
376
+ #
377
+ # @example
378
+ # client.chat.anonymize_completion(id: "id")
379
+ #
380
+ # @return [Apologist::Chat::Types::AnonymizeCompletionResponse]
381
+ def anonymize_completion(request_options: {}, **params)
382
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
383
+ request = Apologist::Internal::JSON::Request.new(
384
+ base_url: request_options[:base_url],
385
+ method: "POST",
386
+ path: "chat/completions/#{URI.encode_uri_component(params[:id].to_s)}/anonymize",
387
+ request_options: request_options
388
+ )
389
+ begin
390
+ response = @client.send(request)
391
+ rescue Net::HTTPRequestTimeout
392
+ raise Apologist::Errors::TimeoutError
393
+ end
394
+ code = response.code.to_i
395
+ if code.between?(200, 299)
396
+ Apologist::Chat::Types::AnonymizeCompletionResponse.load(response.body)
397
+ else
398
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
399
+ raise error_class.new(response.body, code: code)
400
+ end
401
+ end
402
+
306
403
  # Returns a single chat completion (prompt) by numeric id or UUID, including applied tags, guardrail/cta metadata,
307
404
  # share metadata, and automation results.
308
405
  #
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Chat
5
+ module Types
6
+ class AnonymizeCompletionRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Chat
5
+ module Types
6
+ class AnonymizeCompletionResponse < Internal::Types::Model
7
+ field :data, -> { Apologist::Types::CompletionRedactResponse }, optional: true, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Chat
5
+ module Types
6
+ class ChatCompletionRequest < Internal::Types::Model
7
+ field :traceparent, -> { String }, optional: true, nullable: false
8
+
9
+ field :tracestate, -> { String }, optional: true, nullable: false
10
+
11
+ field :baggage, -> { String }, optional: true, nullable: false
12
+
13
+ field :audio, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false
14
+
15
+ field :frequency_penalty, -> { Integer }, optional: true, nullable: false
16
+
17
+ field :logit_bias, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false
18
+
19
+ field :logprobs, -> { Apologist::Chat::Types::ChatCompletionRequestLogprobs }, optional: true, nullable: false
20
+
21
+ field :top_logprobs, -> { Integer }, optional: true, nullable: false
22
+
23
+ field :max_completion_tokens, -> { Integer }, optional: true, nullable: false
24
+
25
+ field :max_tokens, -> { Integer }, optional: true, nullable: false
26
+
27
+ field :messages, -> { Internal::Types::Array[Apologist::Types::ChatMessage] }, optional: true, nullable: false
28
+
29
+ field :metadata, -> { Apologist::Chat::Types::ChatCompletionRequestMetadata }, optional: true, nullable: false
30
+
31
+ field :modalities, -> { Internal::Types::Array[Object] }, optional: true, nullable: false
32
+
33
+ field :model, -> { String }, optional: true, nullable: false
34
+
35
+ field :n, -> { Integer }, optional: true, nullable: false
36
+
37
+ field :parallel_tool_calls, -> { Internal::Types::Boolean }, optional: true, nullable: false
38
+
39
+ field :prediction, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false
40
+
41
+ field :presence_penalty, -> { Integer }, optional: true, nullable: false
42
+
43
+ field :prompt, -> { String }, optional: true, nullable: false
44
+
45
+ field :reasoning_effort, -> { Apologist::Chat::Types::ChatCompletionRequestReasoningEffort }, optional: true, nullable: false
46
+
47
+ field :verbosity, -> { Apologist::Chat::Types::ChatCompletionRequestVerbosity }, optional: true, nullable: false
48
+
49
+ field :response_format, -> { Apologist::Chat::Types::ChatCompletionRequestResponseFormat }, optional: true, nullable: false
50
+
51
+ field :seed, -> { Integer }, optional: true, nullable: false
52
+
53
+ field :service_tier, -> { String }, optional: true, nullable: false
54
+
55
+ field :stop, -> { String }, optional: true, nullable: false
56
+
57
+ field :store, -> { Internal::Types::Boolean }, optional: true, nullable: false
58
+
59
+ field :stream, -> { Internal::Types::Boolean }, optional: true, nullable: false
60
+
61
+ field :stream_options, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false
62
+
63
+ field :temperature, -> { Integer }, optional: true, nullable: false
64
+
65
+ field :top_p, -> { Integer }, optional: true, nullable: false
66
+
67
+ field :tools, -> { Internal::Types::Array[Object] }, optional: true, nullable: false
68
+
69
+ field :tool_choice, -> { Apologist::Chat::Types::ChatCompletionRequestToolChoice }, optional: true, nullable: false
70
+
71
+ field :user, -> { String }, optional: true, nullable: false
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Chat
5
+ module Types
6
+ class ChatCompletionRequestLogprobs < Internal::Types::Model
7
+ extend Apologist::Internal::Types::Union
8
+
9
+ member -> { Internal::Types::Boolean }
10
+
11
+ member -> { Integer }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Chat
5
+ module Types
6
+ class ChatCompletionRequestMetadata < Internal::Types::Model
7
+ field :anonymous, -> { Internal::Types::Boolean }, optional: true, nullable: false
8
+
9
+ field :conversation, -> { String }, optional: true, nullable: false
10
+
11
+ field :language, -> { String }, optional: true, nullable: false
12
+
13
+ field :max_memories, -> { Integer }, optional: true, nullable: false
14
+
15
+ field :parent_url, -> { String }, optional: true, nullable: false
16
+
17
+ field :parent_host, -> { String }, optional: true, nullable: false
18
+
19
+ field :session, -> { String }, optional: true, nullable: false
20
+
21
+ field :device, -> { String }, optional: true, nullable: false
22
+
23
+ field :referral_code, -> { String }, optional: true, nullable: false
24
+
25
+ field :shared_prompt, -> { Integer }, optional: true, nullable: false
26
+
27
+ field :translation, -> { String }, optional: true, nullable: false
28
+
29
+ field :variables, -> { Internal::Types::Hash[String, String] }, optional: true, nullable: false
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Chat
5
+ module Types
6
+ module ChatCompletionRequestReasoningEffort
7
+ extend Apologist::Internal::Types::Enum
8
+
9
+ LOW = "low"
10
+ MEDIUM = "medium"
11
+ HIGH = "high"
12
+ end
13
+ end
14
+ end
15
+ end