Class: Phronomy::Agent::ContextCandidate

Inherits:
Data
  • Object
show all
Defined in:
lib/phronomy/agent/context_candidate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**values) ⇒ ContextCandidate

Returns a new instance of ContextCandidate.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/phronomy/agent/context_candidate.rb', line 21

def initialize(**values)
  normalized = values.merge(
    candidate_id: values.fetch(:candidate_id).to_s.freeze,
    source_kind: values.fetch(:source_kind).to_sym,
    category: values.fetch(:category).to_sym,
    role: values[:role]&.to_sym,
    content_ref: values.fetch(:content_ref).to_s.freeze,
    record_id: values[:record_id]&.to_s&.freeze,
    agent_id: values[:agent_id]&.to_s&.freeze,
    execution_id: values[:execution_id]&.to_s&.freeze,
    llm_call_id: values[:llm_call_id]&.to_s&.freeze,
    tool_call_id: values[:tool_call_id]&.to_s&.freeze,
    sequence: values[:sequence] && Integer(values[:sequence]),
    requirement: (values[:requirement] || :optional).to_sym,
    priority: Integer(values[:priority] || 0),
    metadata: Immutable.copy(values[:metadata] || {})
  )
  unless %i[protocol_required declared_required optional].include?(normalized[:requirement])
    raise ArgumentError, "unknown ContextCandidate requirement: #{normalized[:requirement].inspect}"
  end

  super(**normalized)
  freeze
end

Instance Attribute Details

#agent_idObject (readonly)

Returns the value of attribute agent_id

Returns:

  • (Object)

    the current value of agent_id



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def agent_id
  @agent_id
end

#candidate_idObject (readonly)

Returns the value of attribute candidate_id

Returns:

  • (Object)

    the current value of candidate_id



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def candidate_id
  @candidate_id
end

#categoryObject (readonly)

Returns the value of attribute category

Returns:

  • (Object)

    the current value of category



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def category
  @category
end

#content_refObject (readonly)

Returns the value of attribute content_ref

Returns:

  • (Object)

    the current value of content_ref



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def content_ref
  @content_ref
end

#execution_idObject (readonly)

Returns the value of attribute execution_id

Returns:

  • (Object)

    the current value of execution_id



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def execution_id
  @execution_id
end

#llm_call_idObject (readonly)

Returns the value of attribute llm_call_id

Returns:

  • (Object)

    the current value of llm_call_id



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def llm_call_id
  @llm_call_id
end

#metadataObject (readonly)

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def 
  @metadata
end

#priorityObject (readonly)

Returns the value of attribute priority

Returns:

  • (Object)

    the current value of priority



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def priority
  @priority
end

#record_idObject (readonly)

Returns the value of attribute record_id

Returns:

  • (Object)

    the current value of record_id



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def record_id
  @record_id
end

#requirementObject (readonly)

Returns the value of attribute requirement

Returns:

  • (Object)

    the current value of requirement



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def requirement
  @requirement
end

#roleObject (readonly)

Returns the value of attribute role

Returns:

  • (Object)

    the current value of role



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def role
  @role
end

#sequenceObject (readonly)

Returns the value of attribute sequence

Returns:

  • (Object)

    the current value of sequence



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def sequence
  @sequence
end

#source_kindObject (readonly)

Returns the value of attribute source_kind

Returns:

  • (Object)

    the current value of source_kind



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def source_kind
  @source_kind
end

#tool_call_idObject (readonly)

Returns the value of attribute tool_call_id

Returns:

  • (Object)

    the current value of tool_call_id



5
6
7
# File 'lib/phronomy/agent/context_candidate.rb', line 5

def tool_call_id
  @tool_call_id
end