When a user asks to display an image:
http:// or https://read tool to display the imageread tool directly to display the imageUser says: "Show me this image: https://example.com/photo.jpg"
python3 scripts/smart_image_loader.py https://example.com/photo.jpg/tmp/dir/photo.jpgread tool on: /tmp/dir/photo.jpgUser says: "Display ./images/logo.png"
python3 scripts/smart_image_loader.py ./images/logo.pngread tool on: /home/node/clawd/images/logo.png (absolute path)python3 scripts/smart_image_loader.py <image_path_or_url>
| Argument | Description |
|---|---|
| ---------- | ------------- |
image_path_or_url | Either a local file path (relative or absolute) or a URL |
The script returns a JSON-like output with:
Status: SUCCESS or FAILEDType: url or localFile Path: Local path for the read toolMessage: Status descriptionCleanup Needed: true if temp file should be deleted# URL example
python3 scripts/smart_image_loader.py https://example.com/image.jpg
# Output: Downloads to /tmp/xyz/image.jpg, use read tool on that path
# Local file example (relative)
python3 scripts/smart_image_loader.py ./photos/vacation.jpg
# Output: File found at /home/node/clawd/photos/vacation.jpg
# Local file example (absolute)
python3 scripts/smart_image_loader.py /home/node/clawd/downloads/graphic.png
# Output: File found at /home/node/clawd/downloads/graphic.png
User asks to display an image
|
v
Is it a URL? (http:// or https://)
|
+----+---------------------------+
| |
YES NO
| |
v v
Download to temp Does file exist?
| |
v +-----+-----+
Use read tool | |
| YES NO
v |
Cleanup temp file v
Use read tool
|
v
Done (no cleanup)
exec with rm for cleanup| Scenario | Action |
|---|---|
| ---------- | -------- |
| URL download fails | Report error to user |
| Local file not found | Report error to user |
| Invalid input | Show usage instructions |
共 1 个版本