Class: Legion::Gaia::InputFrame

Inherits:
Data
  • Object
show all
Defined in:
lib/legion/gaia/input_frame.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, channel_id:, id: SecureRandom.uuid, content_type: :text, channel_capabilities: [], device_context: {}, session_continuity_id: nil, auth_context: {}, metadata: {}, received_at: Time.now.utc) ⇒ InputFrame

Returns a new instance of InputFrame.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/legion/gaia/input_frame.rb', line 21

def initialize(
  content:,
  channel_id:,
  id: SecureRandom.uuid,
  content_type: :text,
  channel_capabilities: [],
  device_context: {},
  session_continuity_id: nil,
  auth_context: {},
  metadata: {},
  received_at: Time.now.utc
)
  super
end

Instance Attribute Details

#auth_contextObject (readonly)

Returns the value of attribute auth_context

Returns:

  • (Object)

    the current value of auth_context



9
10
11
# File 'lib/legion/gaia/input_frame.rb', line 9

def auth_context
  @auth_context
end

#channel_capabilitiesObject (readonly)

Returns the value of attribute channel_capabilities

Returns:

  • (Object)

    the current value of channel_capabilities



9
10
11
# File 'lib/legion/gaia/input_frame.rb', line 9

def channel_capabilities
  @channel_capabilities
end

#channel_idObject (readonly)

Returns the value of attribute channel_id

Returns:

  • (Object)

    the current value of channel_id



9
10
11
# File 'lib/legion/gaia/input_frame.rb', line 9

def channel_id
  @channel_id
end

#contentObject (readonly)

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



9
10
11
# File 'lib/legion/gaia/input_frame.rb', line 9

def content
  @content
end

#content_typeObject (readonly)

Returns the value of attribute content_type

Returns:

  • (Object)

    the current value of content_type



9
10
11
# File 'lib/legion/gaia/input_frame.rb', line 9

def content_type
  @content_type
end

#device_contextObject (readonly)

Returns the value of attribute device_context

Returns:

  • (Object)

    the current value of device_context



9
10
11
# File 'lib/legion/gaia/input_frame.rb', line 9

def device_context
  @device_context
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



9
10
11
# File 'lib/legion/gaia/input_frame.rb', line 9

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



9
10
11
# File 'lib/legion/gaia/input_frame.rb', line 9

def 
  @metadata
end

#received_atObject (readonly)

Returns the value of attribute received_at

Returns:

  • (Object)

    the current value of received_at



9
10
11
# File 'lib/legion/gaia/input_frame.rb', line 9

def received_at
  @received_at
end

#session_continuity_idObject (readonly)

Returns the value of attribute session_continuity_id

Returns:

  • (Object)

    the current value of session_continuity_id



9
10
11
# File 'lib/legion/gaia/input_frame.rb', line 9

def session_continuity_id
  @session_continuity_id
end

Instance Method Details

#human_direct?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/legion/gaia/input_frame.rb', line 40

def human_direct?
  [:source_type] == :human_direct
end

#salienceObject



44
45
46
# File 'lib/legion/gaia/input_frame.rb', line 44

def salience
  [:salience] || 0.0
end

#text?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/legion/gaia/input_frame.rb', line 36

def text?
  content_type == :text
end

#to_signalObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/legion/gaia/input_frame.rb', line 48

def to_signal
  {
    value: content,
    source_type: [:source_type] || :ambient,
    salience: salience,
    channel_id: channel_id,
    frame_id: id,
    received_at: received_at
  }
end