Class: Raif::ModelToolInvocation
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Raif::ModelToolInvocation
- Defined in:
- app/models/raif/model_tool_invocation.rb
Overview
Schema Information
Table name: raif_model_tool_invocations
id :bigint not null, primary key
completed_at :datetime
failed_at :datetime
result :jsonb not null
source_type :string not null
tool_arguments :jsonb not null
tool_type :string not null
created_at :datetime not null
updated_at :datetime not null
source_id :bigint not null
Indexes
index_raif_model_tool_invocations_on_source (source_type,source_id)
Instance Method Summary collapse
- #as_llm_message ⇒ Object
- #ensure_valid_tool_argument_schema ⇒ Object
- #result_llm_message ⇒ Object
- #to_partial_path ⇒ Object
- #tool ⇒ Object
Methods inherited from ApplicationRecord
Instance Method Details
#as_llm_message ⇒ Object
44 45 46 |
# File 'app/models/raif/model_tool_invocation.rb', line 44 def "Invoking tool: #{tool_name} with arguments: #{tool_arguments.to_json}" end |
#ensure_valid_tool_argument_schema ⇒ Object
58 59 60 61 62 |
# File 'app/models/raif/model_tool_invocation.rb', line 58 def ensure_valid_tool_argument_schema unless JSON::Validator.validate(tool_arguments_schema, tool_arguments) errors.add(:tool_arguments, "does not match schema") end end |
#result_llm_message ⇒ Object
48 49 50 51 52 |
# File 'app/models/raif/model_tool_invocation.rb', line 48 def return unless tool.respond_to?(:observation_for_invocation) tool.observation_for_invocation(self) end |
#to_partial_path ⇒ Object
54 55 56 |
# File 'app/models/raif/model_tool_invocation.rb', line 54 def to_partial_path "raif/model_tool_invocations/#{tool.invocation_partial_name}" end |
#tool ⇒ Object
40 41 42 |
# File 'app/models/raif/model_tool_invocation.rb', line 40 def tool @tool ||= tool_type.constantize end |