Skip to content

Commit

Permalink
chore: Fix example for python (#209)
Browse files Browse the repository at this point in the history
Fix example for python
  • Loading branch information
0xaguspunk authored Jan 10, 2025
1 parent abab0a2 commit 66a63c3
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 174 deletions.
4 changes: 0 additions & 4 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@

[Docs](https://ohmygoat.dev) | [Examples](https://github.com/goat-sdk/goat/tree/main/typescript/examples) | [Discord](https://discord.gg/goat-sdk)

## Development

1. Clone the repo
2. Install the dependencies: `poetry install`
3. Build the packages: `poetry build`
2 changes: 1 addition & 1 deletion python/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
## Langchain

### EVM
- [web3.py](https://github.com/goat-sdk/goat/tree/main/python/examples/langchain/web3)
- [web3.py](https://github.com/goat-sdk/goat/tree/main/python/examples/langchain/web3)
3 changes: 3 additions & 0 deletions python/examples/langchain/web3/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OPENAI_API_KEY=
WALLET_PRIVATE_KEY=
RPC_PROVIDER_URL=
21 changes: 21 additions & 0 deletions python/examples/langchain/web3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Langchain web3 Example

## Setup

Copy the `.env.template` and populate with your values.

```
cp .env.template .env
```

Install dependencies

```
poetry install
```

## Usage

```
poetry run example.py
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import os
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_structured_chat_agent
from langchain.hub import pull
Expand All @@ -14,9 +18,6 @@
from goat_wallets.evm import send_eth
from goat_wallets.web3 import Web3EVMWalletClient

# Load environment variables
load_dotenv()

# Initialize Web3 and account
w3 = Web3(Web3.HTTPProvider(os.getenv("RPC_PROVIDER_URL")))
private_key = os.getenv("WALLET_PRIVATE_KEY")
Expand Down Expand Up @@ -45,7 +46,7 @@ def main():
agent = create_structured_chat_agent(llm=llm, tools=tools, prompt=prompt)

# Create the executor
agent_executor = AgentExecutor(agent=agent, tools=tools)
agent_executor = AgentExecutor(agent=agent, tools=tools, handle_parsing_errors=True)

# Execute the agent
response = agent_executor.invoke({"input": "Get my balance in USDC"})
Expand Down

Large diffs are not rendered by default.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry.group.dev.dependencies]
ruff = "^0.8.6"
goat-sdk = { path = "../../src/goat-sdk", develop = true }
goat-sdk-wallet-evm = { path = "../../src/wallets/evm", develop = true }
goat-sdk-wallet-web3 = { path = "../../src/wallets/web3", develop = true }
goat-sdk-plugin-erc20 = { path = "../../src/plugins/erc20", develop = true }
goat-sdk-adapter-langchain = { path = "../../src/adapters/langchain", develop = true }
goat-sdk = { path = "../../../src/goat-sdk", develop = true }
goat-sdk-wallet-evm = { path = "../../../src/wallets/evm", develop = true }
goat-sdk-wallet-web3 = { path = "../../../src/wallets/web3", develop = true }
goat-sdk-plugin-erc20 = { path = "../../../src/plugins/erc20", develop = true }
goat-sdk-adapter-langchain = { path = "../../../src/adapters/langchain", develop = true }

[tool.ruff]
line-length = 120
Expand Down

0 comments on commit 66a63c3

Please sign in to comment.