Skip to Content

Introduction

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-agent

The 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:

  1. 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.
  2. Obtain Credentials:

    • Generate the necessary token and ensure you have the required permissions.
  3. Set Up Environment Variables:

    • Create or update your .env file with:
    OPENAI_API_KEY=your-openai-api-key GITHUB_ACCESS_TOKEN=your-github-access-token

What This Does

Your Github Agent will:

  • Process Github Data: Use the GithubService connector 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! πŸš€

Last updated on