Skip to content

krissyawaters/AI_Content_Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

AI-Powered Content Generation and Refinement System for Biohacking Articles

This system automates the creation, refinement, and enhancement of high-quality biohacking and self-optimization content through AI-powered generation, fact-checking, and image creation capabilities. It streamlines the content production workflow by combining article generation, scientific verification, and visual asset creation into a cohesive pipeline.

The system leverages both OpenAI and Azure OpenAI APIs to generate engaging, scientifically-backed content while ensuring accuracy through automated fact-checking and source verification. It includes specialized features for creating complementary visual content through AI-generated image prompts, making it particularly valuable for content creators in the biohacking and self-optimization space.

Repository Structure

.
├── article_image_generator_azure.py   # Azure OpenAI implementation for generating image prompts and alt text
├── article_image_generator.py         # OpenAI implementation for generating image prompts and alt text
├── content_generator.py               # Core content generation for biohacking articles using OpenAI
├── content_refiner_azure.py          # Azure OpenAI implementation for content refinement and fact-checking
├── content_refiner.py                # OpenAI implementation for content refinement and fact-checking
├── image_generator.py                # Handles image generation using OpenAI's DALL-E
├── notion_automation_azure.py        # Azure implementation for Notion content automation
└── notion_automation.py             # OpenAI implementation for Notion content automation

Usage Instructions

Prerequisites

  • Python 3.6 or higher
  • OpenAI API key or Azure OpenAI API credentials
  • Google API key and Custom Search Engine ID for fact-checking
  • Notion API key (if using Notion automation features)

Required Python packages:

openai
requests
python-dotenv
notion-client (for Notion integration)
Pillow (for image handling)

Installation

  1. Clone the repository:
git clone [repository-url]
cd [repository-name]
  1. Install required packages:
pip install -r requirements.txt
  1. Set up environment variables:
# For OpenAI version
export OPENAI_API_KEY="your-openai-key"
export GOOGLE_API_KEY="your-google-key"
export GOOGLE_CSE_ID="your-cse-id"

# For Azure version
export AZURE_OPENAI_ENDPOINT="your-azure-endpoint"
export AZURE_OPENAI_KEY="your-azure-key"

Quick Start

  1. Generate a new article:
from content_generator import generate_content

topic = "AI-driven biohacking for longevity"
article = generate_content(topic, style="news")
print(article)
  1. Refine and fact-check an article:
from content_refiner import fact_check_and_refine_article

refined_article = fact_check_and_refine_article(article)
print(refined_article)
  1. Generate image prompts:
from article_image_generator import generate_image_prompts

image_prompts = generate_image_prompts(refined_article)
print(image_prompts)

More Detailed Examples

  1. Complete content pipeline with Notion integration:
from content_generator import generate_content
from content_refiner import fact_check_and_refine_article
from article_image_generator import generate_image_prompts
from notion_automation import save_to_notion

# Generate initial content
topic = "The Impact of Circadian Rhythms on Cognitive Performance"
article = generate_content(topic)

# Refine and fact-check
refined_article = fact_check_and_refine_article(article)

# Generate image prompts
image_prompts = generate_image_prompts(refined_article)

# Save to Notion
save_to_notion(refined_article, image_prompts)

Troubleshooting

  1. API Authentication Issues
# Check API key configuration
if not os.getenv("OPENAI_API_KEY"):
    print("OpenAI API key not found. Please set OPENAI_API_KEY environment variable")
  1. Content Generation Errors
  • Issue: Word count requirements not met
  • Solution: Adjust max_tokens parameter in API calls
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": prompt}],
    max_tokens=2000  # Increase for longer content
)
  1. Fact-checking Issues
  • Issue: No sources found
  • Solution: Adjust search query construction
# Modify search query to be more specific
query = sentence[:100] + " research study scientific"

Data Flow

The system processes content through a pipeline of generation, refinement, and enhancement stages, ensuring quality and accuracy at each step.

[Content Generation] -> [Fact Checking] -> [Refinement] -> [Image Generation] -> [Notion Integration]
     |                       |                  |                |                      |
     v                       v                  v                v                      v
Initial Draft         Verified Sources    Polished Content    Visual Assets         Published

Key component interactions:

  1. Content Generator creates initial article draft using AI
  2. Content Refiner verifies facts and adds academic sources
  3. Article undergoes formatting and structure optimization
  4. Image Generator creates complementary visual content
  5. Notion Automation handles content distribution
  6. Each step includes error handling and retry mechanisms
  7. System maintains consistent formatting throughout the pipeline# AI_Content_Generator

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published