Class: Phronomy::Agent::LLMInputManifest

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

Defined Under Namespace

Classes: Segment

Constant Summary collapse

VERSION =
1
CALL_MODES =
%i[ask complete].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(call_sequence:, call_mode:, segments:, model_config_ref:, tool_definitions_ref: nil, response_schema_ref: nil, assembly_policy_version: 1, ruby_llm_version: nil, adapter_name: nil, adapter_version: nil, version: VERSION) ⇒ LLMInputManifest

Returns a new instance of LLMInputManifest.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 36

def initialize(
  call_sequence:,
  call_mode:,
  segments:,
  model_config_ref:,
  tool_definitions_ref: nil,
  response_schema_ref: nil,
  assembly_policy_version: 1,
  ruby_llm_version: nil,
  adapter_name: nil,
  adapter_version: nil,
  version: VERSION
)
  @version = Integer(version)
  @call_sequence = Integer(call_sequence)
  @call_mode = call_mode.to_sym
  @assembly_policy_version = Integer(assembly_policy_version)
  @segments = Array(segments).sort_by(&:position).freeze
  @model_config_ref = model_config_ref.to_s.freeze
  @tool_definitions_ref = tool_definitions_ref&.to_s&.freeze
  @response_schema_ref = response_schema_ref&.to_s&.freeze
  @ruby_llm_version = ruby_llm_version&.to_s&.freeze
  @adapter_name = adapter_name&.to_s&.freeze
  @adapter_version = adapter_version&.to_s&.freeze
  validate!
  freeze
end

Instance Attribute Details

#adapter_nameObject (readonly)

Returns the value of attribute adapter_name.



31
32
33
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 31

def adapter_name
  @adapter_name
end

#adapter_versionObject (readonly)

Returns the value of attribute adapter_version.



31
32
33
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 31

def adapter_version
  @adapter_version
end

#assembly_policy_versionObject (readonly)

Returns the value of attribute assembly_policy_version.



31
32
33
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 31

def assembly_policy_version
  @assembly_policy_version
end

#call_modeObject (readonly)

Returns the value of attribute call_mode.



31
32
33
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 31

def call_mode
  @call_mode
end

#call_sequenceObject (readonly)

Returns the value of attribute call_sequence.



31
32
33
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 31

def call_sequence
  @call_sequence
end

#model_config_refObject (readonly)

Returns the value of attribute model_config_ref.



31
32
33
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 31

def model_config_ref
  @model_config_ref
end

#response_schema_refObject (readonly)

Returns the value of attribute response_schema_ref.



31
32
33
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 31

def response_schema_ref
  @response_schema_ref
end

#ruby_llm_versionObject (readonly)

Returns the value of attribute ruby_llm_version.



31
32
33
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 31

def ruby_llm_version
  @ruby_llm_version
end

#segmentsObject (readonly)

Returns the value of attribute segments.



31
32
33
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 31

def segments
  @segments
end

#tool_definitions_refObject (readonly)

Returns the value of attribute tool_definitions_ref.



31
32
33
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 31

def tool_definitions_ref
  @tool_definitions_ref
end

#versionObject (readonly)

Returns the value of attribute version.



31
32
33
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 31

def version
  @version
end

Instance Method Details

#referenced_content_refsObject



64
65
66
67
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 64

def referenced_content_refs
  ([model_config_ref, tool_definitions_ref, response_schema_ref] +
    segments.map(&:content_ref)).compact.uniq.freeze
end

#to_hObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/phronomy/agent/llm_input_manifest.rb', line 69

def to_h
  {
    "version" => version,
    "call_sequence" => call_sequence,
    "call_mode" => call_mode.to_s,
    "assembly_policy_version" => assembly_policy_version,
    "segments" => segments.map(&:to_h),
    "model_config_ref" => model_config_ref,
    "tool_definitions_ref" => tool_definitions_ref,
    "response_schema_ref" => response_schema_ref,
    "ruby_llm_version" => ruby_llm_version,
    "adapter_name" => adapter_name,
    "adapter_version" => adapter_version
  }.compact
end