Class: Legion::Extensions::Agentic::Language::FrameSemantics::Helpers::FrameInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/language/frame_semantics/helpers/frame_instance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(frame_id:, frame_name:, slot_fillers:, context:, confidence: 0.7) ⇒ FrameInstance

Returns a new instance of FrameInstance.



14
15
16
17
18
19
20
21
22
# File 'lib/legion/extensions/agentic/language/frame_semantics/helpers/frame_instance.rb', line 14

def initialize(frame_id:, frame_name:, slot_fillers:, context:, confidence: 0.7)
  @id           = SecureRandom.uuid
  @frame_id     = frame_id
  @frame_name   = frame_name
  @slot_fillers = slot_fillers.dup
  @context      = context
  @confidence   = confidence
  @created_at   = Time.now.utc
end

Instance Attribute Details

#confidenceObject (readonly)

Returns the value of attribute confidence.



12
13
14
# File 'lib/legion/extensions/agentic/language/frame_semantics/helpers/frame_instance.rb', line 12

def confidence
  @confidence
end

#contextObject (readonly)

Returns the value of attribute context.



12
13
14
# File 'lib/legion/extensions/agentic/language/frame_semantics/helpers/frame_instance.rb', line 12

def context
  @context
end

#created_atObject (readonly)

Returns the value of attribute created_at.



12
13
14
# File 'lib/legion/extensions/agentic/language/frame_semantics/helpers/frame_instance.rb', line 12

def created_at
  @created_at
end

#frame_idObject (readonly)

Returns the value of attribute frame_id.



12
13
14
# File 'lib/legion/extensions/agentic/language/frame_semantics/helpers/frame_instance.rb', line 12

def frame_id
  @frame_id
end

#frame_nameObject (readonly)

Returns the value of attribute frame_name.



12
13
14
# File 'lib/legion/extensions/agentic/language/frame_semantics/helpers/frame_instance.rb', line 12

def frame_name
  @frame_name
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/language/frame_semantics/helpers/frame_instance.rb', line 12

def id
  @id
end

#slot_fillersObject (readonly)

Returns the value of attribute slot_fillers.



12
13
14
# File 'lib/legion/extensions/agentic/language/frame_semantics/helpers/frame_instance.rb', line 12

def slot_fillers
  @slot_fillers
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/legion/extensions/agentic/language/frame_semantics/helpers/frame_instance.rb', line 24

def complete?
  filled_count.positive?
end

#filled_countObject



28
29
30
# File 'lib/legion/extensions/agentic/language/frame_semantics/helpers/frame_instance.rb', line 28

def filled_count
  @slot_fillers.count { |_k, v| !v.nil? }
end

#to_hObject



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/legion/extensions/agentic/language/frame_semantics/helpers/frame_instance.rb', line 32

def to_h
  {
    id:           @id,
    frame_id:     @frame_id,
    frame_name:   @frame_name,
    slot_fillers: @slot_fillers,
    context:      @context,
    confidence:   @confidence,
    filled_count: filled_count,
    complete:     complete?,
    created_at:   @created_at
  }
end