Class: Vapi::ServerMessageResponseKnowledgeBaseRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/server_message_response_knowledge_base_request.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(documents: OMIT, message: OMIT, additional_properties: nil) ⇒ Vapi::ServerMessageResponseKnowledgeBaseRequest

Parameters:

  • documents (Array<Vapi::KnowledgeBaseResponseDocument>) (defaults to: OMIT)

    This is the list of documents that will be sent to the model alongside the ‘messages` to generate a response.

  • message (Vapi::CustomMessage) (defaults to: OMIT)

    This can be used to skip the model output generation and speak a custom message.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



28
29
30
31
32
33
34
35
# File 'lib/vapi_server_sdk/types/server_message_response_knowledge_base_request.rb', line 28

def initialize(documents: OMIT, message: OMIT, additional_properties: nil)
  @documents = documents if documents != OMIT
  @message = message if message != OMIT
  @additional_properties = additional_properties
  @_field_set = { "documents": documents, "message": message }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



16
17
18
# File 'lib/vapi_server_sdk/types/server_message_response_knowledge_base_request.rb', line 16

def additional_properties
  @additional_properties
end

#documentsArray<Vapi::KnowledgeBaseResponseDocument> (readonly)

Returns This is the list of documents that will be sent to the model alongside the ‘messages` to generate a response.

Returns:



12
13
14
# File 'lib/vapi_server_sdk/types/server_message_response_knowledge_base_request.rb', line 12

def documents
  @documents
end

#messageVapi::CustomMessage (readonly)

Returns This can be used to skip the model output generation and speak a custom message.

Returns:

  • (Vapi::CustomMessage)

    This can be used to skip the model output generation and speak a custom message.



14
15
16
# File 'lib/vapi_server_sdk/types/server_message_response_knowledge_base_request.rb', line 14

def message
  @message
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ServerMessageResponseKnowledgeBaseRequest

Deserialize a JSON object to an instance of

ServerMessageResponseKnowledgeBaseRequest

Parameters:

  • json_object (String)

Returns:



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/vapi_server_sdk/types/server_message_response_knowledge_base_request.rb', line 42

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  documents = parsed_json["documents"]&.map do |item|
    item = item.to_json
    Vapi::KnowledgeBaseResponseDocument.from_json(json_object: item)
  end
  if parsed_json["message"].nil?
    message = nil
  else
    message = parsed_json["message"].to_json
    message = Vapi::CustomMessage.from_json(json_object: message)
  end
  new(
    documents: documents,
    message: message,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


76
77
78
79
# File 'lib/vapi_server_sdk/types/server_message_response_knowledge_base_request.rb', line 76

def self.validate_raw(obj:)
  obj.documents&.is_a?(Array) != false || raise("Passed value for field obj.documents is not the expected type, validation failed.")
  obj.message.nil? || Vapi::CustomMessage.validate_raw(obj: obj.message)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ServerMessageResponseKnowledgeBaseRequest to a JSON

object

Returns:

  • (String)


66
67
68
# File 'lib/vapi_server_sdk/types/server_message_response_knowledge_base_request.rb', line 66

def to_json(*_args)
  @_field_set&.to_json
end