|
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
|
A model chain element that processes input text using a model runner. More...
#include <model_chain_element.h>
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_element & | operator= (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_type * | create_impl (Args &&... args) |
| with_pimpl (Args &&... args) | |
| with_pimpl (with_pimpl< chain_element > &&other) noexcept | |
| with_pimpl (std::nullptr_t) | |
| with_pimpl & | operator= (with_pimpl &&other) noexcept |
| impl_type & | impl () |
| const impl_type & | impl () const |
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.
| 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.
| prompt | The prompt to append to the input text. |
| ai_runner | The model runner to use for processing the text. |
| model_lifetime_policy | Option to decide whether to unload model after usage or keep it persistent |
|
inlineoverridevirtual |
Check if the model chain element is a leaf.
The model chain element is never a leaf, so this function always returns false.
Implements docwire::chain_element.
Definition at line 83 of file model_chain_element.h.
|
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.
| prompt | The prompt to append to the input text. |
| model_lifetime_policy | Option 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.
| msg | The input message to process. |
| emit_message | Callback used to emit derived messages downstream. |
Implements docwire::chain_element.