Class: Vapi::Artifact

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(messages: OMIT, messages_open_ai_formatted: OMIT, recording_url: OMIT, stereo_recording_url: OMIT, video_recording_url: OMIT, video_recording_start_delay_seconds: OMIT, transcript: OMIT, additional_properties: nil) ⇒ Vapi::Artifact

Parameters:

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

    These are the messages that were spoken during the call.

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

    These are the messages that were spoken during the call, formatted for OpenAI.

  • recording_url (String) (defaults to: OMIT)

    This is the recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.

  • stereo_recording_url (String) (defaults to: OMIT)

    This is the stereo recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.

  • video_recording_url (String) (defaults to: OMIT)

    This is video recording url for the call. To enable, set ‘assistant.artifactPlan.videoRecordingEnabled`.

  • video_recording_start_delay_seconds (Float) (defaults to: OMIT)

    This is video recording start delay in ms. To enable, set ‘assistant.artifactPlan.videoRecordingEnabled`. This can be used to align the playback of the recording with artifact.messages timestamps.

  • transcript (String) (defaults to: OMIT)

    This is the transcript of the call. This is derived from ‘artifact.messages` but provided for convenience.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/vapi_server_sdk/types/artifact.rb', line 53

def initialize(messages: OMIT, messages_open_ai_formatted: OMIT, recording_url: OMIT, stereo_recording_url: OMIT,
               video_recording_url: OMIT, video_recording_start_delay_seconds: OMIT, transcript: OMIT, additional_properties: nil)
  @messages = messages if messages != OMIT
  @messages_open_ai_formatted = messages_open_ai_formatted if messages_open_ai_formatted != OMIT
  @recording_url = recording_url if recording_url != OMIT
  @stereo_recording_url = stereo_recording_url if stereo_recording_url != OMIT
  @video_recording_url = video_recording_url if video_recording_url != OMIT
  if video_recording_start_delay_seconds != OMIT
    @video_recording_start_delay_seconds = video_recording_start_delay_seconds
  end
  @transcript = transcript if transcript != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "messages": messages,
    "messagesOpenAIFormatted": messages_open_ai_formatted,
    "recordingUrl": recording_url,
    "stereoRecordingUrl": stereo_recording_url,
    "videoRecordingUrl": video_recording_url,
    "videoRecordingStartDelaySeconds": video_recording_start_delay_seconds,
    "transcript": transcript
  }.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



31
32
33
# File 'lib/vapi_server_sdk/types/artifact.rb', line 31

def additional_properties
  @additional_properties
end

#messagesArray<Vapi::ArtifactMessagesItem> (readonly)

Returns These are the messages that were spoken during the call.

Returns:



11
12
13
# File 'lib/vapi_server_sdk/types/artifact.rb', line 11

def messages
  @messages
end

#messages_open_ai_formattedArray<Vapi::OpenAiMessage> (readonly)

Returns These are the messages that were spoken during the call, formatted for OpenAI.

Returns:

  • (Array<Vapi::OpenAiMessage>)

    These are the messages that were spoken during the call, formatted for OpenAI.



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

def messages_open_ai_formatted
  @messages_open_ai_formatted
end

#recording_urlString (readonly)

Returns This is the recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.

Returns:

  • (String)

    This is the recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.



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

def recording_url
  @recording_url
end

#stereo_recording_urlString (readonly)

Returns This is the stereo recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.

Returns:

  • (String)

    This is the stereo recording url for the call. To enable, set ‘assistant.artifactPlan.recordingEnabled`.



19
20
21
# File 'lib/vapi_server_sdk/types/artifact.rb', line 19

def stereo_recording_url
  @stereo_recording_url
end

#transcriptString (readonly)

Returns This is the transcript of the call. This is derived from ‘artifact.messages` but provided for convenience.

Returns:

  • (String)

    This is the transcript of the call. This is derived from ‘artifact.messages` but provided for convenience.



29
30
31
# File 'lib/vapi_server_sdk/types/artifact.rb', line 29

def transcript
  @transcript
end

#video_recording_start_delay_secondsFloat (readonly)

Returns This is video recording start delay in ms. To enable, set ‘assistant.artifactPlan.videoRecordingEnabled`. This can be used to align the playback of the recording with artifact.messages timestamps.

Returns:

  • (Float)

    This is video recording start delay in ms. To enable, set ‘assistant.artifactPlan.videoRecordingEnabled`. This can be used to align the playback of the recording with artifact.messages timestamps.



26
27
28
# File 'lib/vapi_server_sdk/types/artifact.rb', line 26

def video_recording_start_delay_seconds
  @video_recording_start_delay_seconds
end

#video_recording_urlString (readonly)

Returns This is video recording url for the call. To enable, set ‘assistant.artifactPlan.videoRecordingEnabled`.

Returns:

  • (String)

    This is video recording url for the call. To enable, set ‘assistant.artifactPlan.videoRecordingEnabled`.



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

def video_recording_url
  @video_recording_url
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::Artifact

Deserialize a JSON object to an instance of Artifact

Parameters:

  • json_object (String)

Returns:



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

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::ArtifactMessagesItem.from_json(json_object: item)
  end
  messages_open_ai_formatted = parsed_json["messagesOpenAIFormatted"]&.map do |item|
    item = item.to_json
    Vapi::OpenAiMessage.from_json(json_object: item)
  end
  recording_url = parsed_json["recordingUrl"]
  stereo_recording_url = parsed_json["stereoRecordingUrl"]
  video_recording_url = parsed_json["videoRecordingUrl"]
  video_recording_start_delay_seconds = parsed_json["videoRecordingStartDelaySeconds"]
  transcript = parsed_json["transcript"]
  new(
    messages: messages,
    messages_open_ai_formatted: messages_open_ai_formatted,
    recording_url: recording_url,
    stereo_recording_url: stereo_recording_url,
    video_recording_url: video_recording_url,
    video_recording_start_delay_seconds: video_recording_start_delay_seconds,
    transcript: transcript,
    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)


123
124
125
126
127
128
129
130
131
# File 'lib/vapi_server_sdk/types/artifact.rb', line 123

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.messages_open_ai_formatted&.is_a?(Array) != false || raise("Passed value for field obj.messages_open_ai_formatted is not the expected type, validation failed.")
  obj.recording_url&.is_a?(String) != false || raise("Passed value for field obj.recording_url is not the expected type, validation failed.")
  obj.stereo_recording_url&.is_a?(String) != false || raise("Passed value for field obj.stereo_recording_url is not the expected type, validation failed.")
  obj.video_recording_url&.is_a?(String) != false || raise("Passed value for field obj.video_recording_url is not the expected type, validation failed.")
  obj.video_recording_start_delay_seconds&.is_a?(Float) != false || raise("Passed value for field obj.video_recording_start_delay_seconds is not the expected type, validation failed.")
  obj.transcript&.is_a?(String) != false || raise("Passed value for field obj.transcript is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Artifact to a JSON object

Returns:

  • (String)


113
114
115
# File 'lib/vapi_server_sdk/types/artifact.rb', line 113

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