-
Notifications
You must be signed in to change notification settings - Fork 581
feat(whiteboard): pin whiteboard-cli to v0.2.10 in lark-whiteboard skill #649
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,80 @@ | ||
| # 图片资源处理 | ||
| # 图片准备 (Image Preparation) | ||
|
|
||
| ## 图片需求识别 | ||
| > 本文件说明如何在画板 DSL 中使用图片节点。进入任何含图片的场景前,必须先完成图片准备流程。 | ||
|
|
||
| **触发条件(严格)**:仅当用户**显式要求**使用图片时,才使用 image 节点。触发关键词: | ||
| ## 概述 | ||
|
|
||
| > 图片、配图、插图、照片、真实图片、实拍、放一张图、加个图、嵌入图片 | ||
| 画板 DSL 支持 `type: 'image'` 节点,但图片不能直接使用 URL,必须先上传到飞书获取 **media token**,然后在 DSL 中引用。 | ||
|
|
||
| **不触发的情况**:即使主题涉及旅行、美食、产品、人物等视觉性内容,只要用户没有显式说要「图片/配图/插图」,就**一律不使用 image 节点**,用文字 + 形状 + icon 来呈现即可。 | ||
| **关键约束**: | ||
| - 图片 token 必须通过 `docs +media-upload --parent-type whiteboard` 上传获取 | ||
| - 图片必须上传到**目标画板**(`--parent-node` 设为目标画板 token),跨画板的 token 不可用 | ||
| - `drive +upload` 获取的 Drive file token **不能**用于画板图片节点 | ||
|
|
||
| 识别到图片需求后,先完成下方 Step 0,再回到 [DSL 路径 Workflow](../routes/dsl.md) 继续 Step 2(生成 DSL)。 | ||
| ## Step 0:图片准备流程 | ||
|
|
||
| **图片数量**:3-6 张为宜。 | ||
| ### 1. 下载图片 | ||
|
|
||
| ## Step 0:图片准备 | ||
| 用 `curl` 下载图片到本地。**必须使用能根据关键词返回相关图片的图片源**。 | ||
|
|
||
| 1. 识别图片需求(见上方触发关键词表) | ||
| 2. 确定需要几张图,为每张图准备不同的搜索关键词(英文) | ||
| 3. 逐张下载 → 校验每张图不同(文件大小) → 逐张上传到飞书 Drive | ||
| 4. 收集所有 file_token,在 Step 2 生成 DSL 时引用 | ||
| **推荐图片源**: | ||
|
|
||
| ## 上传步骤 | ||
| | 图片源类型 | 说明 | | ||
| |-------|------| | ||
| | 免费版权图库 | 支持按关键词搜索,图片无版权风险(CC0 或类似协议),图库种类丰富(人物/动物/风景/美食/建筑等),关键词能精准匹配图片内容 | | ||
| | 直接 URL | 用户提供或已知的图片链接,最可靠 | | ||
|
|
||
| **选择图库的必要条件**: | ||
| - **版权合规**:图片必须无版权纠纷风险,避免使用需要付费授权或有使用限制的图库 | ||
| - **关键词搜索**:支持按关键词搜索并返回相关图片,确保图片内容与主题匹配 | ||
| - **内容丰富**:图库图片种类多、数量大,能覆盖常见主题(宠物、美食、景点、产品等) | ||
|
|
||
| **单张图片**: | ||
| ```bash | ||
| curl -L -o palace.jpg "https://example.com/palace.jpg" | ||
| lark-cli drive +upload --file ./palace.jpg | ||
| # 响应: { "file_token": "<file_token>", ... } | ||
| curl -L -o photo1.jpg "<图片URL>" | ||
| curl -L -o photo2.jpg "<图片URL>" | ||
| ``` | ||
|
|
||
| **多张图片(每张必须是不同的图)**: | ||
| ```bash | ||
| # 1. 每张图用不同的搜索词/URL 下载 | ||
| curl -L -o forbidden-city.jpg "https://example.com/forbidden-city.jpg" | ||
| curl -L -o great-wall.jpg "https://example.com/great-wall.jpg" | ||
| curl -L -o temple.jpg "https://example.com/temple.jpg" | ||
| **严禁使用随机占位图服务**:某些图库仅提供随机占位图,URL 中的关键词参数不会影响返回的图片内容,下载的图片与主题完全无关。 | ||
|
|
||
| # 2. 校验每张图确实不同(比较文件大小,跨平台通用) | ||
| ### 2. 校验图片 | ||
|
|
||
| ```bash | ||
| ls -l *.jpg # 确认每张文件大小不同;若大小相同则内容可能重复,需重新下载 | ||
| ``` | ||
|
zkh-bytedance marked this conversation as resolved.
|
||
|
|
||
| **图片内容审查(必须执行)**: | ||
| - 下载完成后,确认文件是真实图片而非 HTML 错误页:若某张图片大小 < 1KB,很可能是下载失败返回了 HTML 错误页,需重新下载 | ||
| - **图片内容正确性只能在渲染后验证**:生成 DSL 并本地渲染 PNG 后,必须查看渲染结果,确认每张图片内容与主题相关(如宠物主题的图片确实是宠物,而非建筑/风景等不相关内容) | ||
| - 若发现图片内容与主题不符,必须用更精确的关键词重新下载并重新上传 | ||
|
|
||
| ### 3. 上传到目标画板 | ||
|
|
||
| # 3. 逐张上传,收集 token | ||
| lark-cli drive +upload --file ./forbidden-city.jpg # → <file_token_1> | ||
| lark-cli drive +upload --file ./great-wall.jpg # → <file_token_2> | ||
| lark-cli drive +upload --file ./temple.jpg # → <file_token_3> | ||
| **必须**使用 `docs +media-upload --parent-type whiteboard` 上传: | ||
|
|
||
| ```bash | ||
| lark-cli docs +media-upload --file ./photo1.jpg --parent-type whiteboard --parent-node <whiteboard_token> | ||
| # 响应: { "file_token": "<media_token>", ... } | ||
| ``` | ||
|
|
||
| > **多图常见错误**:用同一个 URL 参数下载多次,导致多张图片完全相同。每张图必须用不同的搜索关键词或不同的图片 ID。 | ||
| 逐张上传,收集每个 media token: | ||
|
|
||
| ## 图片来源策略 | ||
| ```bash | ||
| lark-cli docs +media-upload --file ./photo1.jpg --parent-type whiteboard --parent-node <whiteboard_token> # → <media_token_1> | ||
| lark-cli docs +media-upload --file ./photo2.jpg --parent-type whiteboard --parent-node <whiteboard_token> # → <media_token_2> | ||
| lark-cli docs +media-upload --file ./photo3.jpg --parent-type whiteboard --parent-node <whiteboard_token> # → <media_token_3> | ||
| ``` | ||
|
|
||
| ### 4. 在 DSL 中引用 | ||
|
|
||
| ```json | ||
| { "type": "image", "id": "img-1", "width": 240, "height": 160, "image": { "src": "<media_token_1>" } } | ||
| ``` | ||
|
|
||
| | 来源 | 方式 | 适用场景 | | ||
| |------|------|----------| | ||
| | 公开 URL | `curl -L -o file.jpg <URL>` 下载后上传 | 景点照片、开源图片 | | ||
| | AI 生成 | 调用图片生成工具,保存后上传 | 插画、图标、概念图 | | ||
| | 用户提供 | 用户给出本地路径或 URL | 产品截图、Logo | | ||
| ## 常见错误 | ||
|
|
||
| > `image.src` 必须是飞书 Drive 的 `file_token`,不支持直接使用 URL。所有图片都需要先上传。 | ||
| | 错误现象 | 原因 | 解决 | | ||
| |---------|------|------| | ||
| | 画板 API 返回 500(2891001) | 使用了 Drive file token 而非 media token | 改用 `docs +media-upload --parent-type whiteboard` | | ||
| | 画板 API 返回 500 | 图片上传到了其他画板 | 重新上传到目标画板 | | ||
| | 图片裂开/无法显示 | token 无效或已过期 | 重新上传获取新 token | | ||
| | 图片内容与主题无关 | 使用了随机占位图服务 | 改用免费版权图库服务 | | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.