Class: Phronomy::Agent::LLMCallRecord
- Inherits:
-
Object
- Object
- Phronomy::Agent::LLMCallRecord
- Defined in:
- lib/phronomy/agent/llm_call_record.rb
Constant Summary collapse
- STATUSES =
%i[completed failed cancelled].freeze
- ATTRIBUTES =
%i[ llm_call_id execution_id sequence status manifest_ref output_ref error_ref usage_ref started_at completed_at metadata ].freeze
Instance Method Summary collapse
-
#initialize(execution_id:, sequence:, status:, manifest_ref:, llm_call_id: SecureRandom.uuid, output_ref: nil, error_ref: nil, usage_ref: nil, started_at: Time.now.utc.iso8601(6), completed_at: nil, metadata: {}) ⇒ LLMCallRecord
constructor
A new instance of LLMCallRecord.
- #to_h ⇒ Object
Constructor Details
#initialize(execution_id:, sequence:, status:, manifest_ref:, llm_call_id: SecureRandom.uuid, output_ref: nil, error_ref: nil, usage_ref: nil, started_at: Time.now.utc.iso8601(6), completed_at: nil, metadata: {}) ⇒ LLMCallRecord
Returns a new instance of LLMCallRecord.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/phronomy/agent/llm_call_record.rb', line 17 def initialize( execution_id:, sequence:, status:, manifest_ref:, llm_call_id: SecureRandom.uuid, output_ref: nil, error_ref: nil, usage_ref: nil, started_at: Time.now.utc.iso8601(6), completed_at: nil, metadata: {} ) values = binding.local_variables.to_h { |name| [name, binding.local_variable_get(name)] } ATTRIBUTES.each do |name| value = values.fetch(name) value = value.to_sym if name == :status instance_variable_set("@#{name}", Immutable.copy(value)) end raise ArgumentError, "unknown LLM Call status: #{status.inspect}" unless STATUSES.include?(status) raise ArgumentError, "LLM Call sequence must be positive" unless sequence.positive? Immutable.validate_canonical_json!(, label: "LLM Call metadata") freeze end |
Instance Method Details
#to_h ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/phronomy/agent/llm_call_record.rb', line 42 def to_h ATTRIBUTES.to_h do |name| value = public_send(name) value = value.to_s if name == :status [name.to_s, value] end end |