SuperAPI AI Directory

file-to-article-generator

Writing & research

View repository

Updated 10-16 06:23

About this skill

File Parser and Article Generator

Task Objective

  • This Skill is used to: extract content from files uploaded by users (PDF/Word/images), save images locally, and generate articles based on requirements and content
  • Capabilities include: multi-format file parsing, image extraction and saving, intelligent understanding of image content, intelligent determination of 6 article types (brand news/product updates/policy rules/marketing campaigns/customer testimonials/industry news), generation of multiple article types (Markdown format), image-content fit checking, quality scoring evaluation
  • Trigger conditions: when a user uploads a file and requests the generation of a brand- or product-related article

Prerequisites

  • Dependency notes:
    PyMuPDF==1.23.8      # PDF文件解析和图片提取
    python-docx==0.8.11  # Word文件解析和图片提取
    Pillow==10.0.0       # 图片处理和格式转换
    
  • Non-standard file/folder preparation: create the output directory
    mkdir -p output/images
    

Operation Steps

Standard Process

1. File Parsing

Use [INVOKE:parse_file] to call the script to process the file uploaded by the user:

  • Input: pass the JSON-format parameter via stdin {"file_path": "文件路径"}
  • Output directory:/home/gem/output/images/(the script will create it automatically)
  • Output: parsing result in JSON format, including text content, image list (with local paths), and metadata
  • Supported formats: PDF, DOCX, common image formats (JPG/PNG, etc.)

Invocation Method: Include the following format in the reply to trigger script execution:

[INVOKE:parse_file({"file_path": "/home/gem/uploads/文件名.pdf"})]

Image Saving Instructions:

  • The script will automatically extract images from the file and save them to the /home/gem/output/images/ directory
  • Image naming format:image_001.png, image_002.png , etc.
  • The returned JSON contains the local paths of the images, which can be used directly for Markdown references

2. Requirements Collection

Ask the user about the specific requirements for generating the article:

  • Target audience: Who is the article intended for? (e.g., technical staff, general users, management)
  • Article purpose: What scenario is it used for? (e.g., technical blog, product introduction, press release, internal report)
  • Special requirements: word count limits, language style, key content, format preferences, etc.

3. Image Content Understanding

If the parsing result contains images, understand the content of each image:

  • Use image recognition capabilities to analyze image content (theme, scene, elements, style, etc.)
  • Extract the core information and visual features of the images
  • Determine the relevance of the images to the original content

4. Type Determination

Based on the parsed file content, image content, and user requirements, determine the article type:

  • Refer to references/article-types.md for the type definitions and determination criteria
  • The agent analyzes the file content features and user requirement keywords
  • Determine the best-matching article type (e.g., news report, technical documentation, product introduction, tutorial guide, etc.)

5. Article Generation

Based on the determined article type, use the corresponding prompt template to generate content:

  • From references/generation-prompts.md select the prompt for the corresponding type
  • Replace the variables in the prompt:
    • {ORIGINAL_TEXT}: The text content extracted from the original file
    • {USER_REQUIREMENTS}: The user's specific requirement description
    • {TARGET_AUDIENCE}: Target audience
    • {IMAGES_INFO}: Image information list (including image content understanding results and local paths)
  • Generate the main body of the article
  • Use Markdown syntax to insert images:![图片描述](./images/image_001.png)
  • Ensure that the images match the article content and avoid inserting images arbitrarily

6. Result scoring (must be executed)

Based on references/evaluation-prompts.md Evaluate the quality of the generated article using the evaluation prompt:

  • Important: This step is mandatory and cannot be skipped
  • Select an appropriate evaluation role based on the article type (boss/customer service director)
  • Evaluate title click desire (50 points): pain point matching, result certainty, de-generalization
  • Evaluate the reading value of the full text (50 points): actionability, transferability, decision support
  • Calculate the total score and provide a harsh but honest evaluation report
  • Provide title rewriting suggestions and analysis of content deficiencies

7. Output delivery

Output the final result in the format of assets/output-template.md :

  • Original text summary
  • The complete generated article content (use Markdown syntax to reference images)
  • Quality evaluation report(must be included at the end of the article)
  • Image list (index, local path, description)
  • File download instructions

Note: The evaluation result must be appended at the end of the article content as an important reference for article quality.

  • Quality scoring report (scores by dimension, total score, improvement suggestions)

Download instructions:

  • Save the article as a Markdown format file:./output/article.md
  • Images are saved in:./images/ directory (relative to the article location)
  • Users can download the entire ./output/ directory, including the article and all images

Optional branches

  • When the file contains only images (no text): mark it as image-type content and generate a related article based on the image descriptions
  • When the user's requirements are unclear: provide examples of several common types for the user to choose from
  • When the score is low (<60 points): ask the user whether regeneration is needed and provide improvement directions

Resource index

Notes

  • File parsing must be completed through scripts to ensure accurate extraction of text and image information
  • Images will be automatically saved to the sandbox; use relative paths when referencing them ./images/xxx.png
  • Image content understanding must use image recognition capabilities to extract the image's theme, scene, elements, and style characteristics
  • Images must match the article content; insert images reasonably based on image understanding results and the article theme, using Markdown format ![描述](路径), avoiding arbitrary image placement
  • Article type determination and content generation are both completed by the agent, fully utilizing natural language understanding and creative capabilities
  • The scoring step is mandatory, cannot be skipped, and the article must be evaluated using the role of boss or supervisor
  • The evaluation result must be appended at the end of the article content, serving as an important reference for article quality
  • When the score is low (<60 points), the article can be regenerated based on the title rewriting suggestions and content deficiency analysis in the evaluation report
  • The final output includes the Markdown-formatted article, evaluation report, and all image files, which users can download together

Usage Examples

Example 1: Brand Trend Report

  • Function Description: Convert brand launch event materials into a brand trend report article
  • Execution Method:
    1. Parse the brand launch event file
    2. Ask about the audience (public/partners/media) and focus (brand strategy/partnership highlights/event atmosphere)
    3. Determine it as the brand trend type (brand-event)
    4. Use the brand trend prompt to generate the article
    5. Score and output the result
  • Key Parameters: Audience=public, purpose=brand promotion, style=positive and upbeat

Example 2: Product Update Release

  • Function Description: Convert product update documents into a product update article
  • Execution Method:
    1. Parse the product version update description file
    2. Ask about key features and technical highlights
    3. Determine it as the product update type (product-feature)
    4. Use the product update prompt to generate the article
    5. Score and output the result
  • Key Parameters: Audience=users, purpose=feature introduction, style=professional and easy to understand

Example 3: Marketing Campaign Promotion

  • Function Description: Convert promotional campaign materials into a marketing campaign article
  • Execution Method:
    1. Parse the campaign planning file
    2. Ask about campaign discounts and target users
    3. Determine it as the marketing campaign type (product-campaign)
    4. Use the marketing campaign prompt to generate the article
    5. Score and output the result
  • Key Parameters: Audience=potential users, purpose=campaign promotion, style=attractive