Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f989e91
Merge pull request #3 from coinbase/add-changelog
John-peterson-coinbase Nov 4, 2024
b4d3036
chore: Use Released Version of cdp-agentkit-core as dep in Ext's (#6)
John-peterson-coinbase Nov 5, 2024
f34358f
chore: Fix README Badges (#7)
John-peterson-coinbase Nov 5, 2024
8b65087
feat: github workflow for documentation generation and publishing to …
stat Nov 5, 2024
9d1de43
removing additional matrix.python references and coding for 3.10 (#8)
stat Nov 5, 2024
ac3fafc
Added support for creating a Uniswap V3 liquidity pool (#5)
rohan-agarwal-coinbase Nov 5, 2024
1af79f5
feat: github workflows for publishing agentkit and langchain to pypi …
stat Nov 5, 2024
b4214af
feat: Scaffolding for Twitter Langchain Toolkit (#10)
John-peterson-coinbase Nov 5, 2024
39b4c2a
Refactoring READMEs and CONTRIBUTING.md (#11)
rohan-agarwal-coinbase Nov 5, 2024
239e4e9
chore: Publish Docs on Manual Trigger (#13)
John-peterson-coinbase Nov 6, 2024
2cbd20f
fix: GHA Docs Generation - Checkout repo step (#14)
John-peterson-coinbase Nov 6, 2024
7705b20
fix: Run commands inside poetry virtualenv (#15)
John-peterson-coinbase Nov 6, 2024
44f302c
fix: GHA Docs - Use 1 root dir for docs site (#16)
John-peterson-coinbase Nov 6, 2024
c3d547a
fix: GHA API Docs - Dirout Structure (#17)
John-peterson-coinbase Nov 6, 2024
0846441
feat: implementing action for twitter post tweet (#12)
stat Nov 6, 2024
e738a2e
fix env vars export in readme #18
jazz-cb Nov 7, 2024
63eb7cc
feat: Export Agentic Wallet Default Address ID (#19)
John-peterson-coinbase Nov 7, 2024
69438c3
fix: Remove README Release Widget (#20)
John-peterson-coinbase Nov 7, 2024
3c2682b
chore: Remove Action enumeration/re-implementation in Framework Exts …
John-peterson-coinbase Nov 7, 2024
2393768
chore: Add PR Template (#26)
John-peterson-coinbase Nov 7, 2024
fe9e109
Actions for getting uniswap v3 pool contract address, liquidity, slot…
rohan-agarwal-coinbase Nov 7, 2024
9126e73
feat: action for twitter account details (#23)
stat Nov 7, 2024
bfabef0
chore: Remove Uniswap functionality (#27)
alex-stone Nov 7, 2024
9f3643b
chore: Catch errors in core actions
John-peterson-coinbase Nov 7, 2024
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
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### What changed? Why?


#### Qualified Impact
<!-- Please evaluate what components could be affected and what the impact would be if there was an
error. How would this error be resolved, e.g. rollback a deploy, push a new fix, disable a feature
flag, etc... -->
51 changes: 51 additions & 0 deletions .github/workflows/publish_agentkit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Release AgentKit to PyPI

on:
workflow_dispatch:

jobs:
deploy-agentkit:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./cdp-agentkit-core
environment:
name: pypi
url: https://pypi.org/p/cdp-agentkit-core
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: ./cdp-agentkit-core/.venv
key: venv-agentkit-${{ runner.os }}-3.10-${{ hashFiles('cdp-agentkit-core/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install

- name: Build package
run: poetry build

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
77 changes: 77 additions & 0 deletions .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Publish Docs to Github Pages

on:
workflow_dispatch:

jobs:
build-and-deploy-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv for cdp-agentkit-core
id: cached-poetry-dependencies-core
uses: actions/cache@v3
with:
path: ./cdp-agentkit-core/.venv
key: venv-agentkit-${{ runner.os }}-3.10-${{ hashFiles('cdp-agentkit-core/poetry.lock') }}

- name: Install dependencies for cdp-agentkit-core
if: steps.cached-poetry-dependencies-core.outputs.cache-hit != 'true'
run: |
cd cdp-agentkit-core
poetry install --with dev
cd ..

- name: Build Sphinx Documentation for cdp-agentkit-core
run: |
cd cdp-agentkit-core
poetry run make docs
cd docs
poetry run make html
cd ../..
mkdir -p docs/cdp-agentkit-core
cp -r cdp-agentkit-core/docs/_build/html/* docs/cdp-agentkit-core

- name: Load cached venv for cdp-langchain
id: cached-poetry-dependencies-langchain
uses: actions/cache@v3
with:
path: ./cdp-langchain/.venv
key: venv-langchain-${{ runner.os }}-3.10-${{ hashFiles('cdp-langchain/poetry.lock') }}

- name: Install dependencies for cdp-langchain
if: steps.cached-poetry-dependencies-langchain.outputs.cache-hit != 'true'
run: |
cd cdp-langchain
poetry install --with dev
cd ..

- name: Build Sphinx Documentation for cdp-langchain
run: |
cd cdp-langchain
poetry run make docs
cd docs
poetry run make html
cd ../..
mkdir -p docs/cdp-langchain
cp -r cdp-langchain/docs/_build/html/* docs/cdp-langchain

- name: Deploy to Github Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
keep_files: false
51 changes: 51 additions & 0 deletions .github/workflows/publish_langchain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Release LangChain to PyPI

on:
workflow_dispatch:

jobs:
deploy-langchain:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./cdp-langchain
environment:
name: pypi
url: https://pypi.org/p/cdp-langchain
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: ./cdp-langchain/.venv
key: venv-langchain-${{ runner.os }}-3.10-${{ hashFiles('cdp-langchain/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install

- name: Build package
run: poetry build

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
# Environment Configurations
**/env/
**/.env/
**/.env
**/.env.local/
**/.env.test/
139 changes: 137 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# CDP Agentkit Contributing Guide
Thank you for your interest in contributing to CDP Agentkit! We welcome all contributions, no matter how big or small. Some of the ways you can contribute include:
- Adding new actions to the core package
- Updating existing Langchain Toolkits or adding new Langchain Toolkits to support new tools
- Creating new AI frameworks extensions
- Adding tests and improving documentation

## Development

### Python Version
### Prerequisites
- Python 3.10 or higher
- Rust/Cargo installed ([Rust Installation Instructions](https://doc.rust-lang.org/cargo/getting-started/installation.html))
- Poetry for package management and tooling
- [Poetry Installation Instructions](https://python-poetry.org/docs/#installation)

Developing in this repository requires Python 3.10 or higher.
`cdp-langchain` also requires a [CDP API Key](https://portal.cdp.coinbase.com/access/api).

### Set-up

Expand All @@ -13,3 +22,129 @@ Clone the repo by running:
```bash
git clone git@github.com:coinbase/cdp-agentkit.git
```

## Adding an Action to Agentkit Core
- Actions are defined in `./cdp_agentkit_core/actions` module. See `./cdp_agentkit_core/actions/mint_nft.py` for an example.
- Actions are created by subclassing `CdpAction`
E.g.
```python
class DeployNftAction(CdpAction):
"""Deploy NFT action."""

name: str = "mint_nft"
description: str = MINT_NFT_PROMPT
args_schema: type[BaseModel] | None = MintNftInput
func: Callable[..., str] = mint_nft
```

### Components of an Agentic Action
- `name` - Name of the action.
- `description` - A string that will provide the AI Agent with context on what the function does and a natural language description of the input.
- E.g.
```python
MINT_NFT_PROMPT = """
This tool will mint an NFT (ERC-721) to a specified destination address onchain via a contract invocation. It takes the contract address of the NFT onchain and the destination address onchain that will receive the NFT as inputs."""
```
- `arg_schema` - A Pydantic Model that defines the input argument schema for the action.
- E.g.
```python
class MintNftInput(BaseModel):
"""Input argument schema for mint NFT action."""

contract_address: str = Field(
...,
description="The contract address of the NFT (ERC-721) to mint, e.g. `0x036CbD53842c5426634e7929541eC2318f3dCF7e`",
)
destination: str = Field(
...,
description="The destination address that will receieve the NFT onchain, e.g. `0x036CbD53842c5426634e7929541eC2318f3dCF7e`",
)
```
- `func` - A function (or Callable class) that executes the action.
- E.g.
```python
def mint_nft(wallet: Wallet, contract_address: str, destination: str) -> str:
"""Mint an NFT (ERC-721) to a specified destination address onchain via a contract invocation.

Args:
wallet (Wallet): The wallet to trade the asset from.
contract_address (str): The contract address of the NFT (ERC-721) to mint, e.g. `0x036CbD53842c5426634e7929541eC2318f3dCF7e`.
destination (str): The destination address that will receieve the NFT onchain, e.g. `0x036CbD53842c5426634e7929541eC2318f3dCF7e`.

Returns:
str: A message containing the NFT mint details.

"""
mint_args = {"to": destination, "quantity": "1"}

mint_invocation = wallet.invoke_contract(
contract_address=contract_address, method="mint", args=mint_args
).wait()

return f"Minted NFT from contract {contract_address} to address {destination} on network {wallet.network_id}.\nTransaction hash for the mint: {mint_invocation.transaction.transaction_hash}\nTransaction link for the mint: {mint_invocation.transaction.transaction_link}"
```

## Adding an Agentic Action to Langchain Toolkit
1. Ensure the action is implemented in `cdp-agentkit-core` and in a released version.
2. Update the `cdp-agentkit-core` dependency to the latest version.
3. Add the action to the list of tools in the `CdpToolkit` class documentation.

## Adding an Agentic Action to the Twitter Toolkit
1. Ensure the action is implemented in `cdp-agentkit-core/actions/social/twitter`.
2. Add a wrapper method to `TwitterApiWrapper` in `./twitter_langchain/twitter_api_wrapper.py`
- E.g.
```python
def post_tweet_wrapper(self, tweet: str) -> str:
"""Post tweet to Twitter.

Args:
client (tweepy.Client): The tweepy client to use.
tweet (str): The text of the tweet to post to twitter. Tweets can be maximum 280 characters.

Returns:
str: A message containing the result of the post action and the tweet.

"""

return post_tweet(client=self.client, tweet=tweet)
```
3. Add call to the wrapper in `TwitterApiWrapper.run` in `./twitter_langchain/twitter_api_wrapper.py`
- E.g.
```python
if mode == "post_tweet":
return self.post_tweet_wrapper(**kwargs)

```
4. Add the action to the list of available tools in the `TwitterToolkit` in `./twitter_langchain/twitter_toolkit.py`
- E.g.
```python
actions: List[Dict] = [
{
"mode": "post_tweet",
"name": "post_tweet",
"description": POST_TWEET_PROMPT,
"args_schema": PostTweetInput,
},
]
```
5. Update `TwitterToolkit` documentation
- Add the action to the list of tools
- Add any additional ENV requirements

## Development Tools
### Formatting
`make format`

### Linting
- Check linter
`make lint`

- Fix linter errors
`make lint-fix`

### Unit Testing
- Run unit tests
`make test`

## Changelog
- For new features and bug fixes, please add a new changelog entry to the `CHANGELOG.md` file in the appropriate packages and include that in your Pull Request.
Loading