Class: Vapi::AnyscaleModel

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/anyscale_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, temperature: OMIT, knowledge_base: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) ⇒ Vapi::AnyscaleModel

Parameters:

  • messages (Array<Vapi::OpenAiMessage>) (defaults to: OMIT)

    This is the starting state for the conversation.

  • tools (Array<Vapi::AnyscaleModelToolsItem>) (defaults to: OMIT)

    These are the tools that the assistant can use during the call. To use existing tools, use ‘toolIds`. Both `tools` and `toolIds` can be used together.

  • tool_ids (Array<String>) (defaults to: OMIT)

    These are the tools that the assistant can use during the call. To use transient tools, use ‘tools`. Both `tools` and `toolIds` can be used together.

  • model (String)

    This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b

  • temperature (Float) (defaults to: OMIT)

    This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.

  • knowledge_base (Vapi::KnowledgeBase) (defaults to: OMIT)

    These are the options for the knowledge base.

  • max_tokens (Float) (defaults to: OMIT)

    This is the max number of tokens that the assistant will be allowed to generate in each turn of the conversation. Default is 250.

  • emotion_recognition_enabled (Boolean) (defaults to: OMIT)

    This determines whether we detect user’s emotion while they speak and send it as an additional info to model. Default ‘false` because the model is usually are good at understanding the user’s emotion from text. @default false

  • num_fast_turns (Float) (defaults to: OMIT)

    This sets how many turns at the start of the conversation to use a smaller, faster model from the same provider before switching to the primary model. Example, gpt-3.5-turbo if provider is openai. Default is 0. @default 0

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/vapi_server_sdk/types/anyscale_model.rb', line 76

def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, knowledge_base: 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
  @model = model
  @temperature = temperature if temperature != OMIT
  @knowledge_base = knowledge_base if knowledge_base != 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,
    "model": model,
    "temperature": temperature,
    "knowledgeBase": knowledge_base,
    "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)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



44
45
46
# File 'lib/vapi_server_sdk/types/anyscale_model.rb', line 44

def additional_properties
  @additional_properties
end

#emotion_recognition_enabledBoolean (readonly)

Returns This determines whether we detect user’s emotion while they speak and send it as an additional info to model. Default ‘false` because the model is usually are good at understanding the user’s emotion from text. @default false.

Returns:

  • (Boolean)

    This determines whether we detect user’s emotion while they speak and send it as an additional info to model. Default ‘false` because the model is usually are good at understanding the user’s emotion from text. @default false



36
37
38
# File 'lib/vapi_server_sdk/types/anyscale_model.rb', line 36

def emotion_recognition_enabled
  @emotion_recognition_enabled
end

#knowledge_baseVapi::KnowledgeBase (readonly)

Returns These are the options for the knowledge base.

Returns:



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

def knowledge_base
  @knowledge_base
end

#max_tokensFloat (readonly)

Returns This is the max number of tokens that the assistant will be allowed to generate in each turn of the conversation. Default is 250.

Returns:

  • (Float)

    This is the max number of tokens that the assistant will be allowed to generate in each turn of the conversation. Default is 250.



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

def max_tokens
  @max_tokens
end

#messagesArray<Vapi::OpenAiMessage> (readonly)

Returns This is the starting state for the conversation.

Returns:



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

def messages
  @messages
end

#modelString (readonly)

Returns This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b.

Returns:

  • (String)

    This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b



22
23
24
# File 'lib/vapi_server_sdk/types/anyscale_model.rb', line 22

def model
  @model
end

#num_fast_turnsFloat (readonly)

Returns This sets how many turns at the start of the conversation to use a smaller, faster model from the same provider before switching to the primary model. Example, gpt-3.5-turbo if provider is openai. Default is 0. @default 0.

Returns:

  • (Float)

    This sets how many turns at the start of the conversation to use a smaller, faster model from the same provider before switching to the primary model. Example, gpt-3.5-turbo if provider is openai. Default is 0. @default 0



42
43
44
# File 'lib/vapi_server_sdk/types/anyscale_model.rb', line 42

def num_fast_turns
  @num_fast_turns
end

#temperatureFloat (readonly)

Returns This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.

Returns:

  • (Float)

    This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.



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

def temperature
  @temperature
end

#tool_idsArray<String> (readonly)

Returns These are the tools that the assistant can use during the call. To use transient tools, use ‘tools`. Both `tools` and `toolIds` can be used together.

Returns:

  • (Array<String>)

    These are the tools that the assistant can use during the call. To use transient tools, use ‘tools`. Both `tools` and `toolIds` can be used together.



20
21
22
# File 'lib/vapi_server_sdk/types/anyscale_model.rb', line 20

def tool_ids
  @tool_ids
end

#toolsArray<Vapi::AnyscaleModelToolsItem> (readonly)

Returns These are the tools that the assistant can use during the call. To use existing tools, use ‘toolIds`. Both `tools` and `toolIds` can be used together.

Returns:

  • (Array<Vapi::AnyscaleModelToolsItem>)

    These are the tools that the assistant can use during the call. To use existing tools, use ‘toolIds`. Both `tools` and `toolIds` can be used together.



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

def tools
  @tools
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::AnyscaleModel

Deserialize a JSON object to an instance of AnyscaleModel

Parameters:

  • json_object (String)

Returns:



107
108
109
110
111
112
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
# File 'lib/vapi_server_sdk/types/anyscale_model.rb', line 107

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::AnyscaleModelToolsItem.from_json(json_object: item)
  end
  tool_ids = parsed_json["toolIds"]
  model = parsed_json["model"]
  temperature = parsed_json["temperature"]
  if parsed_json["knowledgeBase"].nil?
    knowledge_base = nil
  else
    knowledge_base = parsed_json["knowledgeBase"].to_json
    knowledge_base = Vapi::KnowledgeBase.from_json(json_object: knowledge_base)
  end
  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,
    model: model,
    temperature: temperature,
    knowledge_base: knowledge_base,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


157
158
159
160
161
162
163
164
165
166
167
# File 'lib/vapi_server_sdk/types/anyscale_model.rb', line 157

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.model.is_a?(String) != 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.knowledge_base.nil? || Vapi::KnowledgeBase.validate_raw(obj: obj.knowledge_base)
  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 AnyscaleModel to a JSON object

Returns:

  • (String)


147
148
149
# File 'lib/vapi_server_sdk/types/anyscale_model.rb', line 147

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