diff --git a/cdp-langchain/cdp_langchain/__init__.py b/cdp-langchain/cdp_langchain/__init__.py index 8b1378917..40cfa16b9 100644 --- a/cdp-langchain/cdp_langchain/__init__.py +++ b/cdp-langchain/cdp_langchain/__init__.py @@ -1 +1,3 @@ +from cdp_langchain.__version__ import __version__ +__all__ = ["__version__"] diff --git a/cdp-langchain/cdp_langchain/__version__.py b/cdp-langchain/cdp_langchain/__version__.py new file mode 100644 index 000000000..f102a9cad --- /dev/null +++ b/cdp-langchain/cdp_langchain/__version__.py @@ -0,0 +1 @@ +__version__ = "0.0.1" diff --git a/cdp-langchain/cdp_langchain/constants.py b/cdp-langchain/cdp_langchain/constants.py new file mode 100644 index 000000000..c3b1c3dd2 --- /dev/null +++ b/cdp-langchain/cdp_langchain/constants.py @@ -0,0 +1,4 @@ +"""Specifies package level constants used throughout the package.""" + +# CDP_LANGCHAIN_DEFAULT_SOURCE (str): Denotes the default source for CDP Langchain Agentkit extensions. +CDP_LANGCHAIN_DEFAULT_SOURCE = "cdp-langchain" diff --git a/cdp-langchain/cdp_langchain/utils/cdp_agentkit_wrapper.py b/cdp-langchain/cdp_langchain/utils/cdp_agentkit_wrapper.py index f4f6dfbff..c15555bcd 100644 --- a/cdp-langchain/cdp_langchain/utils/cdp_agentkit_wrapper.py +++ b/cdp-langchain/cdp_langchain/utils/cdp_agentkit_wrapper.py @@ -9,6 +9,8 @@ from pydantic import BaseModel, model_validator from cdp import Wallet +from cdp_langchain import __version__ +from cdp_langchain.constants import CDP_LANGCHAIN_DEFAULT_SOURCE class CdpAgentkitWrapper(BaseModel): @@ -37,7 +39,12 @@ def validate_environment(cls, values: dict) -> Any: "CDP SDK is not installed. " "Please install it with `pip install cdp-sdk`" ) from None - Cdp.configure(cdp_api_key_name, cdp_api_key_private_key) + Cdp.configure( + api_key_name=cdp_api_key_name, + private_key=cdp_api_key_private_key, + source=CDP_LANGCHAIN_DEFAULT_SOURCE, + source_version=__version__, + ) if wallet_data_json: wallet_data = WalletData.from_dict(json.loads(wallet_data_json)) diff --git a/cdp-langchain/tests/utils/test_cdp_agentkit_wrapper.py b/cdp-langchain/tests/utils/test_cdp_agentkit_wrapper.py index 6dc92b655..9820aefd2 100644 --- a/cdp-langchain/tests/utils/test_cdp_agentkit_wrapper.py +++ b/cdp-langchain/tests/utils/test_cdp_agentkit_wrapper.py @@ -7,6 +7,8 @@ from pydantic import ValidationError from cdp import Cdp, Wallet, WalletData +from cdp_langchain import __version__ +from cdp_langchain.constants import CDP_LANGCHAIN_DEFAULT_SOURCE from cdp_langchain.utils import CdpAgentkitWrapper @@ -62,7 +64,10 @@ def test_initialization_with_env_vars( assert wrapper.wallet is not None mock_cdp_configure.assert_called_once_with( - env_vars["CDP_API_KEY_NAME"], env_vars["CDP_API_KEY_PRIVATE_KEY"] + api_key_name=env_vars["CDP_API_KEY_NAME"], + private_key=env_vars["CDP_API_KEY_PRIVATE_KEY"], + source=CDP_LANGCHAIN_DEFAULT_SOURCE, + source_version=__version__, ) mock_wallet_create.assert_called_once_with(network_id=env_vars["NETWORK_ID"]) @@ -83,7 +88,10 @@ def test_initialization_with_direct_values(mock_cdp_configure: Mock, mock_wallet assert wrapper.network_id == test_values["network_id"] mock_cdp_configure.assert_called_once_with( - test_values["cdp_api_key_name"], test_values["cdp_api_key_private_key"] + api_key_name=test_values["cdp_api_key_name"], + private_key=test_values["cdp_api_key_private_key"], + source=CDP_LANGCHAIN_DEFAULT_SOURCE, + source_version=__version__, ) mock_wallet_create.assert_called_once_with(network_id=test_values["network_id"]) @@ -110,7 +118,10 @@ def test_initialization_with_direct_values_and_persisted_wallet( assert wrapper.network_id == test_values["network_id"] mock_cdp_configure.assert_called_once_with( - test_values["cdp_api_key_name"], test_values["cdp_api_key_private_key"] + api_key_name=test_values["cdp_api_key_name"], + private_key=test_values["cdp_api_key_private_key"], + source=CDP_LANGCHAIN_DEFAULT_SOURCE, + source_version=__version__, ) mock_wallet_import_data.assert_called_once()