Class: Vapi::OpenAiWebChatRequest
- Inherits:
-
Object
- Object
- Vapi::OpenAiWebChatRequest
- Defined in:
- lib/vapi_server_sdk/types/open_ai_web_chat_request.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#assistant_id ⇒ String
readonly
The assistant ID to use for this chat.
-
#assistant_overrides ⇒ Vapi::ChatAssistantOverrides
readonly
These are the variable values that will be used to replace template variables in the assistant messages.
-
#customer ⇒ Vapi::CreateWebCustomerDto
readonly
This is the customer information for the chat.
-
#input ⇒ Vapi::OpenAiWebChatRequestInput
readonly
This is the input text for the chat.
-
#session_id ⇒ String
readonly
This is the ID of the session that will be used for the chat.
-
#stream ⇒ Boolean
readonly
Whether to stream the response or not.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::OpenAiWebChatRequest
Deserialize a JSON object to an instance of OpenAiWebChatRequest.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(assistant_id:, input:, session_id: OMIT, assistant_overrides: OMIT, customer: OMIT, stream: OMIT, additional_properties: nil) ⇒ Vapi::OpenAiWebChatRequest constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of OpenAiWebChatRequest to a JSON object.
Constructor Details
#initialize(assistant_id:, input:, session_id: OMIT, assistant_overrides: OMIT, customer: OMIT, stream: OMIT, additional_properties: nil) ⇒ Vapi::OpenAiWebChatRequest
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/vapi_server_sdk/types/open_ai_web_chat_request.rb', line 53 def initialize(assistant_id:, input:, session_id: OMIT, assistant_overrides: OMIT, customer: OMIT, stream: OMIT, additional_properties: nil) @assistant_id = assistant_id @session_id = session_id if session_id != OMIT @assistant_overrides = assistant_overrides if assistant_overrides != OMIT @customer = customer if customer != OMIT @input = input @stream = stream if stream != OMIT @additional_properties = additional_properties @_field_set = { "assistantId": assistant_id, "sessionId": session_id, "assistantOverrides": assistant_overrides, "customer": customer, "input": input, "stream": stream }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
31 32 33 |
# File 'lib/vapi_server_sdk/types/open_ai_web_chat_request.rb', line 31 def additional_properties @additional_properties end |
#assistant_id ⇒ String (readonly)
Returns The assistant ID to use for this chat.
12 13 14 |
# File 'lib/vapi_server_sdk/types/open_ai_web_chat_request.rb', line 12 def assistant_id @assistant_id end |
#assistant_overrides ⇒ Vapi::ChatAssistantOverrides (readonly)
Returns These are the variable values that will be used to replace template variables in the assistant messages. Only variable substitution is supported in web chat - other assistant properties cannot be overridden.
21 22 23 |
# File 'lib/vapi_server_sdk/types/open_ai_web_chat_request.rb', line 21 def assistant_overrides @assistant_overrides end |
#customer ⇒ Vapi::CreateWebCustomerDto (readonly)
Returns This is the customer information for the chat. Used to automatically manage sessions for repeat customers.
24 25 26 |
# File 'lib/vapi_server_sdk/types/open_ai_web_chat_request.rb', line 24 def customer @customer end |
#input ⇒ Vapi::OpenAiWebChatRequestInput (readonly)
Returns This is the input text for the chat. Can be a string or an array of chat messages.
27 28 29 |
# File 'lib/vapi_server_sdk/types/open_ai_web_chat_request.rb', line 27 def input @input end |
#session_id ⇒ String (readonly)
Returns This is the ID of the session that will be used for the chat. If provided, the conversation will continue from the previous state. If not provided or expired, a new session will be created.
16 17 18 |
# File 'lib/vapi_server_sdk/types/open_ai_web_chat_request.rb', line 16 def session_id @session_id end |
#stream ⇒ Boolean (readonly)
Returns Whether to stream the response or not.
29 30 31 |
# File 'lib/vapi_server_sdk/types/open_ai_web_chat_request.rb', line 29 def stream @stream end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::OpenAiWebChatRequest
Deserialize a JSON object to an instance of OpenAiWebChatRequest
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/vapi_server_sdk/types/open_ai_web_chat_request.rb', line 78 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) assistant_id = parsed_json["assistantId"] session_id = parsed_json["sessionId"] if parsed_json["assistantOverrides"].nil? assistant_overrides = nil else assistant_overrides = parsed_json["assistantOverrides"].to_json assistant_overrides = Vapi::ChatAssistantOverrides.from_json(json_object: assistant_overrides) end if parsed_json["customer"].nil? customer = nil else customer = parsed_json["customer"].to_json customer = Vapi::CreateWebCustomerDto.from_json(json_object: customer) end if parsed_json["input"].nil? input = nil else input = parsed_json["input"].to_json input = Vapi::OpenAiWebChatRequestInput.from_json(json_object: input) end stream = parsed_json["stream"] new( assistant_id: assistant_id, session_id: session_id, assistant_overrides: assistant_overrides, customer: customer, input: input, stream: stream, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
126 127 128 129 130 131 132 133 |
# File 'lib/vapi_server_sdk/types/open_ai_web_chat_request.rb', line 126 def self.validate_raw(obj:) obj.assistant_id.is_a?(String) != false || raise("Passed value for field obj.assistant_id is not the expected type, validation failed.") obj.session_id&.is_a?(String) != false || raise("Passed value for field obj.session_id is not the expected type, validation failed.") obj.assistant_overrides.nil? || Vapi::ChatAssistantOverrides.validate_raw(obj: obj.assistant_overrides) obj.customer.nil? || Vapi::CreateWebCustomerDto.validate_raw(obj: obj.customer) Vapi::OpenAiWebChatRequestInput.validate_raw(obj: obj.input) obj.stream&.is_a?(Boolean) != false || raise("Passed value for field obj.stream is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of OpenAiWebChatRequest to a JSON object
116 117 118 |
# File 'lib/vapi_server_sdk/types/open_ai_web_chat_request.rb', line 116 def to_json(*_args) @_field_set&.to_json end |