Guide to use reddit tool on your AI agent using Vity Toolkit
Details
AuthType.API_KEYQuick Start
1
npm install vity-toolkit langchain @langchain/openai2
import { ChatOpenAI } from "@langchain/openai";
import { App, LangchainToolkit } from "vity-toolkit";
import { createOpenAIFunctionsAgent, AgentExecutor } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";
const llm = new ChatOpenAI({ model: "gpt-4o" });
const toolKit = new LangchainToolkit({
appPrivateKey: "<app-wallet-private-key>",
userPrivateKey: "<user-wallet-private-key>",
});3
const tools = toolKit.getTools({ apps: [App.SOLANA_WALLET] });4
const prompt = ChatPromptTemplate.fromMessages([
["system", `You are an AI agent responsible for taking actions on Reddit on users' behalf.
You need to take action on Reddit using Reddit APIs. Use correct tools to run APIs from the given tool-set.`],
["placeholder", "{chat_history}"],
["human", "{input}"],
["placeholder", "{agent_scratchpad}"],
]);
const agent = await createOpenAIFunctionsAgent({
llm,
tools,
prompt,
});
const agentExecutor = new AgentExecutor({ agent, tools, verbose: true });5
const response = await agentExecutor.invoke({ input: "Fetch newest 1 post from solana on pump.fun and comment `GM` on that post." });
console.log(response);Supported Actions
Action
Description
Action.REDDIT_FILTERAction.REDDIT_COMMENTAction.REDDIT_CREATE_POSTAction.REDDIT_DELETE_POSTLast updated