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
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Vapi
|
7
|
+
class ClientInboundMessageEndCall
|
8
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
9
|
+
attr_reader :additional_properties
|
10
|
+
# @return [Object]
|
11
|
+
attr_reader :_field_set
|
12
|
+
protected :_field_set
|
13
|
+
|
14
|
+
OMIT = Object.new
|
15
|
+
|
16
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
17
|
+
# @return [Vapi::ClientInboundMessageEndCall]
|
18
|
+
def initialize(additional_properties: nil)
|
19
|
+
@additional_properties = additional_properties
|
20
|
+
@_field_set = {}
|
21
|
+
end
|
22
|
+
|
23
|
+
# Deserialize a JSON object to an instance of ClientInboundMessageEndCall
|
24
|
+
#
|
25
|
+
# @param json_object [String]
|
26
|
+
# @return [Vapi::ClientInboundMessageEndCall]
|
27
|
+
def self.from_json(json_object:)
|
28
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
29
|
+
new(additional_properties: struct)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Serialize an instance of ClientInboundMessageEndCall to a JSON object
|
33
|
+
#
|
34
|
+
# @return [String]
|
35
|
+
def to_json(*_args)
|
36
|
+
@_field_set&.to_json
|
37
|
+
end
|
38
|
+
|
39
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
40
|
+
# hash and check each fields type against the current object's property
|
41
|
+
# definitions.
|
42
|
+
#
|
43
|
+
# @param obj [Object]
|
44
|
+
# @return [Void]
|
45
|
+
def self.validate_raw(obj:); end
|
46
|
+
end
|
47
|
+
end
|
@@ -4,6 +4,7 @@ require "json"
|
|
4
4
|
require_relative "client_inbound_message_add_message"
|
5
5
|
require_relative "client_inbound_message_control"
|
6
6
|
require_relative "client_inbound_message_say"
|
7
|
+
require_relative "client_inbound_message_end_call"
|
7
8
|
require_relative "client_inbound_message_transfer"
|
8
9
|
|
9
10
|
module Vapi
|
@@ -39,6 +40,8 @@ module Vapi
|
|
39
40
|
Vapi::ClientInboundMessageControl.from_json(json_object: json_object)
|
40
41
|
when "say"
|
41
42
|
Vapi::ClientInboundMessageSay.from_json(json_object: json_object)
|
43
|
+
when "end-call"
|
44
|
+
Vapi::ClientInboundMessageEndCall.from_json(json_object: json_object)
|
42
45
|
when "transfer"
|
43
46
|
Vapi::ClientInboundMessageTransfer.from_json(json_object: json_object)
|
44
47
|
else
|
@@ -58,6 +61,8 @@ module Vapi
|
|
58
61
|
{ **@member.to_json, type: @discriminant }.to_json
|
59
62
|
when "say"
|
60
63
|
{ **@member.to_json, type: @discriminant }.to_json
|
64
|
+
when "end-call"
|
65
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
61
66
|
when "transfer"
|
62
67
|
{ **@member.to_json, type: @discriminant }.to_json
|
63
68
|
else
|
@@ -80,6 +85,8 @@ module Vapi
|
|
80
85
|
Vapi::ClientInboundMessageControl.validate_raw(obj: obj)
|
81
86
|
when "say"
|
82
87
|
Vapi::ClientInboundMessageSay.validate_raw(obj: obj)
|
88
|
+
when "end-call"
|
89
|
+
Vapi::ClientInboundMessageEndCall.validate_raw(obj: obj)
|
83
90
|
when "transfer"
|
84
91
|
Vapi::ClientInboundMessageTransfer.validate_raw(obj: obj)
|
85
92
|
else
|
@@ -113,6 +120,12 @@ module Vapi
|
|
113
120
|
new(member: member, discriminant: "say")
|
114
121
|
end
|
115
122
|
|
123
|
+
# @param member [Vapi::ClientInboundMessageEndCall]
|
124
|
+
# @return [Vapi::ClientInboundMessageMessage]
|
125
|
+
def self.end_call(member:)
|
126
|
+
new(member: member, discriminant: "end-call")
|
127
|
+
end
|
128
|
+
|
116
129
|
# @param member [Vapi::ClientInboundMessageTransfer]
|
117
130
|
# @return [Vapi::ClientInboundMessageMessage]
|
118
131
|
def self.transfer(member:)
|
@@ -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 ClientMessageToolCallsToolWithToolCallListItem
|
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::ClientMessageToolCallsToolWithToolCallListItem]
|
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
|
# ClientMessageToolCallsToolWithToolCallListItem
|
12
31
|
#
|
@@ -14,55 +33,46 @@ module Vapi
|
|
14
33
|
# @return [Vapi::ClientMessageToolCallsToolWithToolCallListItem]
|
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::ClientMessageToolCallsToolWithToolCallListItem]
|
113
|
+
def self.function(member:)
|
114
|
+
new(member: member, discriminant: "function")
|
115
|
+
end
|
116
|
+
|
117
|
+
# @param member [Vapi::GhlToolWithToolCall]
|
118
|
+
# @return [Vapi::ClientMessageToolCallsToolWithToolCallListItem]
|
119
|
+
def self.ghl(member:)
|
120
|
+
new(member: member, discriminant: "ghl")
|
121
|
+
end
|
122
|
+
|
123
|
+
# @param member [Vapi::MakeToolWithToolCall]
|
124
|
+
# @return [Vapi::ClientMessageToolCallsToolWithToolCallListItem]
|
125
|
+
def self.make(member:)
|
126
|
+
new(member: member, discriminant: "make")
|
127
|
+
end
|
128
|
+
|
129
|
+
# @param member [Vapi::BashToolWithToolCall]
|
130
|
+
# @return [Vapi::ClientMessageToolCallsToolWithToolCallListItem]
|
131
|
+
def self.bash(member:)
|
132
|
+
new(member: member, discriminant: "bash")
|
133
|
+
end
|
134
|
+
|
135
|
+
# @param member [Vapi::ComputerToolWithToolCall]
|
136
|
+
# @return [Vapi::ClientMessageToolCallsToolWithToolCallListItem]
|
137
|
+
def self.computer(member:)
|
138
|
+
new(member: member, discriminant: "computer")
|
139
|
+
end
|
140
|
+
|
141
|
+
# @param member [Vapi::TextEditorToolWithToolCall]
|
142
|
+
# @return [Vapi::ClientMessageToolCallsToolWithToolCallListItem]
|
143
|
+
def self.text_editor(member:)
|
144
|
+
new(member: member, discriminant: "textEditor")
|
106
145
|
end
|
107
146
|
end
|
108
147
|
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "computer_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 ComputerToolWithToolCall
|
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::ComputerToolWithToolCallMessagesItem>] 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 'computer'
|
29
|
+
attr_reader :name
|
30
|
+
# @return [Float] The display width in pixels
|
31
|
+
attr_reader :display_width_px
|
32
|
+
# @return [Float] The display height in pixels
|
33
|
+
attr_reader :display_height_px
|
34
|
+
# @return [Float] Optional display number
|
35
|
+
attr_reader :display_number
|
36
|
+
# @return [Vapi::OpenAiFunction] This is the function definition of the tool.
|
37
|
+
# For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on
|
38
|
+
# tool-specific fields like `tool.destinations`. But, even in those cases, you can
|
39
|
+
# provide a custom function definition for advanced use cases.
|
40
|
+
# An example of an advanced use case is if you want to customize the message
|
41
|
+
# that's spoken for `endCall` tool. You can specify a function where it returns an
|
42
|
+
# argument "reason". Then, in `messages` array, you can have many
|
43
|
+
# "request-complete" messages. One of these messages will be triggered if the
|
44
|
+
# `messages[].conditions` matches the "reason" argument.
|
45
|
+
attr_reader :function
|
46
|
+
# @return [Vapi::Server] This is the server that will be hit when this tool is requested by the model.
|
47
|
+
# All requests will be sent with the call object among other things. You can find
|
48
|
+
# more details in the Server URL documentation.
|
49
|
+
# This overrides the serverUrl set on the org and the phoneNumber. Order of
|
50
|
+
# precedence: highest tool.server.url, then assistant.serverUrl, then
|
51
|
+
# phoneNumber.serverUrl, then org.serverUrl.
|
52
|
+
attr_reader :server
|
53
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
54
|
+
attr_reader :additional_properties
|
55
|
+
# @return [Object]
|
56
|
+
attr_reader :_field_set
|
57
|
+
protected :_field_set
|
58
|
+
|
59
|
+
OMIT = Object.new
|
60
|
+
|
61
|
+
# @param async [Boolean] This determines if the tool is async.
|
62
|
+
# If async, the assistant will move forward without waiting for your server to
|
63
|
+
# respond. This is useful if you just want to trigger something on your server.
|
64
|
+
# If sync, the assistant will wait for your server to respond. This is useful if
|
65
|
+
# want assistant to respond with the result from your server.
|
66
|
+
# Defaults to synchronous (`false`).
|
67
|
+
# @param messages [Array<Vapi::ComputerToolWithToolCallMessagesItem>] These are the messages that will be spoken to the user as the tool is running.
|
68
|
+
# For some tools, this is auto-filled based on special fields like
|
69
|
+
# `tool.destinations`. For others like the function tool, these can be custom
|
70
|
+
# configured.
|
71
|
+
# @param sub_type [String] The sub type of tool.
|
72
|
+
# @param tool_call [Vapi::ToolCall]
|
73
|
+
# @param name [String] The name of the tool, fixed to 'computer'
|
74
|
+
# @param display_width_px [Float] The display width in pixels
|
75
|
+
# @param display_height_px [Float] The display height in pixels
|
76
|
+
# @param display_number [Float] Optional display number
|
77
|
+
# @param function [Vapi::OpenAiFunction] This is the function definition of the tool.
|
78
|
+
# For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on
|
79
|
+
# tool-specific fields like `tool.destinations`. But, even in those cases, you can
|
80
|
+
# provide a custom function definition for advanced use cases.
|
81
|
+
# An example of an advanced use case is if you want to customize the message
|
82
|
+
# that's spoken for `endCall` tool. You can specify a function where it returns an
|
83
|
+
# argument "reason". Then, in `messages` array, you can have many
|
84
|
+
# "request-complete" messages. One of these messages will be triggered if the
|
85
|
+
# `messages[].conditions` matches the "reason" argument.
|
86
|
+
# @param server [Vapi::Server] This is the server that will be hit when this tool is requested by the model.
|
87
|
+
# All requests will be sent with the call object among other things. You can find
|
88
|
+
# more details in the Server URL documentation.
|
89
|
+
# This overrides the serverUrl set on the org and the phoneNumber. Order of
|
90
|
+
# precedence: highest tool.server.url, then assistant.serverUrl, then
|
91
|
+
# phoneNumber.serverUrl, then org.serverUrl.
|
92
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
93
|
+
# @return [Vapi::ComputerToolWithToolCall]
|
94
|
+
def initialize(sub_type:, tool_call:, name:, display_width_px:, display_height_px:, async: OMIT, messages: OMIT,
|
95
|
+
display_number: OMIT, function: OMIT, server: OMIT, additional_properties: nil)
|
96
|
+
@async = async if async != OMIT
|
97
|
+
@messages = messages if messages != OMIT
|
98
|
+
@sub_type = sub_type
|
99
|
+
@tool_call = tool_call
|
100
|
+
@name = name
|
101
|
+
@display_width_px = display_width_px
|
102
|
+
@display_height_px = display_height_px
|
103
|
+
@display_number = display_number if display_number != OMIT
|
104
|
+
@function = function if function != OMIT
|
105
|
+
@server = server if server != OMIT
|
106
|
+
@additional_properties = additional_properties
|
107
|
+
@_field_set = {
|
108
|
+
"async": async,
|
109
|
+
"messages": messages,
|
110
|
+
"subType": sub_type,
|
111
|
+
"toolCall": tool_call,
|
112
|
+
"name": name,
|
113
|
+
"displayWidthPx": display_width_px,
|
114
|
+
"displayHeightPx": display_height_px,
|
115
|
+
"displayNumber": display_number,
|
116
|
+
"function": function,
|
117
|
+
"server": server
|
118
|
+
}.reject do |_k, v|
|
119
|
+
v == OMIT
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# Deserialize a JSON object to an instance of ComputerToolWithToolCall
|
124
|
+
#
|
125
|
+
# @param json_object [String]
|
126
|
+
# @return [Vapi::ComputerToolWithToolCall]
|
127
|
+
def self.from_json(json_object:)
|
128
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
129
|
+
parsed_json = JSON.parse(json_object)
|
130
|
+
async = parsed_json["async"]
|
131
|
+
messages = parsed_json["messages"]&.map do |item|
|
132
|
+
item = item.to_json
|
133
|
+
Vapi::ComputerToolWithToolCallMessagesItem.from_json(json_object: item)
|
134
|
+
end
|
135
|
+
sub_type = parsed_json["subType"]
|
136
|
+
if parsed_json["toolCall"].nil?
|
137
|
+
tool_call = nil
|
138
|
+
else
|
139
|
+
tool_call = parsed_json["toolCall"].to_json
|
140
|
+
tool_call = Vapi::ToolCall.from_json(json_object: tool_call)
|
141
|
+
end
|
142
|
+
name = parsed_json["name"]
|
143
|
+
display_width_px = parsed_json["displayWidthPx"]
|
144
|
+
display_height_px = parsed_json["displayHeightPx"]
|
145
|
+
display_number = parsed_json["displayNumber"]
|
146
|
+
if parsed_json["function"].nil?
|
147
|
+
function = nil
|
148
|
+
else
|
149
|
+
function = parsed_json["function"].to_json
|
150
|
+
function = Vapi::OpenAiFunction.from_json(json_object: function)
|
151
|
+
end
|
152
|
+
if parsed_json["server"].nil?
|
153
|
+
server = nil
|
154
|
+
else
|
155
|
+
server = parsed_json["server"].to_json
|
156
|
+
server = Vapi::Server.from_json(json_object: server)
|
157
|
+
end
|
158
|
+
new(
|
159
|
+
async: async,
|
160
|
+
messages: messages,
|
161
|
+
sub_type: sub_type,
|
162
|
+
tool_call: tool_call,
|
163
|
+
name: name,
|
164
|
+
display_width_px: display_width_px,
|
165
|
+
display_height_px: display_height_px,
|
166
|
+
display_number: display_number,
|
167
|
+
function: function,
|
168
|
+
server: server,
|
169
|
+
additional_properties: struct
|
170
|
+
)
|
171
|
+
end
|
172
|
+
|
173
|
+
# Serialize an instance of ComputerToolWithToolCall to a JSON object
|
174
|
+
#
|
175
|
+
# @return [String]
|
176
|
+
def to_json(*_args)
|
177
|
+
@_field_set&.to_json
|
178
|
+
end
|
179
|
+
|
180
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
181
|
+
# hash and check each fields type against the current object's property
|
182
|
+
# definitions.
|
183
|
+
#
|
184
|
+
# @param obj [Object]
|
185
|
+
# @return [Void]
|
186
|
+
def self.validate_raw(obj:)
|
187
|
+
obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.")
|
188
|
+
obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.")
|
189
|
+
obj.sub_type.is_a?(String) != false || raise("Passed value for field obj.sub_type is not the expected type, validation failed.")
|
190
|
+
Vapi::ToolCall.validate_raw(obj: obj.tool_call)
|
191
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
192
|
+
obj.display_width_px.is_a?(Float) != false || raise("Passed value for field obj.display_width_px is not the expected type, validation failed.")
|
193
|
+
obj.display_height_px.is_a?(Float) != false || raise("Passed value for field obj.display_height_px is not the expected type, validation failed.")
|
194
|
+
obj.display_number&.is_a?(Float) != false || raise("Passed value for field obj.display_number is not the expected type, validation failed.")
|
195
|
+
obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function)
|
196
|
+
obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,120 @@
|
|
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 ComputerToolWithToolCallMessagesItem
|
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::ComputerToolWithToolCallMessagesItem]
|
22
|
+
def initialize(member:, discriminant:)
|
23
|
+
@member = member
|
24
|
+
@discriminant = discriminant
|
25
|
+
end
|
26
|
+
|
27
|
+
# Deserialize a JSON object to an instance of ComputerToolWithToolCallMessagesItem
|
28
|
+
#
|
29
|
+
# @param json_object [String]
|
30
|
+
# @return [Vapi::ComputerToolWithToolCallMessagesItem]
|
31
|
+
def self.from_json(json_object:)
|
32
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
33
|
+
member = case struct.type
|
34
|
+
when "request-start"
|
35
|
+
Vapi::ToolMessageStart.from_json(json_object: json_object)
|
36
|
+
when "request-complete"
|
37
|
+
Vapi::ToolMessageComplete.from_json(json_object: json_object)
|
38
|
+
when "request-failed"
|
39
|
+
Vapi::ToolMessageFailed.from_json(json_object: json_object)
|
40
|
+
when "request-response-delayed"
|
41
|
+
Vapi::ToolMessageDelayed.from_json(json_object: json_object)
|
42
|
+
else
|
43
|
+
Vapi::ToolMessageStart.from_json(json_object: json_object)
|
44
|
+
end
|
45
|
+
new(member: member, discriminant: struct.type)
|
46
|
+
end
|
47
|
+
|
48
|
+
# For Union Types, to_json functionality is delegated to the wrapped member.
|
49
|
+
#
|
50
|
+
# @return [String]
|
51
|
+
def to_json(*_args)
|
52
|
+
case @discriminant
|
53
|
+
when "request-start"
|
54
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
55
|
+
when "request-complete"
|
56
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
57
|
+
when "request-failed"
|
58
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
59
|
+
when "request-response-delayed"
|
60
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
61
|
+
else
|
62
|
+
{ "type": @discriminant, value: @member }.to_json
|
63
|
+
end
|
64
|
+
@member.to_json
|
65
|
+
end
|
66
|
+
|
67
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
68
|
+
# hash and check each fields type against the current object's property
|
69
|
+
# definitions.
|
70
|
+
#
|
71
|
+
# @param obj [Object]
|
72
|
+
# @return [Void]
|
73
|
+
def self.validate_raw(obj:)
|
74
|
+
case obj.type
|
75
|
+
when "request-start"
|
76
|
+
Vapi::ToolMessageStart.validate_raw(obj: obj)
|
77
|
+
when "request-complete"
|
78
|
+
Vapi::ToolMessageComplete.validate_raw(obj: obj)
|
79
|
+
when "request-failed"
|
80
|
+
Vapi::ToolMessageFailed.validate_raw(obj: obj)
|
81
|
+
when "request-response-delayed"
|
82
|
+
Vapi::ToolMessageDelayed.validate_raw(obj: obj)
|
83
|
+
else
|
84
|
+
raise("Passed value matched no type within the union, validation failed.")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# For Union Types, is_a? functionality is delegated to the wrapped member.
|
89
|
+
#
|
90
|
+
# @param obj [Object]
|
91
|
+
# @return [Boolean]
|
92
|
+
def is_a?(obj)
|
93
|
+
@member.is_a?(obj)
|
94
|
+
end
|
95
|
+
|
96
|
+
# @param member [Vapi::ToolMessageStart]
|
97
|
+
# @return [Vapi::ComputerToolWithToolCallMessagesItem]
|
98
|
+
def self.request_start(member:)
|
99
|
+
new(member: member, discriminant: "request-start")
|
100
|
+
end
|
101
|
+
|
102
|
+
# @param member [Vapi::ToolMessageComplete]
|
103
|
+
# @return [Vapi::ComputerToolWithToolCallMessagesItem]
|
104
|
+
def self.request_complete(member:)
|
105
|
+
new(member: member, discriminant: "request-complete")
|
106
|
+
end
|
107
|
+
|
108
|
+
# @param member [Vapi::ToolMessageFailed]
|
109
|
+
# @return [Vapi::ComputerToolWithToolCallMessagesItem]
|
110
|
+
def self.request_failed(member:)
|
111
|
+
new(member: member, discriminant: "request-failed")
|
112
|
+
end
|
113
|
+
|
114
|
+
# @param member [Vapi::ToolMessageDelayed]
|
115
|
+
# @return [Vapi::ComputerToolWithToolCallMessagesItem]
|
116
|
+
def self.request_response_delayed(member:)
|
117
|
+
new(member: member, discriminant: "request-response-delayed")
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -4,12 +4,14 @@ module Vapi
|
|
4
4
|
# This is the region of the Azure resource.
|
5
5
|
class CreateAzureCredentialDtoRegion
|
6
6
|
AUSTRALIA = "australia"
|
7
|
-
|
7
|
+
CANADAEAST = "canadaeast"
|
8
|
+
CANADACENTRAL = "canadacentral"
|
8
9
|
EASTUS_2 = "eastus2"
|
9
10
|
EASTUS = "eastus"
|
10
11
|
FRANCE = "france"
|
11
12
|
INDIA = "india"
|
12
|
-
|
13
|
+
JAPANEAST = "japaneast"
|
14
|
+
JAPANWEST = "japanwest"
|
13
15
|
UAENORTH = "uaenorth"
|
14
16
|
NORTHCENTRALUS = "northcentralus"
|
15
17
|
NORWAY = "norway"
|
@@ -3,12 +3,14 @@
|
|
3
3
|
module Vapi
|
4
4
|
class CreateAzureOpenAiCredentialDtoRegion
|
5
5
|
AUSTRALIA = "australia"
|
6
|
-
|
6
|
+
CANADAEAST = "canadaeast"
|
7
|
+
CANADACENTRAL = "canadacentral"
|
7
8
|
EASTUS_2 = "eastus2"
|
8
9
|
EASTUS = "eastus"
|
9
10
|
FRANCE = "france"
|
10
11
|
INDIA = "india"
|
11
|
-
|
12
|
+
JAPANEAST = "japaneast"
|
13
|
+
JAPANWEST = "japanwest"
|
12
14
|
UAENORTH = "uaenorth"
|
13
15
|
NORTHCENTRALUS = "northcentralus"
|
14
16
|
NORWAY = "norway"
|