apologist 1.3.0 → 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.
- checksums.yaml +4 -4
- data/.fern/metadata.json +2 -2
- data/README.md +1 -3
- data/lib/Apologist/benchmarks/client.rb +2 -1
- data/lib/Apologist/benchmarks/types/benchmark_run_request_content.rb +1 -1
- data/lib/Apologist/benchmarks/types/benchmark_run_request_content_one_item.rb +15 -0
- data/lib/Apologist/channels/client.rb +41 -14
- data/lib/Apologist/channels/types/chatwoot_webhook_payload.rb +35 -0
- data/lib/Apologist/channels/types/chatwoot_webhook_payload_account.rb +11 -0
- data/lib/Apologist/channels/types/chatwoot_webhook_payload_conversation.rb +18 -0
- data/lib/Apologist/channels/types/chatwoot_webhook_payload_conversation_account.rb +11 -0
- data/lib/Apologist/channels/types/chatwoot_webhook_payload_sender.rb +16 -0
- data/lib/Apologist/chat/client.rb +103 -6
- data/lib/Apologist/chat/types/anonymize_completion_request.rb +11 -0
- data/lib/Apologist/chat/types/anonymize_completion_response.rb +11 -0
- data/lib/Apologist/chat/types/chat_completion_request.rb +75 -0
- data/lib/Apologist/chat/types/chat_completion_request_logprobs.rb +15 -0
- data/lib/Apologist/chat/types/chat_completion_request_metadata.rb +33 -0
- data/lib/Apologist/chat/types/chat_completion_request_reasoning_effort.rb +15 -0
- data/lib/Apologist/chat/types/chat_completion_request_response_format.rb +13 -0
- data/lib/Apologist/chat/types/chat_completion_request_response_format_json_schema.rb +19 -0
- data/lib/Apologist/chat/types/chat_completion_request_response_format_type.rb +17 -0
- data/lib/Apologist/chat/types/chat_completion_request_tool_choice.rb +15 -0
- data/lib/Apologist/chat/types/chat_completion_request_tool_choice_zero.rb +15 -0
- data/lib/Apologist/chat/types/chat_completion_request_verbosity.rb +16 -0
- data/lib/Apologist/chat/types/list_chat_completions_request.rb +6 -0
- data/lib/Apologist/chat/types/scrub_completion_request.rb +11 -0
- data/lib/Apologist/chat/types/scrub_completion_response.rb +11 -0
- data/lib/Apologist/client.rb +1 -1
- data/lib/Apologist/ct_as/client.rb +3 -5
- data/lib/Apologist/ct_as/types/cta_match_request.rb +27 -0
- data/lib/Apologist/evaluators/types/evaluator_request_content.rb +2 -1
- data/lib/Apologist/evaluators/types/evaluator_request_content_one_item.rb +15 -0
- data/lib/Apologist/types/chatwoot_conversation_meta.rb +11 -0
- data/lib/Apologist/types/chatwoot_conversation_meta_sender.rb +11 -0
- data/lib/Apologist/types/completion_redact_response.rb +16 -0
- data/lib/Apologist/types/{chat_completion_request_reasoning_effort.rb → completion_redact_response_mode.rb} +3 -4
- data/lib/Apologist/types/user_flag.rb +2 -0
- data/lib/Apologist/types/webhook_evaluation.rb +1 -1
- data/lib/Apologist/types/webhook_event_info_key.rb +1 -0
- data/lib/Apologist/types/webhook_payload.rb +6 -2
- data/lib/Apologist/types/webhook_payload_trace.rb +13 -0
- data/lib/Apologist/version.rb +1 -1
- data/lib/Apologist.rb +29 -14
- data/reference.md +586 -24
- metadata +29 -14
- data/lib/Apologist/channels/types/receive_chatwoot_webhook_request.rb +0 -17
- data/lib/Apologist/types/chat_completion_request.rb +0 -11
- data/lib/Apologist/types/chat_completion_request_logprobs.rb +0 -13
- data/lib/Apologist/types/chat_completion_request_metadata.rb +0 -31
- data/lib/Apologist/types/chat_completion_request_response_format.rb +0 -11
- data/lib/Apologist/types/chat_completion_request_response_format_json_schema.rb +0 -17
- data/lib/Apologist/types/chat_completion_request_response_format_type.rb +0 -15
- data/lib/Apologist/types/chat_completion_request_tool_choice.rb +0 -13
- data/lib/Apologist/types/chat_completion_request_tool_choice_zero.rb +0 -13
- data/lib/Apologist/types/chat_completion_request_verbosity.rb +0 -14
- 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b8b35bf0de9553ecf5f3863ad050defcb16905a2c92c92168a0cbd1b3606ce54
|
|
4
|
+
data.tar.gz: 15551174479fe50af048668359c683598acbd87b20b057644387ef2a533055a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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": "
|
|
9
|
+
"originGitCommit": "aa8fb4b4d05d7116588d03dfe64ebe361e8ba59b",
|
|
10
10
|
"originGitCommitIsDirty": false,
|
|
11
11
|
"invokedBy": "ci",
|
|
12
12
|
"ciProvider": "github",
|
|
13
|
-
"sdkVersion": "1.
|
|
13
|
+
"sdkVersion": "1.3.1"
|
|
14
14
|
}
|
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(
|
|
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]
|
|
@@ -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 [
|
|
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] :
|
|
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
|
-
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
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
|
-
|
|
79
|
-
|
|
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[:
|
|
115
|
+
path: "channels/#{URI.encode_uri_component(params[:channel_id].to_s)}/chatwoot",
|
|
89
116
|
headers: headers,
|
|
90
|
-
body:
|
|
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
|
|
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.
|
|
548
|
-
# verification via `x-hub-signature-256` is
|
|
549
|
-
#
|
|
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,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,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(
|
|
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
|
-
|
|
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 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,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Apologist
|
|
4
|
+
module Chat
|
|
5
|
+
module Types
|
|
6
|
+
class ChatCompletionRequestResponseFormat < Internal::Types::Model
|
|
7
|
+
field :type, -> { Apologist::Chat::Types::ChatCompletionRequestResponseFormatType }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :json_schema, -> { Apologist::Chat::Types::ChatCompletionRequestResponseFormatJSONSchema }, optional: true, nullable: false
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Apologist
|
|
4
|
+
module Chat
|
|
5
|
+
module Types
|
|
6
|
+
# Required when type is json_schema. Supplies the JSON Schema the structured output must conform to. Structured
|
|
7
|
+
# outputs are non-streaming.
|
|
8
|
+
class ChatCompletionRequestResponseFormatJSONSchema < Internal::Types::Model
|
|
9
|
+
field :name, -> { String }, optional: true, nullable: false
|
|
10
|
+
|
|
11
|
+
field :description, -> { String }, optional: true, nullable: false
|
|
12
|
+
|
|
13
|
+
field :schema, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false
|
|
14
|
+
|
|
15
|
+
field :strict, -> { Internal::Types::Boolean }, optional: true, nullable: false
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Apologist
|
|
4
|
+
module Chat
|
|
5
|
+
module Types
|
|
6
|
+
module ChatCompletionRequestResponseFormatType
|
|
7
|
+
extend Apologist::Internal::Types::Enum
|
|
8
|
+
|
|
9
|
+
TEXT = "text"
|
|
10
|
+
HTML = "html"
|
|
11
|
+
JSON_ = "json"
|
|
12
|
+
RAW = "raw"
|
|
13
|
+
JSON_SCHEMA = "json_schema"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Apologist
|
|
4
|
+
module Chat
|
|
5
|
+
module Types
|
|
6
|
+
class ChatCompletionRequestToolChoice < Internal::Types::Model
|
|
7
|
+
extend Apologist::Internal::Types::Union
|
|
8
|
+
|
|
9
|
+
member -> { Apologist::Chat::Types::ChatCompletionRequestToolChoiceZero }
|
|
10
|
+
|
|
11
|
+
member -> { Internal::Types::Hash[String, Object] }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|