Github
Guide to use github 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 P = (globalThis as any).process;
const model = new ChatOpenAI({ model: "gpt-4o" });
const toolKit = new LangchainToolkit({
userPrivateKey: P?.env?.SOLANA_PRIVATE_KEY,
appPrivateKey: P?.env?.SOLANA_PRIVATE_KEY,
});3
const tools = toolKit.getTools({ apps: [App.GITHUB] });4
const prompt = ChatPromptTemplate.fromMessages([
["system", `You are an AI agent responsible for taking actions on GitHub on users' behalf.
You need to take action on GitHub using GitHub APIs. Use correct tools to run APIs from the given tool-set.`],
["placeholder", "{chat_history}"],
["human", "{input}"],
["placeholder", "{agent_scratchpad}"],
]);
const agent = createToolCallingAgent({ llm: model, tools, prompt });
const agentExecutor = new AgentExecutor({
agent,
tools,
verbose: false,
});5
const response = await agentExecutor.invoke({ input: "Search for repositories related to 'machine learning python'" });
console.log(response);Supported Actions
Action
Description
Action.GITHUB_SEARCH_REPOSITORIESAction.GITHUB_CREATE_REPOSITORYAction.GITHUB_GET_FILE_CONTENTSAction.GITHUB_CREATE_OR_UPDATE_FILEAction.GITHUB_CREATE_ISSUEAction.GITHUB_CREATE_PULL_REQUESTLast updated