Skip to content

Commit

Permalink
fix: cdp-langchain README quickstart code samples (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
John-peterson-coinbase authored Dec 7, 2024
1 parent 54b37e3 commit e55b25c
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions cdp-langchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export NETWORK_ID=base-sepolia # Optional: Defaults to base-sepolia

```typescript
import { CdpToolkit } from "@coinbase/cdp-langchain";
import { CdpAgentKit } from "@coinbase/cdp-agentkit-core";
import { CdpAgentkit } from "@coinbase/cdp-agentkit-core";

// Initialize CDP AgentKit
const agentkit = CdpAgentKit.configureWithWallet();
const agentkit = await CdpAgentkit.configureWithWallet();

// Create toolkit
const toolkit = new CdpToolkit(agentkit);
Expand Down Expand Up @@ -66,25 +66,26 @@ The toolkit provides the following tools:

```typescript
import { ChatOpenAI } from "@langchain/openai";
import { initializeAgentExecutorWithOptions } from "langchain/agents";
import { HumanMessage } from "@langchain/core/messages";
import { createReactAgent } from "@langchain/langgraph/prebuilt";

// Initialize LLM
const model = new ChatOpenAI({
model: "gpt-4o-mini",
});

// Create agent executor
const executor = await initializeAgentExecutorWithOptions(toolkit.getTools(), model, {
agentType: "chat-conversational-react-description",
verbose: true,
const agent = createReactAgent({
llm: model,
tools,
});

// Example usage
const result = await executor.invoke({
input: "Send 0.005 ETH to john2879.base.eth",
const result = await agent.invoke({
messages: [new HumanMessage("Send 0.005 ETH to john2879.base.eth")],
});

console.log(result.output);
console.log(result.messages[result.messages.length - 1].content);
```

## CDP Toolkit Specific Features
Expand All @@ -98,7 +99,7 @@ The toolkit maintains an MPC wallet that persists between sessions:
const walletData = await agentkit.exportWallet();

// Import wallet data
const importedAgentKit = CdpAgentKit.configureWithWallet({ cdpWalletData: walletData });
const importedAgentkit = await CdpAgentkit.configureWithWallet({ cdpWalletData: walletData });
```

### Network Support
Expand Down

0 comments on commit e55b25c

Please sign in to comment.