How weikeeyong/openai-pdf2campaigncontent works
Project type and purpose
• This is a lightweight Python proof-of-concept (POC) tool that automates the process of converting user-provided PDFs into campaign-style email content by leveraging the OpenAI API. It is not a full-stack web app but rather a CLI/script-driven workflow.
File structure
• Top level:
• README.md – project description and usage
• UploadPDF2Assistant.py – core script that uploads PDF, links it to a vector store, invokes the assistant, and prints HTML
• UploadPDF2Assistant-FunctionCalling.py – variant that uses OpenAI function-calling features
• No frontend directory, no web server config—this runs entirely as a local Python process that calls out to OpenAI services.
README for additional insights
• Workflow steps:
1. Upload local PDF
2. Link PDF to an OpenAI-backed vector store
3. Request content generation via an OpenAI Assistant (specified by Assistant ID)
4. Receive HTML email body
5. Clean up the uploaded file
• Prerequisites: configured OpenAI Assistant, Vector Store, API key management
Main components and their interactions
a. Local Orchestrator (Python script)
• Reads config/API key
• Prompts or accepts PDF file path
• Calls OpenAI “files” endpoint to upload
• Attaches the uploaded file to a vector store via API
• Polls for indexing completion
• Sends a chat/assistant request (or function call) to generate HTML content
• Receives and displays/stores the HTML
• Cleans up the file on the server
b. OpenAI Cloud Services
• File Storage Service (/files endpoint)
• Vector Store Service (PDF indexing & retrieval)
• Assistant Service (chat completions or function-calling)
c. Optional: Local Configuration (e.g., .env or openai_key.txt)
Architectural patterns and principles
• Orchestration script pattern: single-flow sequence
• Polling loop for asynchronous file indexing
• Clear separation between orchestration logic and external services
• Function-calling variant encapsulates logic into JSON function schemas