API 参考
图片
通过 app.capabilities 判断功能支持,通过 app.access 和宿主权限判断访问授权。示例使用合成数据,调用前请替换路径、ID、输入和筛选条件。
类型定义
graphql
type Subscription {
imageModelsUpdated: ImageModelsUpdate!
}
type Mutation {
cancelImageIndex: Boolean!
cancelImageModelDownload: Boolean!
disableImageSearch: Boolean!
enableImageSearch: Boolean!
importImageSearchModel: Boolean!
startImageIndex(force: Boolean): Boolean!
}
type Query {
imageCount(query: String!): Int!
imageSearchStatus: ImageSearchStatus!
images(query: String!, offset: Int!, limit: Int!, sortBy: ImageSortBy!): [Image!]!
}
enum DataType {
DEFAULT
AUDIO
VIDEO
IMAGE
SMS
CONTACT
NOTE
FEED_ENTRY
CALL
PACKAGE
FILE
APP_FILE
DOC
}
type Image implements MediaItem {
id: ID!
title: String!
path: String!
size: Long!
width: Int!
height: Int!
rotation: Int!
bucketId: ID!
createdAt: Instant!
updatedAt: Instant!
takenAt: Instant
isFavorite: Boolean!
tags: [Tag!]!
}
type ImageModelsUpdate {
version: Long!
status: ImageSearchStatusType!
downloadProgress: Int!
errorMessage: String!
modelSize: Long!
modelDir: String!
isIndexing: Boolean!
totalImages: Int!
indexedImages: Int!
}
type ImageSearchStatus {
status: ImageSearchStatusType!
downloadProgress: Int!
errorMessage: String!
modelSize: Long!
modelDir: String!
isIndexing: Boolean!
totalImages: Int!
indexedImages: Int!
}
enum ImageSearchStatusType {
UNAVAILABLE
DOWNLOADING
LOADING
READY
ERROR
}
enum ImageSortBy {
UPDATED_AT_ASC
UPDATED_AT_DESC
SIZE_ASC
SIZE_DESC
NAME_ASC
NAME_DESC
TAKEN_AT_DESC
}
scalar Instant
scalar Long
interface MediaItem {
id: ID!
title: String!
path: String!
size: Long!
bucketId: ID!
createdAt: Instant!
updatedAt: Instant!
}
type Tag {
id: ID!
name: String!
type: DataType!
count: Int!
}操作
subscription
imageModelsUpdated
接收图片搜索模型下载或可用性更新。
graphql
subscription imageModelsUpdated {
imageModelsUpdated { version status downloadProgress errorMessage modelSize modelDir isIndexing totalImages }
}mutation
cancelImageIndex
取消正在运行的索引任务。
graphql
mutation cancelImageIndex {
cancelImageIndex
}mutation
cancelImageModelDownload
取消正在进行的 AI 模型下载。
graphql
mutation cancelImageModelDownload {
cancelImageModelDownload
}mutation
disableImageSearch
停用 AI 图片语义搜索并释放资源。
graphql
mutation disableImageSearch {
disableImageSearch
}mutation
enableImageSearch
启用 AI 图片语义搜索;本地模型不存在时下载模型。
graphql
mutation enableImageSearch {
enableImageSearch
}mutation
importImageSearchModel
验证并启用已完整上传的图片搜索模型包。
graphql
mutation importImageSearchModel {
importImageSearchModel
}mutation
startImageIndex
开始为 AI 搜索建立图片索引;force=true 时全部重新索引。
graphql
# `force` re-scans images that already have an embedding.
mutation startImageIndex($force: Boolean) {
startImageIndex(force: $force)
}query
imageCount
统计符合查询条件的图片数。
graphql
query imageCount($query: String!) {
imageCount(query: $query)
}query
imageSearchStatus
获取 AI 语义搜索当前的索引状态。
graphql
query imageSearchStatus {
imageSearchStatus { status downloadProgress errorMessage modelSize modelDir isIndexing totalImages indexedImages }
}query
images
搜索图片目录,支持筛选、分页和排序。
graphql
query images($query: String!, $offset: Int!, $limit: Int!, $sortBy: ImageSortBy!) {
images(query: $query, offset: $offset, limit: $limit, sortBy: $sortBy) { id title path size width height rotation bucketId }
}