- 
                Notifications
    You must be signed in to change notification settings 
- Fork 181
veniceimg: store generated images in IPFS #1652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| Hey @ijonele and thank you for opening this pull request! 👋🏼 It looks like you forgot to add a changelog entry for your changes. Make sure to add a changelog entry in the 'CHANGELOG.md' file. | 
| The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
 | 
| 📝 WalkthroughWalkthroughRefactors the VeniceImg plugin to use separate Venice and storage API keys, upload generated image bytes to Filebase IPFS, and return IPFS gateway URLs. Updates configuration, plugin constructor/execution, and app registration accordingly; minor docs formatting change. Changes
 Sequence Diagram(s)sequenceDiagram
    participant User
    participant Plugin
    participant VeniceAPI
    participant FilebaseAPI
    participant IPFSGateway
    User->>Plugin: Request image generation
    Plugin->>VeniceAPI: Generate image (auth: VeniceKey)
    VeniceAPI-->>Plugin: Return image bytes (WebP)
    Plugin->>FilebaseAPI: Upload bytes (auth: StorageKey)
    FilebaseAPI-->>Plugin: Return CID
    Plugin->>IPFSGateway: Build gateway URLs from CID
    Plugin-->>User: Return JSON with IPFS URLs
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
 Suggested reviewers
 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
 ✅ Files skipped from review due to trivial changes (1)
 ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
 ✨ Finishing Touches🧪 Generate unit tests
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit: 
 
 SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
 Other keywords and placeholders
 Documentation and Community
 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🔭 Outside diff range comments (2)
prophet/plugins/veniceimg/veniceimg.go (2)
52-55: Guard against empty image list to avoid index panic
res.Images[0]will panic when the API returns zero images.Apply this diff:
- imgBytes, err := base64.StdEncoding.DecodeString(res.Images[0]) + if len(res.Images) == 0 { + return nil, fmt.Errorf("venice returned no images") + } + imgBytes, err := base64.StdEncoding.DecodeString(res.Images[0])
108-147: Improve error details from Venice generate APIInclude response body on non-200 to aid debugging and handle non-200-but-JSON error payloads. Also, some APIs use 201; if Venice strictly uses 200, this is fine—otherwise consider allowing 201.
Apply this diff:
- if httpRes.StatusCode != http.StatusOK { - return generateResponse{}, fmt.Errorf("http status code: %s", httpRes.Status) - } + if httpRes.StatusCode != http.StatusOK { + b, _ := io.ReadAll(io.LimitReader(httpRes.Body, 2048)) + return generateResponse{}, fmt.Errorf("venice generate failed: %s: %s", httpRes.Status, string(bytes.TrimSpace(b))) + }Additional imports needed (outside this hunk):
import "bytes"Note:
bytesis already imported;iois imported too, so no new imports may be necessary beyond what exists.
🧹 Nitpick comments (2)
prophet/plugins/veniceimg/config/config.go (1)
28-31: Strengthen template guidance around secretsAdd a brief note that these are sensitive credentials and should be supplied via environment/secure secrets manager, not committed in plaintext.
Suggested comment tweak:
-# API Key used when making VeniceImg API requests +# API Key used when making VeniceImg API requests (treat as secret; prefer env/secret manager) venice-key = "{{ .Veniceimg.VeniceKey }}" -# API Key used when saving the image to Filebase +# API Key used when saving the image to Filebase (treat as secret; prefer env/secret manager) storage-key = "{{ .Veniceimg.StorageKey }}"prophet/plugins/veniceimg/veniceimg.go (1)
62-69: Consider returning the CID alongside gateway URLsReturning the raw CID helps downstream consumers who want to use custom gateways or IPFS-native tooling.
Apply this diff:
- urls := map[string]string{ + urls := map[string]string{ + "cid": cid, "filebase": "https://ipfs.filebase.io/ipfs/" + cid, "ipfs": "https://ipfs.io/ipfs/" + cid, "pinata": "https://gateway.pinata.cloud/ipfs/" + cid, }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
- prophet/plugins/veniceimg/config/config.go(2 hunks)
- prophet/plugins/veniceimg/veniceimg.go(4 hunks)
- warden/app/app.go(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: lint
- GitHub Check: test
- GitHub Check: test
- GitHub Check: lint
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
prophet/plugins/veniceimg/config/config.go (1)
4-6: Config key split looks good; tags consistent with template and app optsThe move to separate
venice-keyandstorage-keyis correct; mapstructure/TOML tags align withapp.gousage.
This reverts commit edd047a.
| I'm keeping this on hold until we resume the protocol development work. | 
Integrated the Venic Plugin with Filebase/IPFS (this is a POC)