Introduction
- playgroundΒ You can see the demo code on the playground.
Set up a fully functional Github Agent powered by OpenAIβs GPT model quickly using the Agentica CLI. This agent lets you interact with Githubβsearch users, retrieve profiles, and list repositoriesβthrough natural language commands.
Quick CLI Setup
Launch the Agentica Setup Wizard with a single command:
npx agentica start github-agentThe wizard guides you through:
- Installing required packages (e.g., agentica@0.12.14)
- Choosing your package manager and project type
- Selecting the GITHUB controller
- Entering your
OPENAI_API_KEY
Once complete, Agentica automatically generates your code, creates a .env file, and installs all dependencies.
Generated Code Overview
The generated code looks like this:
import { Agentica } from "@agentica/core";
import { GithubService } from "@wrtnlabs/connector-github";
import dotenv from "dotenv";
import OpenAI from "openai";
import typia from "typia";
dotenv.config();
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
export const GithubAgent = new Agentica({
vendor: {
api: openai,
model: "gpt-4o-mini",
},
controllers: [
{
name: "Github Connector",
protocol: "class",
application: typia.llm.application<GithubService>(),
execute: new GithubService({
secret: process.env.GITHUB_ACCESS_TOKEN!,
}),
},
],
});This code instantly sets up your Github Agent to interact with Github via its API.
Github API Setup
Before running your agent, configure your Github API credentials:
-
Create a Github Application:
- Visit Github Developer SettingsΒ to create a new OAuth application.
- An OAuth application allows you to obtain a token (starting with
gho_), which boosts your API rate limit for more stable usage.
-
Obtain Credentials:
- Generate the necessary token and ensure you have the required permissions.
-
Set Up Environment Variables:
- Create or update your
.envfile with:
OPENAI_API_KEY=your-openai-api-key GITHUB_ACCESS_TOKEN=your-github-access-token - Create or update your
What This Does
Your Github Agent will:
- Process Github Data: Use the
GithubServiceconnector to search users, fetch profiles, and list repositories. - Leverage OpenAIβs GPT Model: Translate natural language queries into Github API calls.
- Maintain Type Safety: With
typia. - Securely Manage Credentials: Using environment variables via
dotenv.
Available Functions
For a complete list of available functions in GithubService, check out the source code:
π wrtnlabs/connectors - GithubService.tsΒ
Your AI-powered Github Agent is now ready for seamless Github interactions! π