Перейти к содержанию
Skillpedia
PDF, Word и слайды7.8k · #13014

document-direct-python

Что он делает

Этот скилл направляет ИИ-агента на создание документов, таких как книги Excel, PDF-отчеты и формы, через прямой запуск Python. Он нужен тем, кому нужны эти файлы без задержек агента шелла.

Когда использовать

  • ✓Когда нужны PDF-документы, чек-листы или отчеты, созданные с помощью Python.
  • ✓Когда задача с документом состоит из нескольких шагов и может превысить лимиты агента.
  • ✓Когда агент шелла падает на форматировании или на чтении книги.

Ссылка на скилл

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/spreadsheet-direct-python-merged/SKILL.md

Скопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.

Как использовать

Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.

Готовое сообщение для вставки

Используй этот скилл, чтобы помочь мне: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/spreadsheet-direct-python-merged/SKILL.md Прочитай файл SKILL.md по этой ссылке и следуй его инструкциям в моей задаче.
Хотите, чтобы ваш ИИ сам находил такие скиллы?Установите бесплатный MCP Skillpedia: одна строка, и перед каждой задачей он ищет среди 15 000+ скиллов.Установить за 1 минуту →

Пример запроса к вашему ИИ

“Создай PDF-отчет с reportlab и книгу Excel с openpyxl из моих данных. Запусти код напрямую.”

5 новых скиллов в неделю. 1 минута чтения.

Как это работает

Агент записывает код Python в файл и запускает его через шелл командой python3. Код использует библиотеки для документов, чтобы создать файлы, а агент проверяет напечатанный вывод на ошибки.

Технический текст (оригинальный SKILL.md)

Оригинальный текст автора на английском, прямо с GitHub.

Direct Python Execution for Document Generation Tasks

When to Use This Skill

Use direct run_shell with Python scripts for document operations when:

  • Reading or writing complex Excel files with multiple sheets
  • Generating PDF documents, checklists, or reports
  • Applying formulas, formatting, or data transformations
  • Working with openpyxl, pandas, reportlab, FPDF, or similar libraries
  • The operation involves multiple steps that could exceed agent step limits
  • You need precise control over error handling and debugging
  • Complex scripts benefit from file-based execution for better reliability

Why Direct Execution?

The shell_agent tool can:

  • Hit maximum step limits on complex multi-step operations
  • Produce unexplained errors on formatting operations
  • Fail on intricate document reads/writes due to iterative parsing
  • Fail to parse heredoc syntax correctly, causing 'unknown error' failures

Direct run_shell with Python is more reliable because it:

  • Executes in a single step with no iteration limits
  • Provides clearer, immediate error messages
  • Handles complex operations without step constraints
  • Gives full control over library imports and execution flow
  • Writing scripts to .py files first avoids shell_agent parsing issues with heredocs

How to Use

Handling Web Research Failures

When web research tools (search_web, read_webpage) fail or return 'unknown error':

  1. Assess what you need: Determine if the information is from well-documented regulatory frameworks, standards, or common knowledge that you can provide from internal knowledge.
  2. Proceed with available knowledge: For pharmacy compliance, OSHA standards, GDPR requirements, and similar well-established frameworks, generate documents using your training knowledge rather than waiting for web access.
  3. Document assumptions: Clearly note that materials were generated based on standard practices when source verification was unavailable.
  4. Use direct Python execution: Continue with the recommended run_shell pattern to generate documents even without web-sourced content.

Example contingency workflow for pharmacy compliance:

# When web research fails, proceed with established regulatory knowledge
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

checklist_items = [
    "Verify pharmacist license is current and displayed",
    "Maintain controlled substance inventory logs",
    "Ensure proper storage temperatures for medications",
    "Keep patient counseling records for controlled substances",
    "Display required pharmacy signage and notices"
]
# Generate PDF using these standard compliance items

This approach was successfully used in task 045aba2e-4093-42aa-ab7f-159cc538278c_phase2 where all web tools failed but pharmacy compliance PDFs were still created successfully.

Recommended Pattern: Write Script to File First

For complex multi-line scripts, especially when using shell_agent as executor:

# Step 1: Write the Python script to a file
cat > generate_document.py << 'EOF'
import openpyxl
from openpyxl import Workbook

# Your document code here
wb = openpyxl.load_workbook('file.xlsx')
# ... operations ...
wb.save('output.xlsx')
print('Success')
EOF

# Step 2: Execute the script
python3 generate_document.py

Alternative Pattern: Inline Heredoc (Simple Scripts Only)

For short, simple scripts when NOT using shell_agent as the executor:

python3 << 'EOF'
import pandas as pd
df = pd.read_excel('input.xlsx')
df.to_excel('output.xlsx', index=False)
print('Done')
EOF

Spreadsheet Examples

Example 1: Read and Transform Excel Data

Write to file first, then execute:

import pandas as pd

# Load data from specific sheet
df = pd.read_excel('input.xlsx', sheet_name='Revenue')

# Apply transformations
df['Net_Revenue'] = df['Gross_Revenue'] * (1 - df['Tax_Rate'])

# Save results
df.to_excel('output.xlsx', index=False, sheet_name='Processed')

Example 2: Multi-Sheet Operations with openpyxl

from openpyxl import load_workbook

wb = load_workbook('tour_data.xlsx')

# Iterate through sheets
for sheet_name in wb.sheetnames:
    ws = wb[sheet_name]
    # Apply formatting or calculations
    for row in ws.iter_rows(min_row=2, max_col=5):
        # Process cells
        pass

wb.save('tour_data_processed.xlsx')

PDF Generation Examples

Example 3: Generate PDF Checklist with reportla

Частые вопросы

В чем главная польза прямого запуска?

Скилл говорит, что код выполняется одним шагом и сразу выдает понятные ошибки.

Может ли он работать с файлами Word?

Скилл упоминает документы Word как поддерживаемый тип результата.

Агент всегда использует файл?

Скилл рекомендует записывать скрипт в файл для сложного многострочного кода.

Подробности

Оригинальное описание автора

Use direct Python execution for reliable document creation including spreadsheets, PDFs, and structured reports

repo: HKUDS/AgentPilot

Популярность

Звёзды на GitHub
7.8k
Место в рейтинге
#13014
Лицензия
MIT
Обновлён
01.11.2026

Полезен ли этот скилл?

0

Войдите , чтобы голосовать.

Комментарии

  • …

Другие скиллы из этого репозитория

Похожие скиллы