-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial commit * Initial commit * multichain * multi chain support * test * Test * Update * Add changeset * Fix lockfile --------- Co-authored-by: Agustin Armellini Fischer <[email protected]>
- Loading branch information
1 parent
a21a1f3
commit 3d3dc2e
Showing
14 changed files
with
828 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"goat-examples-langchain-safe": patch | ||
"@goat-sdk/wallet-safe": patch | ||
--- | ||
|
||
Release package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
OPENAI_API_KEY= | ||
WALLET_PRIVATE_KEY= | ||
RPC_PROVIDER_URL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Langchain with viem Example | ||
|
||
## Setup | ||
|
||
Copy the `.env.template` and populate with your values. | ||
|
||
``` | ||
cp .env.template .env | ||
``` | ||
|
||
## Usage | ||
|
||
``` | ||
npx ts-node index.ts | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { ChatPromptTemplate } from "@langchain/core/prompts"; | ||
import { Ollama } from "@langchain/ollama"; | ||
import { AgentExecutor, createStructuredChatAgent } from "langchain/agents"; | ||
import { pull } from "langchain/hub"; | ||
|
||
import { baseSepolia } from "viem/chains"; | ||
|
||
import { getOnChainTools } from "@goat-sdk/adapter-langchain"; | ||
|
||
import { sendETH } from "@goat-sdk/wallet-evm"; | ||
import { safe } from "@goat-sdk/wallet-safe"; | ||
|
||
require("dotenv").config(); | ||
|
||
const pk = process.env.WALLET_PRIVATE_KEY as `0x${string}`; | ||
|
||
const llm = new Ollama({ | ||
model: "llama3.2:latest", | ||
}); | ||
|
||
(async (): Promise<void> => { | ||
const prompt = await pull<ChatPromptTemplate>("hwchase17/structured-chat-agent"); | ||
|
||
const tools = await getOnChainTools({ | ||
// The wallet will be deployed on chain and requires eth beforehand. | ||
wallet: await safe(pk, baseSepolia), | ||
plugins: [sendETH()], | ||
}); | ||
|
||
const agent = await createStructuredChatAgent({ | ||
llm, | ||
tools, | ||
prompt, | ||
}); | ||
|
||
const agentExecutor = new AgentExecutor({ | ||
agent, | ||
tools, | ||
}); | ||
|
||
const response = await agentExecutor.invoke({ | ||
input: "Send 0.00000 eth to 0x0000000000000000000000000000000000000000", | ||
}); | ||
|
||
console.log(response); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "goat-examples-langchain-safe", | ||
"version": "0.1.0", | ||
"description": "", | ||
"private": true, | ||
"scripts": { | ||
"test": "vitest run --passWithNoTests" | ||
}, | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@goat-sdk/adapter-langchain": "workspace:*", | ||
"@goat-sdk/core": "workspace:*", | ||
"@goat-sdk/plugin-erc20": "workspace:*", | ||
"@goat-sdk/wallet-evm": "workspace:*", | ||
"@goat-sdk/wallet-safe": "workspace:*", | ||
"@langchain/core": "catalog:", | ||
"@langchain/ollama": "0.1.5", | ||
"@langchain/openai": "^0.3.5", | ||
"ai": "4.1.15", | ||
"dotenv": "^16.4.5", | ||
"langchain": "^0.3.2", | ||
"viem": "2.21.49" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
}, | ||
"include": ["index.ts"], | ||
"exclude": ["node_modules", "dist"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Goat Wallet Viem 🐐 - TypeScript | ||
|
||
## Installation | ||
``` | ||
npm install @goat-sdk/wallet-safe | ||
``` | ||
|
||
## Usage | ||
```typescript | ||
import { createWalletClient } from "viem"; | ||
import { privateKeyToAccount } from "viem/accounts"; | ||
import { sepolia } from "viem/chains"; | ||
import { http } from "viem"; | ||
|
||
import { getOnChainTools } from "@goat-sdk/adapter-vercel-ai"; | ||
import { SafeWalletClient } from "./src"; | ||
|
||
const pk = process.env.WALLET_PRIVATE_KEY as `0x${string}` | ||
|
||
const tools = await getOnChainTools({ | ||
wallet: new SafeWalletClient(pk, sepolia), | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "@goat-sdk/wallet-safe", | ||
"version": "0.1.0", | ||
"sideEffects": false, | ||
"files": ["dist/**/*", "README.md", "package.json"], | ||
"scripts": { | ||
"build": "tsup", | ||
"clean": "rm -rf dist", | ||
"test": "vitest run --passWithNoTests" | ||
}, | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"dependencies": { | ||
"@goat-sdk/core": "workspace:*", | ||
"@goat-sdk/wallet-evm": "workspace:*", | ||
"@safe-global/protocol-kit": "5.2.1", | ||
"@safe-global/safe-core-sdk-types": "5.1.0", | ||
"permissionless": "0.2.28", | ||
"viem": "catalog:" | ||
}, | ||
"peerDependencies": { | ||
"@goat-sdk/core": "workspace:*", | ||
"@goat-sdk/wallet-evm": "workspace:*", | ||
"viem": "catalog:" | ||
}, | ||
"homepage": "https://ohmygoat.dev", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/goat-sdk/goat.git" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/goat-sdk/goat/issues" | ||
}, | ||
"keywords": ["ai", "agents", "web3"] | ||
} |
Oops, something went wrong.