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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/lib/requests.rb +2 -2
  3. data/lib/types_export.rb +31 -6
  4. data/lib/vapi_server_sdk/analytics/client.rb +0 -14
  5. data/lib/vapi_server_sdk/assistants/client.rb +4 -70
  6. data/lib/vapi_server_sdk/blocks/client.rb +0 -70
  7. data/lib/vapi_server_sdk/calls/client.rb +6 -70
  8. data/lib/vapi_server_sdk/files/client.rb +0 -70
  9. data/lib/vapi_server_sdk/knowledge_bases/client.rb +0 -70
  10. data/lib/vapi_server_sdk/logs/client.rb +13 -44
  11. data/lib/vapi_server_sdk/logs/types/logging_controller_logs_delete_query_request_type.rb +12 -0
  12. data/lib/vapi_server_sdk/phone_numbers/client.rb +0 -70
  13. data/lib/vapi_server_sdk/squads/client.rb +8 -70
  14. data/lib/vapi_server_sdk/tools/client.rb +0 -70
  15. data/lib/vapi_server_sdk/types/azure_credential_region.rb +4 -2
  16. data/lib/vapi_server_sdk/types/azure_open_ai_credential_region.rb +4 -2
  17. data/lib/vapi_server_sdk/types/bash_tool_with_tool_call.rb +175 -0
  18. data/lib/vapi_server_sdk/types/bash_tool_with_tool_call_messages_item.rb +120 -0
  19. data/lib/vapi_server_sdk/types/client_inbound_message_end_call.rb +47 -0
  20. data/lib/vapi_server_sdk/types/client_inbound_message_message.rb +13 -0
  21. data/lib/vapi_server_sdk/types/client_message_tool_calls_tool_with_tool_call_list_item.rb +116 -77
  22. data/lib/vapi_server_sdk/types/computer_tool_with_tool_call.rb +199 -0
  23. data/lib/vapi_server_sdk/types/computer_tool_with_tool_call_messages_item.rb +120 -0
  24. data/lib/vapi_server_sdk/types/create_azure_credential_dto_region.rb +4 -2
  25. data/lib/vapi_server_sdk/types/create_azure_open_ai_credential_dto_region.rb +4 -2
  26. data/lib/vapi_server_sdk/types/create_custom_knowledge_base_dto.rb +2 -4
  27. data/lib/vapi_server_sdk/types/create_trieve_knowledge_base_dto.rb +34 -47
  28. data/lib/vapi_server_sdk/types/create_trieve_knowledge_base_dto_create_plan.rb +97 -0
  29. data/lib/vapi_server_sdk/types/create_workflow_dto.rb +87 -0
  30. data/lib/vapi_server_sdk/types/create_workflow_dto_nodes_item.rb +81 -0
  31. data/lib/vapi_server_sdk/types/custom_knowledge_base.rb +2 -4
  32. data/lib/vapi_server_sdk/types/edge.rb +80 -0
  33. data/lib/vapi_server_sdk/types/edge_condition.rb +94 -0
  34. data/lib/vapi_server_sdk/types/function_tool_with_tool_call.rb +1 -10
  35. data/lib/vapi_server_sdk/types/gather.rb +87 -0
  36. data/lib/vapi_server_sdk/types/ghl_tool_with_tool_call.rb +1 -9
  37. data/lib/vapi_server_sdk/types/json_schema.rb +13 -2
  38. data/lib/vapi_server_sdk/types/log.rb +18 -18
  39. data/lib/vapi_server_sdk/types/make_tool_with_tool_call.rb +1 -9
  40. data/lib/vapi_server_sdk/types/programmatic_edge_condition.rb +57 -0
  41. data/lib/vapi_server_sdk/types/say.rb +72 -0
  42. data/lib/vapi_server_sdk/types/semantic_edge_condition.rb +57 -0
  43. data/lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb +116 -77
  44. data/lib/vapi_server_sdk/types/subscription.rb +11 -9
  45. data/lib/vapi_server_sdk/types/text_editor_tool_with_tool_call.rb +175 -0
  46. data/lib/vapi_server_sdk/types/text_editor_tool_with_tool_call_messages_item.rb +121 -0
  47. data/lib/vapi_server_sdk/types/trieve_knowledge_base.rb +35 -44
  48. data/lib/vapi_server_sdk/types/{trieve_knowledge_base_vector_store_create_plan.rb → trieve_knowledge_base_chunk_plan.rb} +17 -11
  49. data/lib/vapi_server_sdk/types/trieve_knowledge_base_create.rb +59 -0
  50. data/lib/vapi_server_sdk/types/trieve_knowledge_base_create_plan.rb +96 -0
  51. data/lib/vapi_server_sdk/types/trieve_knowledge_base_import.rb +55 -0
  52. data/lib/vapi_server_sdk/types/{trieve_knowledge_base_vector_store_search_plan.rb → trieve_knowledge_base_search_plan.rb} +9 -11
  53. 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
  54. data/lib/vapi_server_sdk/types/update_azure_credential_dto_region.rb +4 -2
  55. data/lib/vapi_server_sdk/types/update_azure_open_ai_credential_dto_region.rb +4 -2
  56. data/lib/vapi_server_sdk/types/update_custom_knowledge_base_dto.rb +2 -4
  57. data/lib/vapi_server_sdk/types/update_trieve_knowledge_base_dto.rb +34 -47
  58. data/lib/vapi_server_sdk/types/update_trieve_knowledge_base_dto_create_plan.rb +97 -0
  59. data/lib/vapi_server_sdk/types/update_workflow_dto.rb +82 -0
  60. data/lib/vapi_server_sdk/types/update_workflow_dto_nodes_item.rb +81 -0
  61. data/lib/vapi_server_sdk/types/vapi_model.rb +27 -1
  62. data/lib/vapi_server_sdk/types/workflow.rb +125 -0
  63. data/lib/vapi_server_sdk/types/workflow_nodes_item.rb +81 -0
  64. metadata +30 -5
@@ -6,8 +6,7 @@ require "json"
6
6
 
7
7
  module Vapi
8
8
  class CreateCustomKnowledgeBaseDto
9
- # @return [Vapi::Server] /**
10
- # This is where the knowledge base request will be sent.
9
+ # @return [Vapi::Server] This is where the knowledge base request will be sent.
11
10
  # Request Example:
12
11
  # POST https://{server.url}
13
12
  # Content-Type: application/json
@@ -54,8 +53,7 @@ module Vapi
54
53
 
55
54
  OMIT = Object.new
56
55
 
57
- # @param server [Vapi::Server] /**
58
- # This is where the knowledge base request will be sent.
56
+ # @param server [Vapi::Server] This is where the knowledge base request will be sent.
59
57
  # Request Example:
60
58
  # POST https://{server.url}
61
59
  # Content-Type: application/json
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "trieve_knowledge_base_vector_store_search_plan"
4
- require_relative "trieve_knowledge_base_vector_store_create_plan"
3
+ require_relative "trieve_knowledge_base_search_plan"
4
+ require_relative "create_trieve_knowledge_base_dto_create_plan"
5
5
  require "ostruct"
6
6
  require "json"
7
7
 
@@ -9,17 +9,15 @@ module Vapi
9
9
  class CreateTrieveKnowledgeBaseDto
10
10
  # @return [String] This is the name of the knowledge base.
11
11
  attr_reader :name
12
- # @return [Vapi::TrieveKnowledgeBaseVectorStoreSearchPlan] This is the plan on how to search the vector store while a call is going on.
13
- attr_reader :vector_store_search_plan
14
- # @return [Vapi::TrieveKnowledgeBaseVectorStoreCreatePlan] This is the plan if you want us to create a new vector store on your behalf. To
15
- # use an existing vector store from your account, use `vectoreStoreProviderId`
16
- attr_reader :vector_store_create_plan
17
- # @return [String] This is an vector store that you already have on your account with the provider.
18
- # To create a new vector store, use vectorStoreCreatePlan.
19
- # Usage:
20
- # - To bring your own vector store from Trieve, go to https://trieve.ai
21
- # - Create a dataset, and use the datasetId here.
22
- attr_reader :vector_store_provider_id
12
+ # @return [Vapi::TrieveKnowledgeBaseSearchPlan] This is the searching plan used when searching for relevant chunks from the
13
+ # vector store.
14
+ # You should configure this if you're running into these issues:
15
+ # - Too much unnecessary context is being fed as knowledge base context.
16
+ # - Not enough relevant context is being fed as knowledge base context.
17
+ attr_reader :search_plan
18
+ # @return [Vapi::CreateTrieveKnowledgeBaseDtoCreatePlan] This is the plan if you want us to create/import a new vector store using
19
+ # Trieve.
20
+ attr_reader :create_plan
23
21
  # @return [OpenStruct] Additional properties unmapped to the current class definition
24
22
  attr_reader :additional_properties
25
23
  # @return [Object]
@@ -29,29 +27,21 @@ module Vapi
29
27
  OMIT = Object.new
30
28
 
31
29
  # @param name [String] This is the name of the knowledge base.
32
- # @param vector_store_search_plan [Vapi::TrieveKnowledgeBaseVectorStoreSearchPlan] This is the plan on how to search the vector store while a call is going on.
33
- # @param vector_store_create_plan [Vapi::TrieveKnowledgeBaseVectorStoreCreatePlan] This is the plan if you want us to create a new vector store on your behalf. To
34
- # use an existing vector store from your account, use `vectoreStoreProviderId`
35
- # @param vector_store_provider_id [String] This is an vector store that you already have on your account with the provider.
36
- # To create a new vector store, use vectorStoreCreatePlan.
37
- # Usage:
38
- # - To bring your own vector store from Trieve, go to https://trieve.ai
39
- # - Create a dataset, and use the datasetId here.
30
+ # @param search_plan [Vapi::TrieveKnowledgeBaseSearchPlan] This is the searching plan used when searching for relevant chunks from the
31
+ # vector store.
32
+ # You should configure this if you're running into these issues:
33
+ # - Too much unnecessary context is being fed as knowledge base context.
34
+ # - Not enough relevant context is being fed as knowledge base context.
35
+ # @param create_plan [Vapi::CreateTrieveKnowledgeBaseDtoCreatePlan] This is the plan if you want us to create/import a new vector store using
36
+ # Trieve.
40
37
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
41
38
  # @return [Vapi::CreateTrieveKnowledgeBaseDto]
42
- def initialize(vector_store_search_plan:, name: OMIT, vector_store_create_plan: OMIT,
43
- vector_store_provider_id: OMIT, additional_properties: nil)
39
+ def initialize(name: OMIT, search_plan: OMIT, create_plan: OMIT, additional_properties: nil)
44
40
  @name = name if name != OMIT
45
- @vector_store_search_plan = vector_store_search_plan
46
- @vector_store_create_plan = vector_store_create_plan if vector_store_create_plan != OMIT
47
- @vector_store_provider_id = vector_store_provider_id if vector_store_provider_id != OMIT
41
+ @search_plan = search_plan if search_plan != OMIT
42
+ @create_plan = create_plan if create_plan != OMIT
48
43
  @additional_properties = additional_properties
49
- @_field_set = {
50
- "name": name,
51
- "vectorStoreSearchPlan": vector_store_search_plan,
52
- "vectorStoreCreatePlan": vector_store_create_plan,
53
- "vectorStoreProviderId": vector_store_provider_id
54
- }.reject do |_k, v|
44
+ @_field_set = { "name": name, "searchPlan": search_plan, "createPlan": create_plan }.reject do |_k, v|
55
45
  v == OMIT
56
46
  end
57
47
  end
@@ -64,24 +54,22 @@ module Vapi
64
54
  struct = JSON.parse(json_object, object_class: OpenStruct)
65
55
  parsed_json = JSON.parse(json_object)
66
56
  name = parsed_json["name"]
67
- if parsed_json["vectorStoreSearchPlan"].nil?
68
- vector_store_search_plan = nil
57
+ if parsed_json["searchPlan"].nil?
58
+ search_plan = nil
69
59
  else
70
- vector_store_search_plan = parsed_json["vectorStoreSearchPlan"].to_json
71
- vector_store_search_plan = Vapi::TrieveKnowledgeBaseVectorStoreSearchPlan.from_json(json_object: vector_store_search_plan)
60
+ search_plan = parsed_json["searchPlan"].to_json
61
+ search_plan = Vapi::TrieveKnowledgeBaseSearchPlan.from_json(json_object: search_plan)
72
62
  end
73
- if parsed_json["vectorStoreCreatePlan"].nil?
74
- vector_store_create_plan = nil
63
+ if parsed_json["createPlan"].nil?
64
+ create_plan = nil
75
65
  else
76
- vector_store_create_plan = parsed_json["vectorStoreCreatePlan"].to_json
77
- vector_store_create_plan = Vapi::TrieveKnowledgeBaseVectorStoreCreatePlan.from_json(json_object: vector_store_create_plan)
66
+ create_plan = parsed_json["createPlan"].to_json
67
+ create_plan = Vapi::CreateTrieveKnowledgeBaseDtoCreatePlan.from_json(json_object: create_plan)
78
68
  end
79
- vector_store_provider_id = parsed_json["vectorStoreProviderId"]
80
69
  new(
81
70
  name: name,
82
- vector_store_search_plan: vector_store_search_plan,
83
- vector_store_create_plan: vector_store_create_plan,
84
- vector_store_provider_id: vector_store_provider_id,
71
+ search_plan: search_plan,
72
+ create_plan: create_plan,
85
73
  additional_properties: struct
86
74
  )
87
75
  end
@@ -101,9 +89,8 @@ module Vapi
101
89
  # @return [Void]
102
90
  def self.validate_raw(obj:)
103
91
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
104
- Vapi::TrieveKnowledgeBaseVectorStoreSearchPlan.validate_raw(obj: obj.vector_store_search_plan)
105
- obj.vector_store_create_plan.nil? || Vapi::TrieveKnowledgeBaseVectorStoreCreatePlan.validate_raw(obj: obj.vector_store_create_plan)
106
- obj.vector_store_provider_id&.is_a?(String) != false || raise("Passed value for field obj.vector_store_provider_id is not the expected type, validation failed.")
92
+ obj.search_plan.nil? || Vapi::TrieveKnowledgeBaseSearchPlan.validate_raw(obj: obj.search_plan)
93
+ obj.create_plan.nil? || Vapi::CreateTrieveKnowledgeBaseDtoCreatePlan.validate_raw(obj: obj.create_plan)
107
94
  end
108
95
  end
109
96
  end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "trieve_knowledge_base_create"
5
+ require_relative "trieve_knowledge_base_import"
6
+
7
+ module Vapi
8
+ # This is the plan if you want us to create/import a new vector store using
9
+ # Trieve.
10
+ class CreateTrieveKnowledgeBaseDtoCreatePlan
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::CreateTrieveKnowledgeBaseDtoCreatePlan]
22
+ def initialize(member:, discriminant:)
23
+ @member = member
24
+ @discriminant = discriminant
25
+ end
26
+
27
+ # Deserialize a JSON object to an instance of
28
+ # CreateTrieveKnowledgeBaseDtoCreatePlan
29
+ #
30
+ # @param json_object [String]
31
+ # @return [Vapi::CreateTrieveKnowledgeBaseDtoCreatePlan]
32
+ def self.from_json(json_object:)
33
+ struct = JSON.parse(json_object, object_class: OpenStruct)
34
+ member = case struct.type
35
+ when "create"
36
+ Vapi::TrieveKnowledgeBaseCreate.from_json(json_object: json_object)
37
+ when "import"
38
+ Vapi::TrieveKnowledgeBaseImport.from_json(json_object: json_object)
39
+ else
40
+ Vapi::TrieveKnowledgeBaseCreate.from_json(json_object: json_object)
41
+ end
42
+ new(member: member, discriminant: struct.type)
43
+ end
44
+
45
+ # For Union Types, to_json functionality is delegated to the wrapped member.
46
+ #
47
+ # @return [String]
48
+ def to_json(*_args)
49
+ case @discriminant
50
+ when "create"
51
+ { **@member.to_json, type: @discriminant }.to_json
52
+ when "import"
53
+ { **@member.to_json, type: @discriminant }.to_json
54
+ else
55
+ { "type": @discriminant, value: @member }.to_json
56
+ end
57
+ @member.to_json
58
+ end
59
+
60
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
61
+ # hash and check each fields type against the current object's property
62
+ # definitions.
63
+ #
64
+ # @param obj [Object]
65
+ # @return [Void]
66
+ def self.validate_raw(obj:)
67
+ case obj.type
68
+ when "create"
69
+ Vapi::TrieveKnowledgeBaseCreate.validate_raw(obj: obj)
70
+ when "import"
71
+ Vapi::TrieveKnowledgeBaseImport.validate_raw(obj: obj)
72
+ else
73
+ raise("Passed value matched no type within the union, validation failed.")
74
+ end
75
+ end
76
+
77
+ # For Union Types, is_a? functionality is delegated to the wrapped member.
78
+ #
79
+ # @param obj [Object]
80
+ # @return [Boolean]
81
+ def is_a?(obj)
82
+ @member.is_a?(obj)
83
+ end
84
+
85
+ # @param member [Vapi::TrieveKnowledgeBaseCreate]
86
+ # @return [Vapi::CreateTrieveKnowledgeBaseDtoCreatePlan]
87
+ def self.create(member:)
88
+ new(member: member, discriminant: "create")
89
+ end
90
+
91
+ # @param member [Vapi::TrieveKnowledgeBaseImport]
92
+ # @return [Vapi::CreateTrieveKnowledgeBaseDtoCreatePlan]
93
+ def self.import(member:)
94
+ new(member: member, discriminant: "import")
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "create_workflow_dto_nodes_item"
4
+ require_relative "edge"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module Vapi
9
+ class CreateWorkflowDto
10
+ # @return [String]
11
+ attr_reader :type
12
+ # @return [Array<Vapi::CreateWorkflowDtoNodesItem>]
13
+ attr_reader :nodes
14
+ # @return [String]
15
+ attr_reader :name
16
+ # @return [Array<Vapi::Edge>]
17
+ attr_reader :edges
18
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
19
+ attr_reader :additional_properties
20
+ # @return [Object]
21
+ attr_reader :_field_set
22
+ protected :_field_set
23
+
24
+ OMIT = Object.new
25
+
26
+ # @param type [String]
27
+ # @param nodes [Array<Vapi::CreateWorkflowDtoNodesItem>]
28
+ # @param name [String]
29
+ # @param edges [Array<Vapi::Edge>]
30
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
31
+ # @return [Vapi::CreateWorkflowDto]
32
+ def initialize(type:, nodes:, name:, edges:, additional_properties: nil)
33
+ @type = type
34
+ @nodes = nodes
35
+ @name = name
36
+ @edges = edges
37
+ @additional_properties = additional_properties
38
+ @_field_set = { "type": type, "nodes": nodes, "name": name, "edges": edges }
39
+ end
40
+
41
+ # Deserialize a JSON object to an instance of CreateWorkflowDto
42
+ #
43
+ # @param json_object [String]
44
+ # @return [Vapi::CreateWorkflowDto]
45
+ def self.from_json(json_object:)
46
+ struct = JSON.parse(json_object, object_class: OpenStruct)
47
+ parsed_json = JSON.parse(json_object)
48
+ type = parsed_json["type"]
49
+ nodes = parsed_json["nodes"]&.map do |item|
50
+ item = item.to_json
51
+ Vapi::CreateWorkflowDtoNodesItem.from_json(json_object: item)
52
+ end
53
+ name = parsed_json["name"]
54
+ edges = parsed_json["edges"]&.map do |item|
55
+ item = item.to_json
56
+ Vapi::Edge.from_json(json_object: item)
57
+ end
58
+ new(
59
+ type: type,
60
+ nodes: nodes,
61
+ name: name,
62
+ edges: edges,
63
+ additional_properties: struct
64
+ )
65
+ end
66
+
67
+ # Serialize an instance of CreateWorkflowDto to a JSON object
68
+ #
69
+ # @return [String]
70
+ def to_json(*_args)
71
+ @_field_set&.to_json
72
+ end
73
+
74
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
75
+ # hash and check each fields type against the current object's property
76
+ # definitions.
77
+ #
78
+ # @param obj [Object]
79
+ # @return [Void]
80
+ def self.validate_raw(obj:)
81
+ obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
82
+ obj.nodes.is_a?(Array) != false || raise("Passed value for field obj.nodes is not the expected type, validation failed.")
83
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
84
+ obj.edges.is_a?(Array) != false || raise("Passed value for field obj.edges is not the expected type, validation failed.")
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "say"
5
+ require_relative "gather"
6
+ require_relative "create_workflow_dto"
7
+
8
+ module Vapi
9
+ class CreateWorkflowDtoNodesItem
10
+ # Deserialize a JSON object to an instance of CreateWorkflowDtoNodesItem
11
+ #
12
+ # @param json_object [String]
13
+ # @return [Vapi::CreateWorkflowDtoNodesItem]
14
+ def self.from_json(json_object:)
15
+ struct = JSON.parse(json_object, object_class: OpenStruct)
16
+ begin
17
+ Vapi::Say.validate_raw(obj: struct)
18
+ return Vapi::Say.from_json(json_object: struct) unless struct.nil?
19
+
20
+ return nil
21
+ rescue StandardError
22
+ # noop
23
+ end
24
+ begin
25
+ Vapi::Gather.validate_raw(obj: struct)
26
+ return Vapi::Gather.from_json(json_object: struct) unless struct.nil?
27
+
28
+ return nil
29
+ rescue StandardError
30
+ # noop
31
+ end
32
+ begin
33
+ struct.is_a?(Object) != false || raise("Passed value for field struct is not the expected type, validation failed.")
34
+ return struct unless struct.nil?
35
+
36
+ return nil
37
+ rescue StandardError
38
+ # noop
39
+ end
40
+ begin
41
+ Vapi::CreateWorkflowDto.validate_raw(obj: struct)
42
+ return Vapi::CreateWorkflowDto.from_json(json_object: struct) unless struct.nil?
43
+
44
+ return nil
45
+ rescue StandardError
46
+ # noop
47
+ end
48
+ struct
49
+ end
50
+
51
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
52
+ # hash and check each fields type against the current object's property
53
+ # definitions.
54
+ #
55
+ # @param obj [Object]
56
+ # @return [Void]
57
+ def self.validate_raw(obj:)
58
+ begin
59
+ return Vapi::Say.validate_raw(obj: obj)
60
+ rescue StandardError
61
+ # noop
62
+ end
63
+ begin
64
+ return Vapi::Gather.validate_raw(obj: obj)
65
+ rescue StandardError
66
+ # noop
67
+ end
68
+ begin
69
+ return obj.is_a?(Object) != false || raise("Passed value for field obj is not the expected type, validation failed.")
70
+ rescue StandardError
71
+ # noop
72
+ end
73
+ begin
74
+ return Vapi::CreateWorkflowDto.validate_raw(obj: obj)
75
+ rescue StandardError
76
+ # noop
77
+ end
78
+ raise("Passed value matched no type within the union, validation failed.")
79
+ end
80
+ end
81
+ end
@@ -6,8 +6,7 @@ require "json"
6
6
 
7
7
  module Vapi
8
8
  class CustomKnowledgeBase
9
- # @return [Vapi::Server] /**
10
- # This is where the knowledge base request will be sent.
9
+ # @return [Vapi::Server] This is where the knowledge base request will be sent.
11
10
  # Request Example:
12
11
  # POST https://{server.url}
13
12
  # Content-Type: application/json
@@ -58,8 +57,7 @@ module Vapi
58
57
 
59
58
  OMIT = Object.new
60
59
 
61
- # @param server [Vapi::Server] /**
62
- # This is where the knowledge base request will be sent.
60
+ # @param server [Vapi::Server] This is where the knowledge base request will be sent.
63
61
  # Request Example:
64
62
  # POST https://{server.url}
65
63
  # Content-Type: application/json
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "edge_condition"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module Vapi
8
+ class Edge
9
+ # @return [Vapi::EdgeCondition]
10
+ attr_reader :condition
11
+ # @return [String]
12
+ attr_reader :from
13
+ # @return [String]
14
+ attr_reader :to
15
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
16
+ attr_reader :additional_properties
17
+ # @return [Object]
18
+ attr_reader :_field_set
19
+ protected :_field_set
20
+
21
+ OMIT = Object.new
22
+
23
+ # @param condition [Vapi::EdgeCondition]
24
+ # @param from [String]
25
+ # @param to [String]
26
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
27
+ # @return [Vapi::Edge]
28
+ def initialize(from:, to:, condition: OMIT, additional_properties: nil)
29
+ @condition = condition if condition != OMIT
30
+ @from = from
31
+ @to = to
32
+ @additional_properties = additional_properties
33
+ @_field_set = { "condition": condition, "from": from, "to": to }.reject do |_k, v|
34
+ v == OMIT
35
+ end
36
+ end
37
+
38
+ # Deserialize a JSON object to an instance of Edge
39
+ #
40
+ # @param json_object [String]
41
+ # @return [Vapi::Edge]
42
+ def self.from_json(json_object:)
43
+ struct = JSON.parse(json_object, object_class: OpenStruct)
44
+ parsed_json = JSON.parse(json_object)
45
+ if parsed_json["condition"].nil?
46
+ condition = nil
47
+ else
48
+ condition = parsed_json["condition"].to_json
49
+ condition = Vapi::EdgeCondition.from_json(json_object: condition)
50
+ end
51
+ from = parsed_json["from"]
52
+ to = parsed_json["to"]
53
+ new(
54
+ condition: condition,
55
+ from: from,
56
+ to: to,
57
+ additional_properties: struct
58
+ )
59
+ end
60
+
61
+ # Serialize an instance of Edge to a JSON object
62
+ #
63
+ # @return [String]
64
+ def to_json(*_args)
65
+ @_field_set&.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
+ obj.condition.nil? || Vapi::EdgeCondition.validate_raw(obj: obj.condition)
76
+ obj.from.is_a?(String) != false || raise("Passed value for field obj.from is not the expected type, validation failed.")
77
+ obj.to.is_a?(String) != false || raise("Passed value for field obj.to is not the expected type, validation failed.")
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "semantic_edge_condition"
5
+ require_relative "programmatic_edge_condition"
6
+
7
+ module Vapi
8
+ class EdgeCondition
9
+ # @return [Object]
10
+ attr_reader :member
11
+ # @return [String]
12
+ attr_reader :discriminant
13
+
14
+ private_class_method :new
15
+ alias kind_of? is_a?
16
+
17
+ # @param member [Object]
18
+ # @param discriminant [String]
19
+ # @return [Vapi::EdgeCondition]
20
+ def initialize(member:, discriminant:)
21
+ @member = member
22
+ @discriminant = discriminant
23
+ end
24
+
25
+ # Deserialize a JSON object to an instance of EdgeCondition
26
+ #
27
+ # @param json_object [String]
28
+ # @return [Vapi::EdgeCondition]
29
+ def self.from_json(json_object:)
30
+ struct = JSON.parse(json_object, object_class: OpenStruct)
31
+ member = case struct.type
32
+ when "semantic"
33
+ Vapi::SemanticEdgeCondition.from_json(json_object: json_object)
34
+ when "programmatic"
35
+ Vapi::ProgrammaticEdgeCondition.from_json(json_object: json_object)
36
+ else
37
+ Vapi::SemanticEdgeCondition.from_json(json_object: json_object)
38
+ end
39
+ new(member: member, discriminant: struct.type)
40
+ end
41
+
42
+ # For Union Types, to_json functionality is delegated to the wrapped member.
43
+ #
44
+ # @return [String]
45
+ def to_json(*_args)
46
+ case @discriminant
47
+ when "semantic"
48
+ { **@member.to_json, type: @discriminant }.to_json
49
+ when "programmatic"
50
+ { **@member.to_json, type: @discriminant }.to_json
51
+ else
52
+ { "type": @discriminant, value: @member }.to_json
53
+ end
54
+ @member.to_json
55
+ end
56
+
57
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
58
+ # hash and check each fields type against the current object's property
59
+ # definitions.
60
+ #
61
+ # @param obj [Object]
62
+ # @return [Void]
63
+ def self.validate_raw(obj:)
64
+ case obj.type
65
+ when "semantic"
66
+ Vapi::SemanticEdgeCondition.validate_raw(obj: obj)
67
+ when "programmatic"
68
+ Vapi::ProgrammaticEdgeCondition.validate_raw(obj: obj)
69
+ else
70
+ raise("Passed value matched no type within the union, validation failed.")
71
+ end
72
+ end
73
+
74
+ # For Union Types, is_a? functionality is delegated to the wrapped member.
75
+ #
76
+ # @param obj [Object]
77
+ # @return [Boolean]
78
+ def is_a?(obj)
79
+ @member.is_a?(obj)
80
+ end
81
+
82
+ # @param member [Vapi::SemanticEdgeCondition]
83
+ # @return [Vapi::EdgeCondition]
84
+ def self.semantic(member:)
85
+ new(member: member, discriminant: "semantic")
86
+ end
87
+
88
+ # @param member [Vapi::ProgrammaticEdgeCondition]
89
+ # @return [Vapi::EdgeCondition]
90
+ def self.programmatic(member:)
91
+ new(member: member, discriminant: "programmatic")
92
+ end
93
+ end
94
+ end
@@ -21,8 +21,6 @@ module Vapi
21
21
  # `tool.destinations`. For others like the function tool, these can be custom
22
22
  # configured.
23
23
  attr_reader :messages
24
- # @return [String] The type of tool. "function" for Function tool.
25
- attr_reader :type
26
24
  # @return [Vapi::ToolCall]
27
25
  attr_reader :tool_call
28
26
  # @return [Vapi::OpenAiFunction] This is the function definition of the tool.
@@ -60,7 +58,6 @@ module Vapi
60
58
  # For some tools, this is auto-filled based on special fields like
61
59
  # `tool.destinations`. For others like the function tool, these can be custom
62
60
  # configured.
63
- # @param type [String] The type of tool. "function" for Function tool.
64
61
  # @param tool_call [Vapi::ToolCall]
65
62
  # @param function [Vapi::OpenAiFunction] This is the function definition of the tool.
66
63
  # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on
@@ -79,11 +76,9 @@ module Vapi
79
76
  # phoneNumber.serverUrl, then org.serverUrl.
80
77
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
81
78
  # @return [Vapi::FunctionToolWithToolCall]
82
- def initialize(type:, tool_call:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT,
83
- additional_properties: nil)
79
+ def initialize(tool_call:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil)
84
80
  @async = async if async != OMIT
85
81
  @messages = messages if messages != OMIT
86
- @type = type
87
82
  @tool_call = tool_call
88
83
  @function = function if function != OMIT
89
84
  @server = server if server != OMIT
@@ -91,7 +86,6 @@ module Vapi
91
86
  @_field_set = {
92
87
  "async": async,
93
88
  "messages": messages,
94
- "type": type,
95
89
  "toolCall": tool_call,
96
90
  "function": function,
97
91
  "server": server
@@ -112,7 +106,6 @@ module Vapi
112
106
  item = item.to_json
113
107
  Vapi::FunctionToolWithToolCallMessagesItem.from_json(json_object: item)
114
108
  end
115
- type = parsed_json["type"]
116
109
  if parsed_json["toolCall"].nil?
117
110
  tool_call = nil
118
111
  else
@@ -134,7 +127,6 @@ module Vapi
134
127
  new(
135
128
  async: async,
136
129
  messages: messages,
137
- type: type,
138
130
  tool_call: tool_call,
139
131
  function: function,
140
132
  server: server,
@@ -158,7 +150,6 @@ module Vapi
158
150
  def self.validate_raw(obj:)
159
151
  obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.")
160
152
  obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.")
161
- obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
162
153
  Vapi::ToolCall.validate_raw(obj: obj.tool_call)
163
154
  obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function)
164
155
  obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server)