Class: ReductoAI::Resources::Pipeline
- Inherits:
-
Object
- Object
- ReductoAI::Resources::Pipeline
- Defined in:
- lib/reducto_ai/resources/pipeline.rb
Overview
Note:
Pipeline operations consume credits based on all steps executed.
Pipeline resource for multi-step document processing workflows.
Orchestrates multiple Reducto operations (parse, extract, split, edit) in a single request, with outputs from earlier steps feeding into later ones.
Instance Method Summary collapse
-
#async(input:, steps:, async: nil, **options) ⇒ Hash
Executes a multi-step pipeline asynchronously.
-
#initialize(client) ⇒ Pipeline
constructor
private
A new instance of Pipeline.
-
#sync(input:, steps:, **options) ⇒ Hash
Executes a multi-step pipeline synchronously.
Constructor Details
#initialize(client) ⇒ Pipeline
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Pipeline.
25 26 27 |
# File 'lib/reducto_ai/resources/pipeline.rb', line 25 def initialize(client) @client = client end |
Instance Method Details
#async(input:, steps:, async: nil, **options) ⇒ Hash
Executes a multi-step pipeline asynchronously.
Returns immediately with a job_id. Poll with Jobs#retrieve to get results.
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/reducto_ai/resources/pipeline.rb', line 92 def async(input:, steps:, async: nil, **) raise ArgumentError, "input is required" if input.nil? raise ArgumentError, "steps are required" if steps.nil? || (steps.respond_to?(:empty?) && steps.empty?) payload = { input: input, steps: steps } payload[:async] = async unless async.nil? payload.merge!(.compact) @client.post("/pipeline_async", payload) end |
#sync(input:, steps:, **options) ⇒ Hash
Executes a multi-step pipeline synchronously.
57 58 59 60 61 62 63 |
# File 'lib/reducto_ai/resources/pipeline.rb', line 57 def sync(input:, steps:, **) raise ArgumentError, "input is required" if input.nil? raise ArgumentError, "steps are required" if steps.nil? || (steps.respond_to?(:empty?) && steps.empty?) payload = { input: input, steps: steps, ** }.compact @client.post("/pipeline", payload) end |