libtv-skill
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseagent-im 会话(生图 / 生视频)
Agent-IM Conversation (Image/Video Generation)
通过 agent-im 的 OpenAPI 创建会话、发送消息(生图、生视频等),并查询会话消息进展。
Create sessions, send messages (such as image/video generation requests) via Agent-IM's OpenAPI, and query session message progress.
功能
Features
- 创建会话 / 发消息 - 创建新会话或向已有会话发送一条消息(如「生一个动漫视频」)
- 查询会话进展 - 根据 sessionId 拉取该会话的消息列表,用于轮询生图/生视频结果
- 切换项目 - 将当前 accessKey 绑定的项目切换到新项目,后续 create_session 将使用新 projectUuid
- Create Session / Send Message - Create a new session or send a message to an existing session (e.g., "Generate an anime video")
- Query Session Progress - Pull the message list of a session based on sessionId, used for polling image/video generation results
- Switch Project - Switch the project bound to the current accessKey to a new project, and subsequent create_session will use the new projectUuid
前置要求
Prerequisites
bash
export LIBTV_ACCESS_KEY="your-access-key"可选: 或 ,默认 。
OPENAPI_IM_BASEIM_BASE_URLhttps://im.liblib.tv无需安装额外依赖,仅使用 Python 标准库。
bash
export LIBTV_ACCESS_KEY="your-access-key"Optional: or , default .
OPENAPI_IM_BASEIM_BASE_URLhttps://im.liblib.tvNo additional dependencies required, only uses Python standard libraries.
使用方法
Usage
1. 创建会话 / 发送消息
1. Create Session / Send Message
bash
undefinedbash
undefined创建新会话并发送「生一个动漫视频」
Create a new session and send "Generate an anime video"
python3 {baseDir}/scripts/create_session.py "生一个动漫视频"
python3 {baseDir}/scripts/create_session.py "Generate an anime video"
向已有会话发送消息
Send a message to an existing session
python3 {baseDir}/scripts/create_session.py "再生成一张风景图" --session-id SESSION_ID
python3 {baseDir}/scripts/create_session.py "Generate another landscape image" --session-id SESSION_ID
只创建/绑定会话,不发消息
Only create/bind a session without sending a message
python3 {baseDir}/scripts/create_session.py
undefinedpython3 {baseDir}/scripts/create_session.py
undefined2. 查询会话进展
2. Query Session Progress
bash
undefinedbash
undefined查询会话消息列表
Query session message list
python3 {baseDir}/scripts/query_session.py SESSION_ID
python3 {baseDir}/scripts/query_session.py SESSION_ID
增量拉取(只返回 seq 大于 N 的消息)
Incremental pull (only returns messages with seq greater than N)
python3 {baseDir}/scripts/query_session.py SESSION_ID --after-seq 5
python3 {baseDir}/scripts/query_session.py SESSION_ID --after-seq 5
附带项目地址(传入 create_session 返回的 projectUuid,结果中带 projectUrl)
Attach project URL (pass the projectUuid returned by create_session, projectUrl will be included in the result)
python3 {baseDir}/scripts/query_session.py SESSION_ID --project-id PROJECT_UUID
undefinedpython3 {baseDir}/scripts/query_session.py SESSION_ID --project-id PROJECT_UUID
undefined3. 切换项目
3. Switch Project
bash
undefinedbash
undefined切换当前 accessKey 绑定的项目(后续创建会话将使用新项目)
Switch the project bound to the current accessKey (new projectUuid will be used for subsequent create_session)
python3 {baseDir}/scripts/change_project.py
undefinedpython3 {baseDir}/scripts/change_project.py
undefined输出格式
Output Format
create_session 返回:
json
{
"projectUuid": "aa3ba04c5044477cb7a00a9e5bf3b4d0",
"sessionId": "90f05e0c-...",
"projectUrl": "https://www.liblib.tv/canvas?projectId=aa3ba04c5044477cb7a00a9e5bf3b4d0"
}query_session 返回:
json
{
"messages": [
{"id": "msg-xxx", "role": "user", "content": "生一个动漫视频"},
{"id": "msg-yyy", "role": "assistant", "content": "..."}
],
"projectUrl": "https://www.liblib.tv/canvas?projectId=..."
}( 仅在传入 时存在)
projectUrl--project-idchange_project 返回:
json
{
"projectUuid": "新项目UUID",
"projectUrl": "https://www.liblib.tv/canvas?projectId=新项目UUID"
}create_session returns:
json
{
"projectUuid": "aa3ba04c5044477cb7a00a9e5bf3b4d0",
"sessionId": "90f05e0c-...",
"projectUrl": "https://www.liblib.tv/canvas?projectId=aa3ba04c5044477cb7a00a9e5bf3b4d0"
}query_session returns:
json
{
"messages": [
{"id": "msg-xxx", "role": "user", "content": "Generate an anime video"},
{"id": "msg-yyy", "role": "assistant", "content": "..."}
],
"projectUrl": "https://www.liblib.tv/canvas?projectId=..."
}("projectUrl" only exists when is passed)
--project-id最终向用户展示时(OpenClaw)
For Final User Display (OpenClaw)
- 视频地址:来自 返回的
query_session中 assistant 消息的 content 或结果里的视频/图片 URL,即「返回的结果」。messages - 项目地址:使用 返回的
create_session,或自行拼接projectUrl+https://www.liblib.tv/canvas?projectId=。查询进展时若传入projectUuid,--project-id PROJECT_UUID会直接返回query_session,便于一并展示。projectUrl
建议在任务完成或用户询问进展时,同时给出:视频/图片结果链接 + 项目画布链接(projectUrl)。
- Video URL: From the content of assistant messages in returned by
messagesor the video/image URL in the result, i.e., the "returned result".query_session - Project URL: Use the returned by
projectUrl, or concatenate it manually ascreate_session+https://www.liblib.tv/canvas?projectId=. When querying progress withprojectUuid,--project-id PROJECT_UUIDwill directly returnquery_sessionfor easy display together.projectUrl
It is recommended to provide both: Video/Image Result Link + Project Canvas Link (projectUrl) when the task is completed or when the user inquires about progress.
注意事项
Notes
- 鉴权方式为请求头
Authorization: Bearer <LIBTV_ACCESS_KEY> - 创建会话时若不传 ,仅创建/绑定会话,不会调用 SendMessage
message - 查询会话时可用 做增量拉取,便于轮询新消息(含 assistant 回复与生图/生视频结果)
--after-seq - 项目画布地址固定为:+ projectUuid
https://www.liblib.tv/canvas?projectId= - 切换项目后,Redis 缓存会更新,下次 create_session 将使用新的 projectUuid
- Authentication method: Request header
Authorization: Bearer <LIBTV_ACCESS_KEY> - If no is passed when creating a session, only a session is created/bound, and SendMessage will not be called
message - Use for incremental pull when querying sessions, which is convenient for polling new messages (including assistant replies and image/video generation results)
--after-seq - The project canvas URL is fixed as: + projectUuid
https://www.liblib.tv/canvas?projectId= - After switching projects, the Redis cache will be updated, and the new projectUuid will be used for the next create_session