vapi_server_sdk 0.3.0 → 0.4.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.
- checksums.yaml +4 -4
- data/lib/requests.rb +2 -2
- data/lib/types_export.rb +31 -6
- data/lib/vapi_server_sdk/analytics/client.rb +0 -14
- data/lib/vapi_server_sdk/assistants/client.rb +4 -70
- data/lib/vapi_server_sdk/blocks/client.rb +0 -70
- data/lib/vapi_server_sdk/calls/client.rb +6 -70
- data/lib/vapi_server_sdk/files/client.rb +0 -70
- data/lib/vapi_server_sdk/knowledge_bases/client.rb +0 -70
- data/lib/vapi_server_sdk/logs/client.rb +13 -44
- data/lib/vapi_server_sdk/logs/types/logging_controller_logs_delete_query_request_type.rb +12 -0
- data/lib/vapi_server_sdk/phone_numbers/client.rb +0 -70
- data/lib/vapi_server_sdk/squads/client.rb +8 -70
- data/lib/vapi_server_sdk/tools/client.rb +0 -70
- data/lib/vapi_server_sdk/types/azure_credential_region.rb +4 -2
- data/lib/vapi_server_sdk/types/azure_open_ai_credential_region.rb +4 -2
- data/lib/vapi_server_sdk/types/bash_tool_with_tool_call.rb +175 -0
- data/lib/vapi_server_sdk/types/bash_tool_with_tool_call_messages_item.rb +120 -0
- data/lib/vapi_server_sdk/types/client_inbound_message_end_call.rb +47 -0
- data/lib/vapi_server_sdk/types/client_inbound_message_message.rb +13 -0
- data/lib/vapi_server_sdk/types/client_message_tool_calls_tool_with_tool_call_list_item.rb +116 -77
- data/lib/vapi_server_sdk/types/computer_tool_with_tool_call.rb +199 -0
- data/lib/vapi_server_sdk/types/computer_tool_with_tool_call_messages_item.rb +120 -0
- data/lib/vapi_server_sdk/types/create_azure_credential_dto_region.rb +4 -2
- data/lib/vapi_server_sdk/types/create_azure_open_ai_credential_dto_region.rb +4 -2
- data/lib/vapi_server_sdk/types/create_custom_knowledge_base_dto.rb +2 -4
- data/lib/vapi_server_sdk/types/create_trieve_knowledge_base_dto.rb +34 -47
- data/lib/vapi_server_sdk/types/create_trieve_knowledge_base_dto_create_plan.rb +97 -0
- data/lib/vapi_server_sdk/types/create_workflow_dto.rb +87 -0
- data/lib/vapi_server_sdk/types/create_workflow_dto_nodes_item.rb +81 -0
- data/lib/vapi_server_sdk/types/custom_knowledge_base.rb +2 -4
- data/lib/vapi_server_sdk/types/edge.rb +80 -0
- data/lib/vapi_server_sdk/types/edge_condition.rb +94 -0
- data/lib/vapi_server_sdk/types/function_tool_with_tool_call.rb +1 -10
- data/lib/vapi_server_sdk/types/gather.rb +87 -0
- data/lib/vapi_server_sdk/types/ghl_tool_with_tool_call.rb +1 -9
- data/lib/vapi_server_sdk/types/json_schema.rb +13 -2
- data/lib/vapi_server_sdk/types/log.rb +18 -18
- data/lib/vapi_server_sdk/types/make_tool_with_tool_call.rb +1 -9
- data/lib/vapi_server_sdk/types/programmatic_edge_condition.rb +57 -0
- data/lib/vapi_server_sdk/types/say.rb +72 -0
- data/lib/vapi_server_sdk/types/semantic_edge_condition.rb +57 -0
- data/lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb +116 -77
- data/lib/vapi_server_sdk/types/subscription.rb +11 -9
- data/lib/vapi_server_sdk/types/text_editor_tool_with_tool_call.rb +175 -0
- data/lib/vapi_server_sdk/types/text_editor_tool_with_tool_call_messages_item.rb +121 -0
- data/lib/vapi_server_sdk/types/trieve_knowledge_base.rb +35 -44
- data/lib/vapi_server_sdk/types/{trieve_knowledge_base_vector_store_create_plan.rb → trieve_knowledge_base_chunk_plan.rb} +17 -11
- data/lib/vapi_server_sdk/types/trieve_knowledge_base_create.rb +59 -0
- data/lib/vapi_server_sdk/types/trieve_knowledge_base_create_plan.rb +96 -0
- data/lib/vapi_server_sdk/types/trieve_knowledge_base_import.rb +55 -0
- data/lib/vapi_server_sdk/types/{trieve_knowledge_base_vector_store_search_plan.rb → trieve_knowledge_base_search_plan.rb} +9 -11
- data/lib/vapi_server_sdk/types/{trieve_knowledge_base_vector_store_search_plan_search_type.rb → trieve_knowledge_base_search_plan_search_type.rb} +1 -1
- data/lib/vapi_server_sdk/types/update_azure_credential_dto_region.rb +4 -2
- data/lib/vapi_server_sdk/types/update_azure_open_ai_credential_dto_region.rb +4 -2
- data/lib/vapi_server_sdk/types/update_custom_knowledge_base_dto.rb +2 -4
- data/lib/vapi_server_sdk/types/update_trieve_knowledge_base_dto.rb +34 -47
- data/lib/vapi_server_sdk/types/update_trieve_knowledge_base_dto_create_plan.rb +97 -0
- data/lib/vapi_server_sdk/types/update_workflow_dto.rb +82 -0
- data/lib/vapi_server_sdk/types/update_workflow_dto_nodes_item.rb +81 -0
- data/lib/vapi_server_sdk/types/vapi_model.rb +27 -1
- data/lib/vapi_server_sdk/types/workflow.rb +125 -0
- data/lib/vapi_server_sdk/types/workflow_nodes_item.rb +81 -0
- metadata +30 -5
@@ -4,9 +4,28 @@ require "json"
|
|
4
4
|
require_relative "function_tool_with_tool_call"
|
5
5
|
require_relative "ghl_tool_with_tool_call"
|
6
6
|
require_relative "make_tool_with_tool_call"
|
7
|
+
require_relative "bash_tool_with_tool_call"
|
8
|
+
require_relative "computer_tool_with_tool_call"
|
9
|
+
require_relative "text_editor_tool_with_tool_call"
|
7
10
|
|
8
11
|
module Vapi
|
9
12
|
class ServerMessageToolCallsToolWithToolCallListItem
|
13
|
+
# @return [Object]
|
14
|
+
attr_reader :member
|
15
|
+
# @return [String]
|
16
|
+
attr_reader :discriminant
|
17
|
+
|
18
|
+
private_class_method :new
|
19
|
+
alias kind_of? is_a?
|
20
|
+
|
21
|
+
# @param member [Object]
|
22
|
+
# @param discriminant [String]
|
23
|
+
# @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem]
|
24
|
+
def initialize(member:, discriminant:)
|
25
|
+
@member = member
|
26
|
+
@discriminant = discriminant
|
27
|
+
end
|
28
|
+
|
10
29
|
# Deserialize a JSON object to an instance of
|
11
30
|
# ServerMessageToolCallsToolWithToolCallListItem
|
12
31
|
#
|
@@ -14,55 +33,46 @@ module Vapi
|
|
14
33
|
# @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem]
|
15
34
|
def self.from_json(json_object:)
|
16
35
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
return Vapi::MakeToolWithToolCall.from_json(json_object: struct) unless struct.nil?
|
36
|
-
|
37
|
-
return nil
|
38
|
-
rescue StandardError
|
39
|
-
# noop
|
40
|
-
end
|
41
|
-
begin
|
42
|
-
struct.is_a?(Object) != false || raise("Passed value for field struct is not the expected type, validation failed.")
|
43
|
-
return struct unless struct.nil?
|
44
|
-
|
45
|
-
return nil
|
46
|
-
rescue StandardError
|
47
|
-
# noop
|
48
|
-
end
|
49
|
-
begin
|
50
|
-
struct.is_a?(Object) != false || raise("Passed value for field struct is not the expected type, validation failed.")
|
51
|
-
return struct unless struct.nil?
|
52
|
-
|
53
|
-
return nil
|
54
|
-
rescue StandardError
|
55
|
-
# noop
|
56
|
-
end
|
57
|
-
begin
|
58
|
-
struct.is_a?(Object) != false || raise("Passed value for field struct is not the expected type, validation failed.")
|
59
|
-
return struct unless struct.nil?
|
36
|
+
member = case struct.type
|
37
|
+
when "function"
|
38
|
+
Vapi::FunctionToolWithToolCall.from_json(json_object: json_object)
|
39
|
+
when "ghl"
|
40
|
+
Vapi::GhlToolWithToolCall.from_json(json_object: json_object)
|
41
|
+
when "make"
|
42
|
+
Vapi::MakeToolWithToolCall.from_json(json_object: json_object)
|
43
|
+
when "bash"
|
44
|
+
Vapi::BashToolWithToolCall.from_json(json_object: json_object)
|
45
|
+
when "computer"
|
46
|
+
Vapi::ComputerToolWithToolCall.from_json(json_object: json_object)
|
47
|
+
when "textEditor"
|
48
|
+
Vapi::TextEditorToolWithToolCall.from_json(json_object: json_object)
|
49
|
+
else
|
50
|
+
Vapi::FunctionToolWithToolCall.from_json(json_object: json_object)
|
51
|
+
end
|
52
|
+
new(member: member, discriminant: struct.type)
|
53
|
+
end
|
60
54
|
|
61
|
-
|
62
|
-
|
63
|
-
|
55
|
+
# For Union Types, to_json functionality is delegated to the wrapped member.
|
56
|
+
#
|
57
|
+
# @return [String]
|
58
|
+
def to_json(*_args)
|
59
|
+
case @discriminant
|
60
|
+
when "function"
|
61
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
62
|
+
when "ghl"
|
63
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
64
|
+
when "make"
|
65
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
66
|
+
when "bash"
|
67
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
68
|
+
when "computer"
|
69
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
70
|
+
when "textEditor"
|
71
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
72
|
+
else
|
73
|
+
{ "type": @discriminant, value: @member }.to_json
|
64
74
|
end
|
65
|
-
|
75
|
+
@member.to_json
|
66
76
|
end
|
67
77
|
|
68
78
|
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
@@ -72,37 +82,66 @@ module Vapi
|
|
72
82
|
# @param obj [Object]
|
73
83
|
# @return [Void]
|
74
84
|
def self.validate_raw(obj:)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
begin
|
91
|
-
return obj.is_a?(Object) != false || raise("Passed value for field obj is not the expected type, validation failed.")
|
92
|
-
rescue StandardError
|
93
|
-
# noop
|
94
|
-
end
|
95
|
-
begin
|
96
|
-
return obj.is_a?(Object) != false || raise("Passed value for field obj is not the expected type, validation failed.")
|
97
|
-
rescue StandardError
|
98
|
-
# noop
|
99
|
-
end
|
100
|
-
begin
|
101
|
-
return obj.is_a?(Object) != false || raise("Passed value for field obj is not the expected type, validation failed.")
|
102
|
-
rescue StandardError
|
103
|
-
# noop
|
85
|
+
case obj.type
|
86
|
+
when "function"
|
87
|
+
Vapi::FunctionToolWithToolCall.validate_raw(obj: obj)
|
88
|
+
when "ghl"
|
89
|
+
Vapi::GhlToolWithToolCall.validate_raw(obj: obj)
|
90
|
+
when "make"
|
91
|
+
Vapi::MakeToolWithToolCall.validate_raw(obj: obj)
|
92
|
+
when "bash"
|
93
|
+
Vapi::BashToolWithToolCall.validate_raw(obj: obj)
|
94
|
+
when "computer"
|
95
|
+
Vapi::ComputerToolWithToolCall.validate_raw(obj: obj)
|
96
|
+
when "textEditor"
|
97
|
+
Vapi::TextEditorToolWithToolCall.validate_raw(obj: obj)
|
98
|
+
else
|
99
|
+
raise("Passed value matched no type within the union, validation failed.")
|
104
100
|
end
|
105
|
-
|
101
|
+
end
|
102
|
+
|
103
|
+
# For Union Types, is_a? functionality is delegated to the wrapped member.
|
104
|
+
#
|
105
|
+
# @param obj [Object]
|
106
|
+
# @return [Boolean]
|
107
|
+
def is_a?(obj)
|
108
|
+
@member.is_a?(obj)
|
109
|
+
end
|
110
|
+
|
111
|
+
# @param member [Vapi::FunctionToolWithToolCall]
|
112
|
+
# @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem]
|
113
|
+
def self.function(member:)
|
114
|
+
new(member: member, discriminant: "function")
|
115
|
+
end
|
116
|
+
|
117
|
+
# @param member [Vapi::GhlToolWithToolCall]
|
118
|
+
# @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem]
|
119
|
+
def self.ghl(member:)
|
120
|
+
new(member: member, discriminant: "ghl")
|
121
|
+
end
|
122
|
+
|
123
|
+
# @param member [Vapi::MakeToolWithToolCall]
|
124
|
+
# @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem]
|
125
|
+
def self.make(member:)
|
126
|
+
new(member: member, discriminant: "make")
|
127
|
+
end
|
128
|
+
|
129
|
+
# @param member [Vapi::BashToolWithToolCall]
|
130
|
+
# @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem]
|
131
|
+
def self.bash(member:)
|
132
|
+
new(member: member, discriminant: "bash")
|
133
|
+
end
|
134
|
+
|
135
|
+
# @param member [Vapi::ComputerToolWithToolCall]
|
136
|
+
# @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem]
|
137
|
+
def self.computer(member:)
|
138
|
+
new(member: member, discriminant: "computer")
|
139
|
+
end
|
140
|
+
|
141
|
+
# @param member [Vapi::TextEditorToolWithToolCall]
|
142
|
+
# @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem]
|
143
|
+
def self.text_editor(member:)
|
144
|
+
new(member: member, discriminant: "textEditor")
|
106
145
|
end
|
107
146
|
end
|
108
147
|
end
|
@@ -23,8 +23,9 @@ module Vapi
|
|
23
23
|
# @return [String] This is the number of credits the subscription currently has.
|
24
24
|
# Note: This is a string to avoid floating point precision issues.
|
25
25
|
attr_reader :credits
|
26
|
-
# @return [Float] This is the total concurrency
|
27
|
-
|
26
|
+
# @return [Float] This is the total number of active calls (concurrency) across all orgs under
|
27
|
+
# this subscription.
|
28
|
+
attr_reader :concurrency_counter
|
28
29
|
# @return [Float] This is the default concurrency limit for the subscription.
|
29
30
|
attr_reader :concurrency_limit_included
|
30
31
|
# @return [Float] This is the purchased add-on concurrency limit for the subscription.
|
@@ -98,7 +99,8 @@ module Vapi
|
|
98
99
|
# with past due payments.
|
99
100
|
# @param credits [String] This is the number of credits the subscription currently has.
|
100
101
|
# Note: This is a string to avoid floating point precision issues.
|
101
|
-
# @param
|
102
|
+
# @param concurrency_counter [Float] This is the total number of active calls (concurrency) across all orgs under
|
103
|
+
# this subscription.
|
102
104
|
# @param concurrency_limit_included [Float] This is the default concurrency limit for the subscription.
|
103
105
|
# @param concurrency_limit_purchased [Float] This is the purchased add-on concurrency limit for the subscription.
|
104
106
|
# @param monthly_charge_schedule_id [Float] This is the ID of the monthly job that charges for subscription add ons and
|
@@ -135,7 +137,7 @@ module Vapi
|
|
135
137
|
# @param coupon_usage_left [String] This is the number of credits left obtained from a coupon.
|
136
138
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
137
139
|
# @return [Vapi::Subscription]
|
138
|
-
def initialize(id:, created_at:, updated_at:, type:, status:, credits:,
|
140
|
+
def initialize(id:, created_at:, updated_at:, type:, status:, credits:, concurrency_counter:,
|
139
141
|
concurrency_limit_included:, concurrency_limit_purchased:, monthly_charge_schedule_id: OMIT, monthly_credit_check_schedule_id: OMIT, stripe_customer_id: OMIT, stripe_payment_method_id: OMIT, slack_support_enabled: OMIT, slack_channel_id: OMIT, hipaa_enabled: OMIT, hipaa_common_paper_agreement_id: OMIT, stripe_payment_method_fingerprint: OMIT, stripe_customer_email: OMIT, referred_by_email: OMIT, auto_reload_plan: OMIT, minutes_included: OMIT, minutes_used: OMIT, minutes_overage_cost: OMIT, providers_included: OMIT, outbound_calls_daily_limit: OMIT, outbound_calls_counter: OMIT, outbound_calls_counter_next_reset_at: OMIT, coupon_ids: OMIT, coupon_usage_left: OMIT, additional_properties: nil)
|
140
142
|
@id = id
|
141
143
|
@created_at = created_at
|
@@ -143,7 +145,7 @@ module Vapi
|
|
143
145
|
@type = type
|
144
146
|
@status = status
|
145
147
|
@credits = credits
|
146
|
-
@
|
148
|
+
@concurrency_counter = concurrency_counter
|
147
149
|
@concurrency_limit_included = concurrency_limit_included
|
148
150
|
@concurrency_limit_purchased = concurrency_limit_purchased
|
149
151
|
@monthly_charge_schedule_id = monthly_charge_schedule_id if monthly_charge_schedule_id != OMIT
|
@@ -179,7 +181,7 @@ module Vapi
|
|
179
181
|
"type": type,
|
180
182
|
"status": status,
|
181
183
|
"credits": credits,
|
182
|
-
"
|
184
|
+
"concurrencyCounter": concurrency_counter,
|
183
185
|
"concurrencyLimitIncluded": concurrency_limit_included,
|
184
186
|
"concurrencyLimitPurchased": concurrency_limit_purchased,
|
185
187
|
"monthlyChargeScheduleId": monthly_charge_schedule_id,
|
@@ -221,7 +223,7 @@ module Vapi
|
|
221
223
|
type = parsed_json["type"]
|
222
224
|
status = parsed_json["status"]
|
223
225
|
credits = parsed_json["credits"]
|
224
|
-
|
226
|
+
concurrency_counter = parsed_json["concurrencyCounter"]
|
225
227
|
concurrency_limit_included = parsed_json["concurrencyLimitIncluded"]
|
226
228
|
concurrency_limit_purchased = parsed_json["concurrencyLimitPurchased"]
|
227
229
|
monthly_charge_schedule_id = parsed_json["monthlyChargeScheduleId"]
|
@@ -259,7 +261,7 @@ module Vapi
|
|
259
261
|
type: type,
|
260
262
|
status: status,
|
261
263
|
credits: credits,
|
262
|
-
|
264
|
+
concurrency_counter: concurrency_counter,
|
263
265
|
concurrency_limit_included: concurrency_limit_included,
|
264
266
|
concurrency_limit_purchased: concurrency_limit_purchased,
|
265
267
|
monthly_charge_schedule_id: monthly_charge_schedule_id,
|
@@ -307,7 +309,7 @@ module Vapi
|
|
307
309
|
obj.type.is_a?(Vapi::SubscriptionType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
|
308
310
|
obj.status.is_a?(Vapi::SubscriptionStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
309
311
|
obj.credits.is_a?(String) != false || raise("Passed value for field obj.credits is not the expected type, validation failed.")
|
310
|
-
obj.
|
312
|
+
obj.concurrency_counter.is_a?(Float) != false || raise("Passed value for field obj.concurrency_counter is not the expected type, validation failed.")
|
311
313
|
obj.concurrency_limit_included.is_a?(Float) != false || raise("Passed value for field obj.concurrency_limit_included is not the expected type, validation failed.")
|
312
314
|
obj.concurrency_limit_purchased.is_a?(Float) != false || raise("Passed value for field obj.concurrency_limit_purchased is not the expected type, validation failed.")
|
313
315
|
obj.monthly_charge_schedule_id&.is_a?(Float) != false || raise("Passed value for field obj.monthly_charge_schedule_id is not the expected type, validation failed.")
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "text_editor_tool_with_tool_call_messages_item"
|
4
|
+
require_relative "tool_call"
|
5
|
+
require_relative "open_ai_function"
|
6
|
+
require_relative "server"
|
7
|
+
require "ostruct"
|
8
|
+
require "json"
|
9
|
+
|
10
|
+
module Vapi
|
11
|
+
class TextEditorToolWithToolCall
|
12
|
+
# @return [Boolean] This determines if the tool is async.
|
13
|
+
# If async, the assistant will move forward without waiting for your server to
|
14
|
+
# respond. This is useful if you just want to trigger something on your server.
|
15
|
+
# If sync, the assistant will wait for your server to respond. This is useful if
|
16
|
+
# want assistant to respond with the result from your server.
|
17
|
+
# Defaults to synchronous (`false`).
|
18
|
+
attr_reader :async
|
19
|
+
# @return [Array<Vapi::TextEditorToolWithToolCallMessagesItem>] These are the messages that will be spoken to the user as the tool is running.
|
20
|
+
# For some tools, this is auto-filled based on special fields like
|
21
|
+
# `tool.destinations`. For others like the function tool, these can be custom
|
22
|
+
# configured.
|
23
|
+
attr_reader :messages
|
24
|
+
# @return [String] The sub type of tool.
|
25
|
+
attr_reader :sub_type
|
26
|
+
# @return [Vapi::ToolCall]
|
27
|
+
attr_reader :tool_call
|
28
|
+
# @return [String] The name of the tool, fixed to 'str_replace_editor'
|
29
|
+
attr_reader :name
|
30
|
+
# @return [Vapi::OpenAiFunction] This is the function definition of the tool.
|
31
|
+
# For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on
|
32
|
+
# tool-specific fields like `tool.destinations`. But, even in those cases, you can
|
33
|
+
# provide a custom function definition for advanced use cases.
|
34
|
+
# An example of an advanced use case is if you want to customize the message
|
35
|
+
# that's spoken for `endCall` tool. You can specify a function where it returns an
|
36
|
+
# argument "reason". Then, in `messages` array, you can have many
|
37
|
+
# "request-complete" messages. One of these messages will be triggered if the
|
38
|
+
# `messages[].conditions` matches the "reason" argument.
|
39
|
+
attr_reader :function
|
40
|
+
# @return [Vapi::Server] This is the server that will be hit when this tool is requested by the model.
|
41
|
+
# All requests will be sent with the call object among other things. You can find
|
42
|
+
# more details in the Server URL documentation.
|
43
|
+
# This overrides the serverUrl set on the org and the phoneNumber. Order of
|
44
|
+
# precedence: highest tool.server.url, then assistant.serverUrl, then
|
45
|
+
# phoneNumber.serverUrl, then org.serverUrl.
|
46
|
+
attr_reader :server
|
47
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
48
|
+
attr_reader :additional_properties
|
49
|
+
# @return [Object]
|
50
|
+
attr_reader :_field_set
|
51
|
+
protected :_field_set
|
52
|
+
|
53
|
+
OMIT = Object.new
|
54
|
+
|
55
|
+
# @param async [Boolean] This determines if the tool is async.
|
56
|
+
# If async, the assistant will move forward without waiting for your server to
|
57
|
+
# respond. This is useful if you just want to trigger something on your server.
|
58
|
+
# If sync, the assistant will wait for your server to respond. This is useful if
|
59
|
+
# want assistant to respond with the result from your server.
|
60
|
+
# Defaults to synchronous (`false`).
|
61
|
+
# @param messages [Array<Vapi::TextEditorToolWithToolCallMessagesItem>] These are the messages that will be spoken to the user as the tool is running.
|
62
|
+
# For some tools, this is auto-filled based on special fields like
|
63
|
+
# `tool.destinations`. For others like the function tool, these can be custom
|
64
|
+
# configured.
|
65
|
+
# @param sub_type [String] The sub type of tool.
|
66
|
+
# @param tool_call [Vapi::ToolCall]
|
67
|
+
# @param name [String] The name of the tool, fixed to 'str_replace_editor'
|
68
|
+
# @param function [Vapi::OpenAiFunction] This is the function definition of the tool.
|
69
|
+
# For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on
|
70
|
+
# tool-specific fields like `tool.destinations`. But, even in those cases, you can
|
71
|
+
# provide a custom function definition for advanced use cases.
|
72
|
+
# An example of an advanced use case is if you want to customize the message
|
73
|
+
# that's spoken for `endCall` tool. You can specify a function where it returns an
|
74
|
+
# argument "reason". Then, in `messages` array, you can have many
|
75
|
+
# "request-complete" messages. One of these messages will be triggered if the
|
76
|
+
# `messages[].conditions` matches the "reason" argument.
|
77
|
+
# @param server [Vapi::Server] This is the server that will be hit when this tool is requested by the model.
|
78
|
+
# All requests will be sent with the call object among other things. You can find
|
79
|
+
# more details in the Server URL documentation.
|
80
|
+
# This overrides the serverUrl set on the org and the phoneNumber. Order of
|
81
|
+
# precedence: highest tool.server.url, then assistant.serverUrl, then
|
82
|
+
# phoneNumber.serverUrl, then org.serverUrl.
|
83
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
84
|
+
# @return [Vapi::TextEditorToolWithToolCall]
|
85
|
+
def initialize(sub_type:, tool_call:, name:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT,
|
86
|
+
additional_properties: nil)
|
87
|
+
@async = async if async != OMIT
|
88
|
+
@messages = messages if messages != OMIT
|
89
|
+
@sub_type = sub_type
|
90
|
+
@tool_call = tool_call
|
91
|
+
@name = name
|
92
|
+
@function = function if function != OMIT
|
93
|
+
@server = server if server != OMIT
|
94
|
+
@additional_properties = additional_properties
|
95
|
+
@_field_set = {
|
96
|
+
"async": async,
|
97
|
+
"messages": messages,
|
98
|
+
"subType": sub_type,
|
99
|
+
"toolCall": tool_call,
|
100
|
+
"name": name,
|
101
|
+
"function": function,
|
102
|
+
"server": server
|
103
|
+
}.reject do |_k, v|
|
104
|
+
v == OMIT
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Deserialize a JSON object to an instance of TextEditorToolWithToolCall
|
109
|
+
#
|
110
|
+
# @param json_object [String]
|
111
|
+
# @return [Vapi::TextEditorToolWithToolCall]
|
112
|
+
def self.from_json(json_object:)
|
113
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
114
|
+
parsed_json = JSON.parse(json_object)
|
115
|
+
async = parsed_json["async"]
|
116
|
+
messages = parsed_json["messages"]&.map do |item|
|
117
|
+
item = item.to_json
|
118
|
+
Vapi::TextEditorToolWithToolCallMessagesItem.from_json(json_object: item)
|
119
|
+
end
|
120
|
+
sub_type = parsed_json["subType"]
|
121
|
+
if parsed_json["toolCall"].nil?
|
122
|
+
tool_call = nil
|
123
|
+
else
|
124
|
+
tool_call = parsed_json["toolCall"].to_json
|
125
|
+
tool_call = Vapi::ToolCall.from_json(json_object: tool_call)
|
126
|
+
end
|
127
|
+
name = parsed_json["name"]
|
128
|
+
if parsed_json["function"].nil?
|
129
|
+
function = nil
|
130
|
+
else
|
131
|
+
function = parsed_json["function"].to_json
|
132
|
+
function = Vapi::OpenAiFunction.from_json(json_object: function)
|
133
|
+
end
|
134
|
+
if parsed_json["server"].nil?
|
135
|
+
server = nil
|
136
|
+
else
|
137
|
+
server = parsed_json["server"].to_json
|
138
|
+
server = Vapi::Server.from_json(json_object: server)
|
139
|
+
end
|
140
|
+
new(
|
141
|
+
async: async,
|
142
|
+
messages: messages,
|
143
|
+
sub_type: sub_type,
|
144
|
+
tool_call: tool_call,
|
145
|
+
name: name,
|
146
|
+
function: function,
|
147
|
+
server: server,
|
148
|
+
additional_properties: struct
|
149
|
+
)
|
150
|
+
end
|
151
|
+
|
152
|
+
# Serialize an instance of TextEditorToolWithToolCall to a JSON object
|
153
|
+
#
|
154
|
+
# @return [String]
|
155
|
+
def to_json(*_args)
|
156
|
+
@_field_set&.to_json
|
157
|
+
end
|
158
|
+
|
159
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
160
|
+
# hash and check each fields type against the current object's property
|
161
|
+
# definitions.
|
162
|
+
#
|
163
|
+
# @param obj [Object]
|
164
|
+
# @return [Void]
|
165
|
+
def self.validate_raw(obj:)
|
166
|
+
obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.")
|
167
|
+
obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.")
|
168
|
+
obj.sub_type.is_a?(String) != false || raise("Passed value for field obj.sub_type is not the expected type, validation failed.")
|
169
|
+
Vapi::ToolCall.validate_raw(obj: obj.tool_call)
|
170
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
171
|
+
obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function)
|
172
|
+
obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require_relative "tool_message_start"
|
5
|
+
require_relative "tool_message_complete"
|
6
|
+
require_relative "tool_message_failed"
|
7
|
+
require_relative "tool_message_delayed"
|
8
|
+
|
9
|
+
module Vapi
|
10
|
+
class TextEditorToolWithToolCallMessagesItem
|
11
|
+
# @return [Object]
|
12
|
+
attr_reader :member
|
13
|
+
# @return [String]
|
14
|
+
attr_reader :discriminant
|
15
|
+
|
16
|
+
private_class_method :new
|
17
|
+
alias kind_of? is_a?
|
18
|
+
|
19
|
+
# @param member [Object]
|
20
|
+
# @param discriminant [String]
|
21
|
+
# @return [Vapi::TextEditorToolWithToolCallMessagesItem]
|
22
|
+
def initialize(member:, discriminant:)
|
23
|
+
@member = member
|
24
|
+
@discriminant = discriminant
|
25
|
+
end
|
26
|
+
|
27
|
+
# Deserialize a JSON object to an instance of
|
28
|
+
# TextEditorToolWithToolCallMessagesItem
|
29
|
+
#
|
30
|
+
# @param json_object [String]
|
31
|
+
# @return [Vapi::TextEditorToolWithToolCallMessagesItem]
|
32
|
+
def self.from_json(json_object:)
|
33
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
34
|
+
member = case struct.type
|
35
|
+
when "request-start"
|
36
|
+
Vapi::ToolMessageStart.from_json(json_object: json_object)
|
37
|
+
when "request-complete"
|
38
|
+
Vapi::ToolMessageComplete.from_json(json_object: json_object)
|
39
|
+
when "request-failed"
|
40
|
+
Vapi::ToolMessageFailed.from_json(json_object: json_object)
|
41
|
+
when "request-response-delayed"
|
42
|
+
Vapi::ToolMessageDelayed.from_json(json_object: json_object)
|
43
|
+
else
|
44
|
+
Vapi::ToolMessageStart.from_json(json_object: json_object)
|
45
|
+
end
|
46
|
+
new(member: member, discriminant: struct.type)
|
47
|
+
end
|
48
|
+
|
49
|
+
# For Union Types, to_json functionality is delegated to the wrapped member.
|
50
|
+
#
|
51
|
+
# @return [String]
|
52
|
+
def to_json(*_args)
|
53
|
+
case @discriminant
|
54
|
+
when "request-start"
|
55
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
56
|
+
when "request-complete"
|
57
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
58
|
+
when "request-failed"
|
59
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
60
|
+
when "request-response-delayed"
|
61
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
62
|
+
else
|
63
|
+
{ "type": @discriminant, value: @member }.to_json
|
64
|
+
end
|
65
|
+
@member.to_json
|
66
|
+
end
|
67
|
+
|
68
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
69
|
+
# hash and check each fields type against the current object's property
|
70
|
+
# definitions.
|
71
|
+
#
|
72
|
+
# @param obj [Object]
|
73
|
+
# @return [Void]
|
74
|
+
def self.validate_raw(obj:)
|
75
|
+
case obj.type
|
76
|
+
when "request-start"
|
77
|
+
Vapi::ToolMessageStart.validate_raw(obj: obj)
|
78
|
+
when "request-complete"
|
79
|
+
Vapi::ToolMessageComplete.validate_raw(obj: obj)
|
80
|
+
when "request-failed"
|
81
|
+
Vapi::ToolMessageFailed.validate_raw(obj: obj)
|
82
|
+
when "request-response-delayed"
|
83
|
+
Vapi::ToolMessageDelayed.validate_raw(obj: obj)
|
84
|
+
else
|
85
|
+
raise("Passed value matched no type within the union, validation failed.")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# For Union Types, is_a? functionality is delegated to the wrapped member.
|
90
|
+
#
|
91
|
+
# @param obj [Object]
|
92
|
+
# @return [Boolean]
|
93
|
+
def is_a?(obj)
|
94
|
+
@member.is_a?(obj)
|
95
|
+
end
|
96
|
+
|
97
|
+
# @param member [Vapi::ToolMessageStart]
|
98
|
+
# @return [Vapi::TextEditorToolWithToolCallMessagesItem]
|
99
|
+
def self.request_start(member:)
|
100
|
+
new(member: member, discriminant: "request-start")
|
101
|
+
end
|
102
|
+
|
103
|
+
# @param member [Vapi::ToolMessageComplete]
|
104
|
+
# @return [Vapi::TextEditorToolWithToolCallMessagesItem]
|
105
|
+
def self.request_complete(member:)
|
106
|
+
new(member: member, discriminant: "request-complete")
|
107
|
+
end
|
108
|
+
|
109
|
+
# @param member [Vapi::ToolMessageFailed]
|
110
|
+
# @return [Vapi::TextEditorToolWithToolCallMessagesItem]
|
111
|
+
def self.request_failed(member:)
|
112
|
+
new(member: member, discriminant: "request-failed")
|
113
|
+
end
|
114
|
+
|
115
|
+
# @param member [Vapi::ToolMessageDelayed]
|
116
|
+
# @return [Vapi::TextEditorToolWithToolCallMessagesItem]
|
117
|
+
def self.request_response_delayed(member:)
|
118
|
+
new(member: member, discriminant: "request-response-delayed")
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|