-
-
Notifications
You must be signed in to change notification settings - Fork 91
docs(decart): add Decart community adapter #194
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
📝 WalkthroughWalkthroughThis PR introduces comprehensive documentation for the Decart adapter integration, detailing installation, usage patterns, configuration options, image and video generation workflows, and API reference. The new documentation page is registered in the site configuration. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
docs/community-adapters/decart.mddocs/config.json
🧰 Additional context used
🪛 LanguageTool
docs/community-adapters/decart.md
[grammar] ~209-~209: Ensure spelling is correct
Context: ...age(model, apiKey, config?)` Creates a Decart image adapter with an explicit API key....
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🔇 Additional comments (10)
docs/community-adapters/decart.md (9)
1-13: LGTM! Clear introduction and installation instructions.The front matter, introduction, and installation instructions are well-structured and provide a clear entry point for users.
15-39: LGTM! Well-organized usage examples.The dual examples effectively demonstrate both environment-variable-based and explicit API key patterns, making it easy for users to choose the approach that fits their use case.
41-51: LGTM! Configuration pattern is clear.The example correctly demonstrates the configuration pattern with
Omit<DecartImageConfig, "apiKey">, clearly showing that the API key is passed separately from other configuration options.
53-88: LGTM! Image generation documentation is comprehensive.The examples and options table clearly document the available parameters. The resolution being limited to "720p" for image generation appears to be an API constraint of the
lucy-pro-t2imodel.
93-123: LGTM! Clear video generation workflow.The step-by-step breakdown of creating a video job and polling for status is well-documented and easy to follow.
160-178: LGTM! Video model options are well-documented.The video model options table clearly shows the available parameters, including multiple resolution options ("720p" and "480p") compared to image generation.
180-192: LGTM! Clear guidance on API key setup.The environment variable configuration and step-by-step instructions for obtaining an API key are helpful and well-organized.
194-240: LGTM! Comprehensive API reference.The API reference clearly documents all four adapter functions with their parameters and return values. The documentation is consistent with the usage examples throughout the document.
Note: The static analysis tool flagged "Decart" as a potential spelling error on line 209, but this is a false positive—"Decart" is the product name.
242-248: LGTM! Helpful next steps and resources.The links provide users with clear paths to continue learning, including both Decart-specific resources and broader TanStack documentation.
docs/config.json (1)
156-159: LGTM! Navigation entry correctly configured.The Decart documentation is properly registered in the sidebar navigation with the correct label and path that matches the new documentation file.
| ### Complete Example with Polling | ||
|
|
||
| ```typescript | ||
| import { generateVideo, getVideoJobStatus } from "@tanstack/ai"; | ||
| import { decartVideo } from "@decartai/tanstack-ai-adapter"; | ||
|
|
||
| async function createVideo(prompt: string) { | ||
| const adapter = decartVideo("lucy-pro-t2v"); | ||
|
|
||
| // Create the job | ||
| const { jobId } = await generateVideo({ adapter, prompt }); | ||
| console.log("Job created:", jobId); | ||
|
|
||
| // Poll for completion | ||
| let status = "pending"; | ||
| while (status !== "completed" && status !== "failed") { | ||
| await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
|
|
||
| const result = await getVideoJobStatus({ adapter, jobId }); | ||
| status = result.status; | ||
| console.log(`Status: ${status}`); | ||
|
|
||
| if (result.status === "failed") { | ||
| throw new Error("Video generation failed"); | ||
| } | ||
|
|
||
| if (result.status === "completed" && result.url) { | ||
| return result.url; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const videoUrl = await createVideo("A drone shot over a tropical beach"); | ||
| ``` |
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.
Handle the edge case where video completes without a URL.
The polling loop has a logic gap: if result.status === "completed" but result.url is falsy (line 151), the function won't return. On the next iteration, the while condition (line 140) will be false since status === "completed", causing the loop to exit without a return statement. The function will then return undefined.
🔎 Proposed fix to handle missing URL
if (result.status === "failed") {
throw new Error("Video generation failed");
}
if (result.status === "completed" && result.url) {
return result.url;
}
+
+ if (result.status === "completed") {
+ throw new Error("Video generation completed without a URL");
+ }
}
}🤖 Prompt for AI Agents
In docs/community-adapters/decart.md around lines 125 to 158, the createVideo
polling loop can exit when status === "completed" but result.url is falsy,
leading to an implicit undefined return; fix by ensuring the function either
waits until a completed result includes a URL or throws a clear error: either
(A) change the loop condition to continue until status === "failed" or (status
=== "completed" && result.url) so it only exits when a URL is present or failure
occurs, or (B) leave the loop as-is but add an explicit check after the loop
that if status === "completed" and no url was returned, throw a descriptive
Error (e.g., "Video completed but no URL returned") to avoid returning
undefined.
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.
Not sure it's needed? I'd prefer to keep the example focused, but happy to add it if you think it's useful.
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.
@AdirAmsalem You're right—for documentation, keeping the example focused on the happy path is more valuable. The edge case handling would add noise to what's meant to be a clear, educational example. I'm good with leaving it as-is. 👍
🎯 Changes
Followed Community Adapters Guide to add Decart's community adapter.
@decartai/tanstack-ai-adapter)Image Generation
decartImage()/createDecartImage()adapterslucy-pro-t2imodelVideo Generation
decartVideo()/createDecartVideo()adapterslucy-pro-t2vmodel✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.