Langsung ke konten
Skillpedia
PDF, Word & slide7.8k Β· #13014

document-direct-python

Fungsinya

Skill ini memandu agent AI untuk membuat dokumen seperti buku kerja Excel, laporan PDF, dan formulir melalui eksekusi Python langsung. Skill ini ditujukan untuk orang yang memerlukan file tersebut dibuat tanpa penundaan dari agent shell.

Kapan dipakai

  • βœ“Saat Anda memerlukan dokumen PDF, daftar periksa, atau laporan yang dihasilkan dengan Python.
  • βœ“Saat pekerjaan dokumen memiliki beberapa langkah dan mungkin melewati batas agent.
  • βœ“Saat agent shell gagal pada pemformatan atau pada pembacaan buku kerja.

Link skill

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

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/spreadsheet-direct-python-merged/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBuat laporan PDF dengan reportlab dan buku kerja Excel dengan openpyxl dari data saya. Jalankan kodenya secara langsung.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agent menulis kode Python ke file dan menjalankannya lewat shell dengan python3. Kode memakai pustaka dokumen untuk membangun file, dan agent memeriksa output yang ditampilkan untuk mencari error.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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

Pertanyaan umum

Apa manfaat utama eksekusi langsung?

Skill ini menyatakan eksekusi dilakukan dalam satu langkah dengan pesan error yang jelas dan segera.

Bisakah membuat file Word?

Skill ini menyebut dokumen Word sebagai salah satu jenis output yang didukung.

Apakah agent selalu memakai file terlebih dahulu?

Skill ini merekomendasikan penulisan skrip ke file untuk kode multi-baris yang kompleks.

Detail

Deskripsi asli dari pembuat

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

repo: HKUDS/AgentPilot

Popularitas

Bintang GitHub
7.8k
Peringkat
#13014
Lisensi
MIT
Diperbarui
1/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa