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.
.
├── 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
- 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)
- Clone the repository:
git clone [repository-url]
cd [repository-name]
- Install required packages:
pip install -r requirements.txt
- 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"
- Generate a new article:
from content_generator import generate_content
topic = "AI-driven biohacking for longevity"
article = generate_content(topic, style="news")
print(article)
- 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)
- Generate image prompts:
from article_image_generator import generate_image_prompts
image_prompts = generate_image_prompts(refined_article)
print(image_prompts)
- 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)
- 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")
- 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
)
- 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"
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:
- Content Generator creates initial article draft using AI
- Content Refiner verifies facts and adds academic sources
- Article undergoes formatting and structure optimization
- Image Generator creates complementary visual content
- Notion Automation handles content distribution
- Each step includes error handling and retry mechanisms
- System maintains consistent formatting throughout the pipeline# AI_Content_Generator