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
model_chain_element.h
1 /*********************************************************************************************************************************************/
2 /* DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. */
3 /* Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, */
4 /* document analysis. Offline processing possible for security and confidentiality */
5 /* */
6 /* Copyright (c) SILVERCODERS Ltd, http://silvercoders.com */
7 /* Project homepage: https://github.com/docwire/docwire */
8 /* */
9 /* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-DocWire-Commercial */
10 /*********************************************************************************************************************************************/
11 
12 #ifndef DOCWIRE_AI_MODEL_CHAIN_ELEMENT_H
13 #define DOCWIRE_AI_MODEL_CHAIN_ELEMENT_H
14 
15 #include "ai_runner.h"
16 #include "chain_element.h"
17 #include "ai_export.h"
18 
19 namespace docwire::ai
20 {
21 
22 /***
23  * @brief Model usage option for Load/Unload in memory
24  */
25 enum class model_lifetime_policy
26 {
27  persistent, // keeps the model in memory, which makes it available for next pipeline usage
28  unload_after_use // unloads after current usage
29 };
30 
39 class DOCWIRE_AI_EXPORT model_chain_element : public chain_element
40 {
41  public:
49  model_chain_element(const std::string& prompt, std::shared_ptr<ai_runner> runner, model_lifetime_policy lifetime = model_lifetime_policy::persistent);
50 
60  //model_chain_element(const std::string& prompt, model_lifetime_policy lifetime = model_lifetime_policy::persistent);
61 
73  continuation operator()(message_ptr msg, const message_callbacks& emit_message) override;
74 
83  bool is_leaf() const override { return false; }
84 
85  private:
86  std::string m_prompt;
87  std::shared_ptr<ai_runner> m_model_runner;
88  model_lifetime_policy m_model_lifetime;
89 };
90 
91 } // namespace docwire::ai
92 
93 #endif // DOCWIRE_AI_MODEL_CHAIN_ELEMENT_H
A model chain element that processes input text using a model runner.
continuation operator()(message_ptr msg, const message_callbacks &emit_message) override
Construct a model chain element with a default model runner.
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.
bool is_leaf() const override
Check if the model chain element is a leaf.