Skip to content
Draft
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: 1 addition & 1 deletion typescript/agentkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@coinbase/coinbase-sdk": "^0.20.0",
"@jup-ag/api": "^6.0.39",
"@privy-io/server-auth": "^1.18.4",
"@solana/spl-token": "^0.4.12",
"@solana/spl-token": "^0.4.14",
"@solana/web3.js": "^1.98.0",
"md5": "^2.3.0",
"opensea-js": "^7.1.18",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AgentRequest, AgentResponse } from "@/app/types/api";
import { NextResponse } from "next/server";
import { createAgent } from "./create-agent";
import { Message, generateId, generateText } from "ai";
import { UIMessage, generateId, generateText, convertToModelMessages } from "ai";

const messages: Message[] = [];
const messages: UIMessage[] = [];

/**
* Handles incoming POST requests to interact with the AgentKit-powered AI agent.
Expand Down Expand Up @@ -33,14 +33,22 @@ export async function POST(
const agent = await createAgent();

// 3.Start streaming the agent's response
messages.push({ id: generateId(), role: "user", content: userMessage });
messages.push({
id: generateId(),
role: "user",
parts: [{ type: "text", text: userMessage }],
});
const { text } = await generateText({
...agent,
messages,
messages: await convertToModelMessages(messages),
});

// 4. Add the agent's response to the messages
messages.push({ id: generateId(), role: "assistant", content: text });
messages.push({
id: generateId(),
role: "assistant",
parts: [{ type: "text", text }],
});

// 5️. Return the final response
return NextResponse.json({ response: text });
Expand Down
12 changes: 6 additions & 6 deletions typescript/create-onchain-agent/templates/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
"lint": "next lint"
},
"dependencies": {
"@ai-sdk/openai": "^1.2.1",
"@ai-sdk/openai": "^3.0.2",
"@coinbase/agentkit": "^0.4.0",
"@coinbase/agentkit-langchain": "^0.3.0",
"@coinbase/agentkit-vercel-ai-sdk": "^0.1.0",
"@langchain/core": "^0.3.19",
"@langchain/core": "^0.3.80",
"@langchain/langgraph": "^0.2.21",
"@langchain/openai": "^0.3.14",
"@solana/web3.js": "^1.98.0",
"@tanstack/react-query": "^5",
"ai": "^4.1.54",
"ai": "^6.0.5",
"bs58": "^6.0.0",
"next": "14.2.32",
"next": "14.2.35",
"react": "^18",
"react-dom": "^18",
"react-markdown": "^10.0.0",
Expand All @@ -31,8 +31,8 @@
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.2.32",
"eslint": "^9",
"eslint-config-next": "16.1.1",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5"
Expand Down
2 changes: 1 addition & 1 deletion typescript/examples/langchain-cdp-chatbot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@coinbase/agentkit-langchain": "^0.3.0",
"@langchain/langgraph": "^0.2.21",
"@langchain/openai": "^0.3.14",
"@langchain/core": "^0.3.19",
"@langchain/core": "^0.3.80",
"dotenv": "^16.4.5",
"zod": "^3.22.4"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@coinbase/agentkit": "^0.4.0",
"@coinbase/agentkit-langchain": "^0.3.0",
"@langchain/core": "0.3.30",
"@langchain/core": "^0.3.80",
"@langchain/langgraph": "^0.2.39",
"@langchain/openai": "^0.3.16",
"dotenv": "^16.4.5",
Expand Down
2 changes: 1 addition & 1 deletion typescript/examples/langchain-privy-chatbot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@coinbase/agentkit-langchain": "^0.3.0",
"@langchain/langgraph": "^0.2.21",
"@langchain/openai": "^0.3.14",
"@langchain/core": "^0.3.19",
"@langchain/core": "^0.3.80",
"dotenv": "^16.4.5",
"zod": "^3.22.4"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@coinbase/agentkit-langchain": "^0.3.0",
"@langchain/langgraph": "^0.2.21",
"@langchain/openai": "^0.3.14",
"@langchain/core": "^0.3.19",
"@langchain/core": "^0.3.80",
"dotenv": "^16.4.5",
"zod": "^3.22.4"
},
Expand Down
2 changes: 1 addition & 1 deletion typescript/examples/langchain-solana-chatbot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@coinbase/agentkit-langchain": "^0.3.0",
"@langchain/langgraph": "^0.2.21",
"@langchain/openai": "^0.3.14",
"@langchain/core": "^0.3.19",
"@langchain/core": "^0.3.80",
"dotenv": "^16.4.5",
"zod": "^3.22.4"
},
Expand Down
2 changes: 1 addition & 1 deletion typescript/examples/langchain-twitter-chatbot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@coinbase/agentkit-langchain": "^0.3.0",
"@langchain/langgraph": "^0.2.21",
"@langchain/openai": "^0.3.14",
"@langchain/core": "^0.3.19",
"@langchain/core": "^0.3.80",
"dotenv": "^16.4.5",
"zod": "^3.22.4"
},
Expand Down
32 changes: 24 additions & 8 deletions typescript/examples/vercel-ai-sdk-cdp-chatbot/chatbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@coinbase/agentkit";
import { getVercelAITools } from "@coinbase/agentkit-vercel-ai-sdk";
import { openai } from "@ai-sdk/openai";
import { generateId, Message, streamText, ToolSet } from "ai";
import { generateId, UIMessage, streamText, ToolSet, convertToModelMessages } from "ai";
import * as dotenv from "dotenv";
import * as readline from "readline";
import * as fs from "fs";
Expand Down Expand Up @@ -128,7 +128,7 @@ async function runChatMode(tools: ToolSet) {
const question = (prompt: string): Promise<string> =>
new Promise(resolve => rl.question(prompt, resolve));

const messages: Message[] = [];
const messages: UIMessage[] = [];
let running = true;

try {
Expand All @@ -140,7 +140,11 @@ async function runChatMode(tools: ToolSet) {
continue;
}

messages.push({ id: generateId(), role: "user", content: userInput });
messages.push({
id: generateId(),
role: "user",
parts: [{ type: "text", text: userInput }],
});

const stream = streamText({
model: openai("gpt-4o-mini"),
Expand All @@ -157,7 +161,11 @@ async function runChatMode(tools: ToolSet) {
}
console.log("\n-------------------");

messages.push({ id: generateId(), role: "assistant", content: assistantMessage });
messages.push({
id: generateId(),
role: "assistant",
parts: [{ type: "text", text: assistantMessage }],
});
}
} catch (error) {
console.error("Error:", error);
Expand All @@ -175,7 +183,7 @@ async function runChatMode(tools: ToolSet) {
async function runAutonomousMode(tools: ToolSet, interval = 10) {
console.log("Starting autonomous mode...");

const messages: Message[] = [];
const messages: UIMessage[] = [];

// eslint-disable-next-line no-constant-condition
while (true) {
Expand All @@ -184,11 +192,15 @@ async function runAutonomousMode(tools: ToolSet, interval = 10) {
"Be creative and do something interesting on the blockchain. " +
"Choose an action or set of actions and execute it that highlights your abilities.";

messages.push({ id: generateId(), role: "user", content: thought });
messages.push({
id: generateId(),
role: "user",
parts: [{ type: "text", text: thought }],
});

const stream = streamText({
model: openai("gpt-4o-mini"),
messages,
messages: await convertToModelMessages(messages),
tools,
system,
maxSteps: 10,
Expand All @@ -201,7 +213,11 @@ async function runAutonomousMode(tools: ToolSet, interval = 10) {
}
console.log("\n-------------------");

messages.push({ id: generateId(), role: "assistant", content: assistantMessage });
messages.push({
id: generateId(),
role: "assistant",
parts: [{ type: "text", text: assistantMessage }],
});

await new Promise(resolve => setTimeout(resolve, interval * 1000));
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions typescript/examples/vercel-ai-sdk-cdp-chatbot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"format:check": "prettier -c .prettierrc --check \"**/*.{ts,js,cjs,json,md}\""
},
"dependencies": {
"@ai-sdk/openai": "^1.1.9",
"@ai-sdk/openai": "^3.0.2",
"@coinbase/agentkit": "^0.4.0",
"@coinbase/agentkit-vercel-ai-sdk": "^0.1.0",
"ai": "^4.1.16",
"ai": "^6.0.5",
"dotenv": "^16.4.5",
"tsx": "^4.7.1",
"zod": "^3.22.4"
Expand Down
2 changes: 1 addition & 1 deletion typescript/framework-extensions/langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"langchain"
],
"dependencies": {
"@langchain/core": "^0.3.19",
"@langchain/core": "^0.3.80",
"zod": "^3.22.4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion typescript/framework-extensions/vercel-ai-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
},
"peerDependencies": {
"@coinbase/agentkit": ">=0.1.0",
"ai": "^4.1.16"
"ai": "^6.0.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getVercelAITools(agentKit: AgentKit): ToolSet {
return actions.reduce((acc, action) => {
acc[action.name] = tool({
description: action.description,
parameters: action.schema,
inputSchema: action.schema,
execute: async (args: z.output<typeof action.schema>) => {
const result = await action.invoke(args);
return result;
Expand Down
Loading