# index.py from fastapi import FastAPI, HTTPException from pydantic import BaseModel import openai import requests # Initialize the FastAPI app app = FastAPI() # OpenAI API key (replace with your own key) openai.api_key = "your_openai_api_key" # Unsplash API key (replace with your own key) UNSPLASH_API_KEY = "your_unsplash_api_key" # Request body schema class ArticleRequest(BaseModel): topic: str keywords: list[str] tone: str audience: str word_count: int @app.post("/generate-article") async def generate_article(request: ArticleRequest): """ Generate an SEO-optimized article based on user input with plagiarism checking. """ try: # Prepare GPT prompt prompt = ( f"Write a {request.word_count}-word article on the topic '{request.topic}'. " f"Include the following keywords: {', '.join(request.keywords)}. " ...
Comments
Post a Comment