Class: LangsmithrbRails::RunContext
- Inherits:
-
Object
- Object
- LangsmithrbRails::RunContext
- Defined in:
- lib/langsmithrb_rails/run_trees.rb
Overview
Context manager for run trees
Class Method Summary collapse
-
.run(name:, run_type:, inputs:, parent_run_id: nil, project_name: nil, tags: []) {|RunTree| ... } ⇒ Object
Start a new run context.
Class Method Details
.run(name:, run_type:, inputs:, parent_run_id: nil, project_name: nil, tags: []) {|RunTree| ... } ⇒ Object
Start a new run context
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/langsmithrb_rails/run_trees.rb', line 137 def self.run(name:, run_type:, inputs:, parent_run_id: nil, project_name: nil, tags: [], &block) run_tree = RunTree.new( name: name, run_type: run_type, inputs: inputs, parent_run_id: parent_run_id, project_name: project_name, tags: ) begin result = yield(run_tree) run_tree.end(outputs: { result: result }) result rescue => e run_tree.end(error: e.) raise e end end |