Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameters to CdpAgentkitWrapper used for monitoring #29

Merged
merged 7 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cdp-langchain/cdp_langchain/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from cdp_langchain.__version__ import __version__

__all__ = ["__version__"]
1 change: 1 addition & 0 deletions cdp-langchain/cdp_langchain/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1"
4 changes: 4 additions & 0 deletions cdp-langchain/cdp_langchain/constants.py
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 8 additions & 1 deletion cdp-langchain/cdp_langchain/utils/cdp_agentkit_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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))
Expand Down
17 changes: 14 additions & 3 deletions cdp-langchain/tests/utils/test_cdp_agentkit_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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"])
Expand All @@ -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"])
Expand All @@ -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()
Expand Down
Loading