DocWire SDK
DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, document analysis. Offline processing possible for security and confidentiality
docwire::ai::model_chain_element Class Reference

A model chain element that processes input text using a model runner. More...

#include <model_chain_element.h>

Inheritance diagram for docwire::ai::model_chain_element:
docwire::chain_element docwire::with_pimpl< chain_element > docwire::with_pimpl_base docwire::ai::summarize docwire::ai::task docwire::ai::translate docwire::ai::local::summarize docwire::ai::local::task docwire::ai::local::translate

Public Member Functions

 model_chain_element (const std::string &prompt, std::shared_ptr< ai_runner > runner, model_lifetime_policy lifetime=model_lifetime_policy::persistent)
 Construct a model chain element. More...
 
continuation operator() (message_ptr msg, const message_callbacks &emit_message) override
 Construct a model chain element with a default model runner. More...
 
bool is_leaf () const override
 Check if the model chain element is a leaf. More...
 
- Public Member Functions inherited from docwire::chain_element
 chain_element (chain_element &&)=default
 
chain_elementoperator= (chain_element &&)=default
 
virtual bool is_generator () const
 

Additional Inherited Members

- Protected Types inherited from docwire::with_pimpl< chain_element >
using impl_type = pimpl_impl< chain_element >
 
- Protected Member Functions inherited from docwire::with_pimpl< chain_element >
impl_typecreate_impl (Args &&... args)
 
 with_pimpl (Args &&... args)
 
 with_pimpl (with_pimpl< chain_element > &&other) noexcept
 
 with_pimpl (std::nullptr_t)
 
with_pimploperator= (with_pimpl &&other) noexcept
 
impl_typeimpl ()
 
const impl_typeimpl () const
 

Detailed Description

A model chain element that processes input text using a model runner.

This class is a chain element that takes a prompt and a model runner. It processes the input by appending the prompt to the input text and then passing the text to the model runner. The output of the model runner is then emitted as a new message_ptr object.

Definition at line 39 of file model_chain_element.h.

Constructor & Destructor Documentation

◆ model_chain_element()

docwire::ai::model_chain_element::model_chain_element ( const std::string &  prompt,
std::shared_ptr< ai_runner runner,
model_lifetime_policy  lifetime = model_lifetime_policy::persistent 
)

Construct a model chain element.

Parameters
promptThe prompt to append to the input text.
ai_runnerThe model runner to use for processing the text.
model_lifetime_policyOption to decide whether to unload model after usage or keep it persistent

Member Function Documentation

◆ is_leaf()

bool docwire::ai::model_chain_element::is_leaf ( ) const
inlineoverridevirtual

Check if the model chain element is a leaf.

The model chain element is never a leaf, so this function always returns false.

Returns
false Always false.

Implements docwire::chain_element.

Definition at line 83 of file model_chain_element.h.

◆ operator()()

continuation docwire::ai::model_chain_element::operator() ( message_ptr  msg,
const message_callbacks emit_message 
)
overridevirtual

Construct a model chain element with a default model runner.

This constructor initializes the model chain element with a default model_runner configured to use the flan-t5-large-ct2-int8 model.

Parameters
promptThe prompt to append to the input text.
model_lifetime_policyOption to decide whether to unload model after usage or keep it persistent

Process the input.

If the input is not a data source, emit the input and return. If the input is a data source, append the prompt to the input text and then pass the text to the model runner. The output of the model runner is then emitted as a new message_ptr object.

Parameters
msgThe input message to process.
emit_messageCallback used to emit derived messages downstream.

Implements docwire::chain_element.


The documentation for this class was generated from the following file: