|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2026, Redis |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +"""NAT public plugin API imports with compatibility for older supported NAT releases. |
| 5 | +
|
| 6 | +NAT's third-party plugin guidance asks runtime plugin code to import plugin-authoring |
| 7 | +symbols from ``nat.plugin_api``. The current supported range also includes older NAT |
| 8 | +releases that do not ship that facade, so this module is the only compatibility |
| 9 | +fallback to implementation imports. |
| 10 | +""" |
| 11 | + |
| 12 | +from __future__ import annotations |
| 13 | + |
| 14 | +try: |
| 15 | + from nat.plugin_api import ( |
| 16 | + Builder, |
| 17 | + EmbedderRef, |
| 18 | + Function, |
| 19 | + FunctionBaseConfig, |
| 20 | + FunctionInfo, |
| 21 | + FunctionRef, |
| 22 | + KeyAlreadyExistsError, |
| 23 | + LLMFrameworkEnum, |
| 24 | + MemoryBaseConfig, |
| 25 | + MemoryEditor, |
| 26 | + MemoryItem, |
| 27 | + MemoryRef, |
| 28 | + NoSuchKeyError, |
| 29 | + ObjectStore, |
| 30 | + ObjectStoreBaseConfig, |
| 31 | + ObjectStoreItem, |
| 32 | + OptionalSecretStr, |
| 33 | + get_secret_value, |
| 34 | + register_function, |
| 35 | + register_memory, |
| 36 | + register_object_store, |
| 37 | + ) |
| 38 | + |
| 39 | + USING_PLUGIN_API = True |
| 40 | +except ModuleNotFoundError: # pragma: no cover - exercised only on older NAT releases |
| 41 | + from nat.builder.builder import Builder |
| 42 | + from nat.builder.framework_enum import LLMFrameworkEnum |
| 43 | + from nat.builder.function import Function |
| 44 | + from nat.builder.function_info import FunctionInfo |
| 45 | + from nat.cli.register_workflow import register_function, register_memory, register_object_store |
| 46 | + from nat.data_models.common import OptionalSecretStr, get_secret_value |
| 47 | + from nat.data_models.component_ref import EmbedderRef, FunctionRef, MemoryRef |
| 48 | + from nat.data_models.function import FunctionBaseConfig |
| 49 | + from nat.data_models.memory import MemoryBaseConfig |
| 50 | + from nat.data_models.object_store import KeyAlreadyExistsError, NoSuchKeyError, ObjectStoreBaseConfig |
| 51 | + from nat.memory.interfaces import MemoryEditor |
| 52 | + from nat.memory.models import MemoryItem |
| 53 | + from nat.object_store.interfaces import ObjectStore |
| 54 | + from nat.object_store.models import ObjectStoreItem |
| 55 | + |
| 56 | + USING_PLUGIN_API = False |
| 57 | + |
| 58 | + |
| 59 | +__all__ = [ |
| 60 | + "Builder", |
| 61 | + "EmbedderRef", |
| 62 | + "Function", |
| 63 | + "FunctionBaseConfig", |
| 64 | + "FunctionInfo", |
| 65 | + "FunctionRef", |
| 66 | + "KeyAlreadyExistsError", |
| 67 | + "LLMFrameworkEnum", |
| 68 | + "MemoryBaseConfig", |
| 69 | + "MemoryEditor", |
| 70 | + "MemoryItem", |
| 71 | + "MemoryRef", |
| 72 | + "NoSuchKeyError", |
| 73 | + "ObjectStore", |
| 74 | + "ObjectStoreBaseConfig", |
| 75 | + "ObjectStoreItem", |
| 76 | + "OptionalSecretStr", |
| 77 | + "USING_PLUGIN_API", |
| 78 | + "get_secret_value", |
| 79 | + "register_function", |
| 80 | + "register_memory", |
| 81 | + "register_object_store", |
| 82 | +] |
0 commit comments