Skip to content

A GitHub profile description builder using OpenAI and Defer ⚡️

Notifications You must be signed in to change notification settings

defer-run/defer-openai-github-profile

Repository files navigation

GitHub Readme OpenAI Generator

This Next.js app (with app directory) leverages Defer using GitHub data as a prompt for OpenAI completion API.

demo


Getting started

1. Install the dependencies

yarn

2. Deploy on Vercel and Defer

Make sure to get a GitHub personal access token and an OpenAI API Key.

Then, configure the application on Defer and Vercel.


How it works

The Next.js API Route /api/gitHubProfile/[usernameOrExecID] is used as follow:

  • Trigger a new generation: POST /api/gitHubProfile/charlypoly
  • Get the status and result of a profile text generation: GET /api/gitHubProfile/2MeNNf2OTVZP0MUrs1ghwXaUtm4

The generateGitHubProfile() Defer background function handles fetching data from GitHub and forwarding the proper prompt to OpenAI.

Triggering an execution of generateGitHubProfile() is achieved by simply calling it from the Next.js API Route:

import { NextRequest } from "next/server";
import generateGitHubProfile from "@/defer/generateGitHubProfile";

export async function POST(
  _request: NextRequest,
  { params }: { params: { usernameOrExecId: string } }
) {
  const ret = await generateGitHubProfile(params.usernameOrExecId);
  return new Response(JSON.stringify(ret), {
    status: 200,
    headers: { "Content-type": "application/json" },
  });
}

About

A GitHub profile description builder using OpenAI and Defer ⚡️

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published