Class: Vapi::XaiModel

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, knowledge_base: OMIT, knowledge_base_id: OMIT, temperature: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) ⇒ Vapi::XaiModel



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
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 80

def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, knowledge_base: OMIT, knowledge_base_id: OMIT,
               temperature: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil)
  @messages = messages if messages != OMIT
  @tools = tools if tools != OMIT
  @tool_ids = tool_ids if tool_ids != OMIT
  @knowledge_base = knowledge_base if knowledge_base != OMIT
  @knowledge_base_id = knowledge_base_id if knowledge_base_id != OMIT
  @model = model
  @temperature = temperature if temperature != OMIT
  @max_tokens = max_tokens if max_tokens != OMIT
  @emotion_recognition_enabled = emotion_recognition_enabled if emotion_recognition_enabled != OMIT
  @num_fast_turns = num_fast_turns if num_fast_turns != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "messages": messages,
    "tools": tools,
    "toolIds": tool_ids,
    "knowledgeBase": knowledge_base,
    "knowledgeBaseId": knowledge_base_id,
    "model": model,
    "temperature": temperature,
    "maxTokens": max_tokens,
    "emotionRecognitionEnabled": emotion_recognition_enabled,
    "numFastTurns": num_fast_turns
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



47
48
49
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 47

def additional_properties
  @additional_properties
end

#emotion_recognition_enabledBoolean (readonly)



39
40
41
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 39

def emotion_recognition_enabled
  @emotion_recognition_enabled
end

#knowledge_baseVapi::CreateCustomKnowledgeBaseDto (readonly)



23
24
25
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 23

def knowledge_base
  @knowledge_base
end

#knowledge_base_idString (readonly)



25
26
27
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 25

def knowledge_base_id
  @knowledge_base_id
end

#max_tokensFloat (readonly)



33
34
35
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 33

def max_tokens
  @max_tokens
end

#messagesArray<Vapi::OpenAiMessage> (readonly)



13
14
15
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 13

def messages
  @messages
end

#modelVapi::XaiModelModel (readonly)



27
28
29
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 27

def model
  @model
end

#num_fast_turnsFloat (readonly)



45
46
47
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 45

def num_fast_turns
  @num_fast_turns
end

#temperatureFloat (readonly)



30
31
32
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 30

def temperature
  @temperature
end

#tool_idsArray<String> (readonly)



21
22
23
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 21

def tool_ids
  @tool_ids
end

#toolsArray<Vapi::XaiModelToolsItem> (readonly)



17
18
19
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 17

def tools
  @tools
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::XaiModel

Deserialize a JSON object to an instance of XaiModel



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 113

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  messages = parsed_json["messages"]&.map do |item|
    item = item.to_json
    Vapi::OpenAiMessage.from_json(json_object: item)
  end
  tools = parsed_json["tools"]&.map do |item|
    item = item.to_json
    Vapi::XaiModelToolsItem.from_json(json_object: item)
  end
  tool_ids = parsed_json["toolIds"]
  if parsed_json["knowledgeBase"].nil?
    knowledge_base = nil
  else
    knowledge_base = parsed_json["knowledgeBase"].to_json
    knowledge_base = Vapi::CreateCustomKnowledgeBaseDto.from_json(json_object: knowledge_base)
  end
  knowledge_base_id = parsed_json["knowledgeBaseId"]
  model = parsed_json["model"]
  temperature = parsed_json["temperature"]
  max_tokens = parsed_json["maxTokens"]
  emotion_recognition_enabled = parsed_json["emotionRecognitionEnabled"]
  num_fast_turns = parsed_json["numFastTurns"]
  new(
    messages: messages,
    tools: tools,
    tool_ids: tool_ids,
    knowledge_base: knowledge_base,
    knowledge_base_id: knowledge_base_id,
    model: model,
    temperature: temperature,
    max_tokens: max_tokens,
    emotion_recognition_enabled: emotion_recognition_enabled,
    num_fast_turns: num_fast_turns,
    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.


165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 165

def self.validate_raw(obj:)
  obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.")
  obj.tools&.is_a?(Array) != false || raise("Passed value for field obj.tools is not the expected type, validation failed.")
  obj.tool_ids&.is_a?(Array) != false || raise("Passed value for field obj.tool_ids is not the expected type, validation failed.")
  obj.knowledge_base.nil? || Vapi::CreateCustomKnowledgeBaseDto.validate_raw(obj: obj.knowledge_base)
  obj.knowledge_base_id&.is_a?(String) != false || raise("Passed value for field obj.knowledge_base_id is not the expected type, validation failed.")
  obj.model.is_a?(Vapi::XaiModelModel) != false || raise("Passed value for field obj.model is not the expected type, validation failed.")
  obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.")
  obj.max_tokens&.is_a?(Float) != false || raise("Passed value for field obj.max_tokens is not the expected type, validation failed.")
  obj.emotion_recognition_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.emotion_recognition_enabled is not the expected type, validation failed.")
  obj.num_fast_turns&.is_a?(Float) != false || raise("Passed value for field obj.num_fast_turns is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of XaiModel to a JSON object



155
156
157
# File 'lib/vapi_server_sdk/types/xai_model.rb', line 155

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