mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 10:55:27 +00:00
* feat(search): add image similarity search * feat(search): support pasting image attachments
22 lines
745 B
TypeScript
22 lines
745 B
TypeScript
import { client } from '@/ui/api/client'
|
|
import { m } from '@/ui/paraglide/messages.js'
|
|
import type { ImageSearchRequest } from '@shumai/dtos'
|
|
|
|
export async function searchByImage(
|
|
folderId: string,
|
|
request: ImageSearchRequest,
|
|
signal: AbortSignal,
|
|
) {
|
|
const res = await client.api.folders[':folderId']['image-search'].$post(
|
|
{ param: { folderId }, json: request },
|
|
{ init: { signal } },
|
|
)
|
|
if (!res.ok) {
|
|
if (res.status === 409) throw new Error(m.image_search_waiting_for_index())
|
|
if (res.status === 422) throw new Error(m.enable_embedding_agent_hint())
|
|
if (res.status === 400 || res.status === 413) throw new Error(m.image_search_invalid_image())
|
|
throw new Error(m.search_failed())
|
|
}
|
|
return res.json()
|
|
}
|