ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s

This commit is contained in:
2026-08-20 13:12:50 +00:00
commit b119135836
10275 changed files with 3284984 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
#! /usr/bin/env python3
"""Convert all SVG images to PNG for better e-book reader compatibility"""
import os
import re
book_dir = os.path.dirname(os.path.abspath(__file__))
img_dir = os.path.join(book_dir, "images")
# Convert SVG files to PNG
import cairosvg
converted = 0
for fname in sorted(os.listdir(img_dir)):
if not fname.lower().endswith('.svg'):
continue
svg_path = os.path.join(img_dir, fname)
png_name = fname.replace('.svg', '.png')
png_path = os.path.join(img_dir, png_name)
with open(svg_path, 'rb') as f:
svg_data = f.read()
# Convert SVG to PNG
cairosvg.svg2png(bytestring=svg_data, write_to=png_path, output_width=1200)
converted += 1
if converted % 20 == 0:
print(f" {converted} SVG konvertálva...")
print(f"{converted} SVG → PNG konvertálva")
# Now update all chapter files to use .png instead of .svg
chapters = [
"introduction.md", "chapter1.md", "chapter2.md", "chapter3.md",
"chapter4.md", "chapter5.md", "chapter6.md", "chapter7.md",
"chapter8.md", "chapter9.md", "chapter10.md", "afterword.md",
"reference-answers.md"
]
total_fixes = 0
for fname in chapters:
fpath = os.path.join(book_dir, fname)
if not os.path.exists(fpath):
continue
with open(fpath, 'r', encoding='utf-8') as f:
content = f.read()
# Replace image references: images/fig*.svg → images/fig*.png
new_content = re.sub(r'(images/[a-zA-Z0-9_-]+)\.svg', r'\1.png', content)
if new_content != content:
fixes = len(re.findall(r'\.png', new_content)) - len(re.findall(r'\.png', content))
total_fixes += fixes
with open(fpath, 'w', encoding='utf-8') as f:
f.write(new_content)
print(f" {fname}: {fixes} SVG hivatkozás → PNG")
print(f"\n✅ Összesen {total_fixes} hivatkozás frissítve")