|
6 | 6 | #include "openvino/genai/llm_pipeline.hpp" |
7 | 7 | #include "openvino/genai/visibility.hpp" |
8 | 8 |
|
| 9 | +#define GET_PROPERTY_FROM_ARGS_LIST \ |
| 10 | + std::string property_key = va_arg(args_ptr, char*); \ |
| 11 | + if (property_key == ov::cache_encryption_callbacks.name()) { \ |
| 12 | + ov_encryption_callbacks* _value = va_arg(args_ptr, ov_encryption_callbacks*); \ |
| 13 | + auto encrypt_func = _value->encrypt_func; \ |
| 14 | + auto decrypt_func = _value->decrypt_func; \ |
| 15 | + std::function<std::string(const std::string&)> encrypt_value = [encrypt_func](const std::string& in) { \ |
| 16 | + size_t out_size = 0; \ |
| 17 | + std::string out_str; \ |
| 18 | + encrypt_func(in.c_str(), in.length(), nullptr, &out_size); \ |
| 19 | + if (out_size > 0) { \ |
| 20 | + std::unique_ptr<char[]> output_ptr = std::make_unique<char[]>(out_size); \ |
| 21 | + if (output_ptr) { \ |
| 22 | + char* output = output_ptr.get(); \ |
| 23 | + encrypt_func(in.c_str(), in.length(), output, &out_size); \ |
| 24 | + out_str.assign(output, out_size); \ |
| 25 | + } \ |
| 26 | + } \ |
| 27 | + return out_str; \ |
| 28 | + }; \ |
| 29 | + std::function<std::string(const std::string&)> decrypt_value = [decrypt_func](const std::string& in) { \ |
| 30 | + size_t out_size = 0; \ |
| 31 | + std::string out_str; \ |
| 32 | + decrypt_func(in.c_str(), in.length(), nullptr, &out_size); \ |
| 33 | + if (out_size > 0) { \ |
| 34 | + std::unique_ptr<char[]> output_ptr = std::make_unique<char[]>(out_size); \ |
| 35 | + if (output_ptr) { \ |
| 36 | + char* output = output_ptr.get(); \ |
| 37 | + decrypt_func(in.c_str(), in.length(), output, &out_size); \ |
| 38 | + out_str.assign(output, out_size); \ |
| 39 | + } \ |
| 40 | + } \ |
| 41 | + return out_str; \ |
| 42 | + }; \ |
| 43 | + ov::EncryptionCallbacks encryption_callbacks{std::move(encrypt_value), std::move(decrypt_value)}; \ |
| 44 | + property[property_key] = encryption_callbacks; \ |
| 45 | + } else { \ |
| 46 | + std::string _value = va_arg(args_ptr, char*); \ |
| 47 | + ov::Any value = _value; \ |
| 48 | + property[property_key] = value; \ |
| 49 | + } |
| 50 | + |
9 | 51 | /** |
10 | 52 | * @struct ov_genai_generation_config_opaque |
11 | 53 | * @brief This is an interface of ov::genai::GenerationConfig |
|
0 commit comments