Weekend Build Log: My 'Free' AI Side Project Almost Cost Me Real Money
说明与用途
一段简洁的 Python 脚本,用于在 MonkeyCode 免费层限制内总结 Markdown 文件,采用单次重试和输入大小限制。
问题
Building an AI summarizer for Markdown files while staying within free tier limits and avoiding unexpected costs.
结果
A 15‑line Python script that safely summarizes Markdown files within free tier limits, avoiding quota overages and ensuring graceful failure.
工作流
- 1. Define MAX_CHARS to limit input size.
- 2. Read Markdown file from disk.
- 3. Construct prompt to summarize in 5 bullet points.
- 4. Send request to MonkeyCode API with one retry and 30s timeout.
- 5. Handle errors and write summary to output.md.
- 6. Exit with clear error if file too large or API fails.
证据
I added one retry. Not five. I also set a hard timeout so a stuck request wouldn't hang forever.
MAX_CHARS is a crude token proxy. It protects free quota from runaway inputs.
- 记录日期: 2026-09-08T05:59:47.501Z