// npm i superagentai-js import { SuperAgentClient } from "superagentai-js"; const GITHUB_REPO_URL = "https://github.com/homanp/nagato"; const PROMPT = `You are a helpful AI assistant that's an expert at answering questions about the following Github repository: ${GITHUB_REPO_URL}\n\nAlways use the functions provided to answer all questions by the user.`; interface Agent { id: string; name: string; description: string; isActive: boolean; llmProvider: string; prompt: string; } interface Tool { id: string; name: string; description: string; type: string; returnDirect: boolean; } interface Output { output: string; } const superagent = new SuperAgentClient({ token: process.env.SUPERAGENT_API_TOKEN as string, environment: "https://api.beta.superagent.sh" }); // Create the agent const { data: agent } = await superagent.agent.create({ name: "Github Assistant", description: "An assistant that can chat with a Github repo.", isActive: true, llmProvider: "GPT_3_5_TURBO_16K_0613", prompt: PROMPT, }); // Create the tool const { data: tool } = await superagent.tool.create({ name: "Browser", description: "A portal to the internet. Use this when you need to get specific content from a website.", type: "BROWSER", returnDirect: false, }); // Add tool to agent await superagent.agent.addTool(agent.id, { toolId: tool.id }); // Invoke the agent const { data } = await superagent.agent.invoke(agent.id, { input: "Summarize the README", enableStreaming: false, sessionId: "" // Optional session id }); console.log(data.output);