Skip to content

🤖 Auto Content Generator: A .NET 8 API that leverages OpenAI's GPT-4o to automatically generate markdown formatted blog posts, commit the new file, and create a pull request on your GitHub repository. Easy setup with environment variables and customizable prompts.

Notifications You must be signed in to change notification settings

calumjs/gpt-auto-blog-writer

Repository files navigation

Auto Content Generator

YouTube video
Original Video

YouTube video
Feature: Interactive Review Process...Coming to the repo soon!

Auto Content Generator is a .NET 8 application that uses OpenAI's GPT-3.5-turbo (or GPT-4) to generate new markdown formatted blog posts. The application clones a specified GitHub repository, generates a new Markdown file with the blog post content, commits the new file, and creates a pull request for the change. Additionally, it handles pull request reviews, updating content based on comments, and commits changes back to the repository.

Environment Variables:

  • GitHubToken: The personal access token for your GitHub account.
  • GitHubRepoOwner: The owner of the GitHub repository.
  • GitHubRepoName: The name of the GitHub repository.
  • GitHubEmail: The email address of your GitHub account.
  • GitHubPostsDirectory: The directory in the repository where the blog posts are stored.
  • OpenAIKey: Your OpenAI API key.

Usage:

  1. Set the required environment variables in the appsettings.json file or in the appsettings.Development.json file for development.

Sample appsettings.json:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "GitHub": {
    "GitHubToken": "<< PUT IN SECRETS OR 'appsettings.Development.json' >>",
    "GitHubRepoOwner": "<< PUT IN SECRETS OR 'appsettings.Development.json' >>",
    "GitHubRepoName": "<< PUT IN SECRETS OR 'appsettings.Development.json' >>",
    "GitHubEmail": "<< PUT IN SECRETS OR 'appsettings.Development.json' >>",
    "GitHubPostsDirectory": "_posts"
  },
  "OpenAI": {
    "OpenAIKey": "<< PUT IN SECRETS OR 'appsettings.Development.json' >>",
    "Model": "gpt-4",
    "ImageModel": "dall-e-3"
  }
}
  1. Run the application.

Use the following command to run the application:

dotnet run
  1. Generate a new blog post.

Make an HTTP POST request to the endpoint /generate-blog-post. This will give you a new pull request on your repo.

  1. Respond to PR comments

Leave a comment asking for changes and submit your review, then call the endpoint /pr-webhook/{pullRequestNumber:int}. Your comments will be picked up and actioned.

About

🤖 Auto Content Generator: A .NET 8 API that leverages OpenAI's GPT-4o to automatically generate markdown formatted blog posts, commit the new file, and create a pull request on your GitHub repository. Easy setup with environment variables and customizable prompts.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages