libtv-skill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

agent-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

  1. 创建会话 / 发消息 - 创建新会话或向已有会话发送一条消息(如「生一个动漫视频」)
  2. 查询会话进展 - 根据 sessionId 拉取该会话的消息列表,用于轮询生图/生视频结果
  3. 切换项目 - 将当前 accessKey 绑定的项目切换到新项目,后续 create_session 将使用新 projectUuid
  1. Create Session / Send Message - Create a new session or send a message to an existing session (e.g., "Generate an anime video")
  2. Query Session Progress - Pull the message list of a session based on sessionId, used for polling image/video generation results
  3. 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_BASE
IM_BASE_URL
,默认
https://im.liblib.tv
无需安装额外依赖,仅使用 Python 标准库。
bash
export LIBTV_ACCESS_KEY="your-access-key"
Optional:
OPENAPI_IM_BASE
or
IM_BASE_URL
, default
https://im.liblib.tv
.
No additional dependencies required, only uses Python standard libraries.

使用方法

Usage

1. 创建会话 / 发送消息

1. Create Session / Send Message

bash
undefined
bash
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
undefined
python3 {baseDir}/scripts/create_session.py
undefined

2. 查询会话进展

2. Query Session Progress

bash
undefined
bash
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
undefined
python3 {baseDir}/scripts/query_session.py SESSION_ID --project-id PROJECT_UUID
undefined

3. 切换项目

3. Switch Project

bash
undefined
bash
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
undefined
python3 {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-id
时存在)
change_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
--project-id
is passed)

最终向用户展示时(OpenClaw)

For Final User Display (OpenClaw)

  • 视频地址:来自
    query_session
    返回的
    messages
    中 assistant 消息的 content 或结果里的视频/图片 URL,即「返回的结果」。
  • 项目地址:使用
    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
    messages
    returned by
    query_session
    or the video/image URL in the result, i.e., the "returned result".
  • Project URL: Use the
    projectUrl
    returned by
    create_session
    , or concatenate it manually as
    https://www.liblib.tv/canvas?projectId=
    +
    projectUuid
    . When querying progress with
    --project-id PROJECT_UUID
    ,
    query_session
    will directly return
    projectUrl
    for easy display together.
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>
  • 创建会话时若不传
    message
    ,仅创建/绑定会话,不会调用 SendMessage
  • 查询会话时可用
    --after-seq
    做增量拉取,便于轮询新消息(含 assistant 回复与生图/生视频结果)
  • 项目画布地址固定为:
    https://www.liblib.tv/canvas?projectId=
    + projectUuid
  • 切换项目后,Redis 缓存会更新,下次 create_session 将使用新的 projectUuid
  • Authentication method: Request header
    Authorization: Bearer <LIBTV_ACCESS_KEY>
  • If no
    message
    is passed when creating a session, only a session is created/bound, and SendMessage will not be called
  • Use
    --after-seq
    for incremental pull when querying sessions, which is convenient for polling new messages (including assistant replies and image/video generation results)
  • The project canvas URL is fixed as:
    https://www.liblib.tv/canvas?projectId=
    + projectUuid
  • After switching projects, the Redis cache will be updated, and the new projectUuid will be used for the next create_session