Vity Toolkit
TelegramTwitterGithubRequest new tool
  • Introduction
    • Vity Toolkit
    • 🚀Quick Start - Langchain
    • 🚀Quick Start - Vercel AI
  • Features
    • Apps and Actions
    • How can I use Action directly?
    • Agent Authentication
    • Extensions
  • Tools
    • Superteam Earn
    • Solana Wallet
    • Reddit
    • Gibwork
    • Twitter
  • EXAMPLES
    • AI Bounty Finder
Powered by GitBook
On this page
  • Quick Start
  • Supported Actions
  1. Tools

Reddit

Guide to use reddit tool on your AI agent using Vity Toolkit

PreviousSolana WalletNextGibwork

Last updated 5 months ago

Reddit is a social news and discussion website where users can share and vote on content, and participate in communities called subreddits.

Details

Supported Auth Type

Quick Start

1

Install the package.

npm install vity-toolkit langchain @langchain/openai
2

Initialize Vity Toolkit and Langchain.

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>",
});

Make sure that you already have .

3

Add the tool.

const tools = toolKit.getTools({ apps: [App.SOLANA_WALLET] });
4

Define the Agent.

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

Execute the Agent.

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

Filter the posts in a subreddit by a query.

Comment on a post in a subreddit.

Create a new post in a subreddit.

Delete a post.

AuthType.API_KEY
Action.REDDIT_FILTER
Action.REDDIT_COMMENT
Action.REDDIT_CREATE_POST
Action.REDDIT_DELETE_POST
integrated and connected the app