clipprobe

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package clipprobe talks to the external immich-clip-probe service (https://github.com/dhcgn/immich-clip-probe/), which exposes Immich's CLIP similarity search for files that are not in Immich yet. It is the only place that does raw HTTP for clip-probe; command and workflow code must go through Client.

Index

Constants

This section is empty.

Variables

View Source
var ValidTypes = []string{"IMAGE", "VIDEO", "all"}

ValidTypes is the closed set accepted by POST /v1/similar ?type=.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to one clip-probe service. No Immich credentials are ever sent here — the token is the service's own API_TOKEN (x-api-key header).

func New

func New(server, token string) *Client

New builds a Client for the service origin (e.g. https://clip-probe.example.com/).

func (*Client) FindSimilar

func (c *Client) FindSimilar(ctx context.Context, filePath string, opts Options) (*SimilarResponse, []byte, error)

FindSimilar posts one image file and returns the decoded response plus the raw body (for --json output). An empty Matches is not an error.

type ErrorBody

type ErrorBody struct {
	Error   string `json:"error"`
	Message string `json:"message"`
}

ErrorBody is the service's error shape. Match on Error, never on Message.

type Links struct {
	Web       string `json:"web,omitempty"`
	Thumbnail string `json:"thumbnail,omitempty"`
}

Links holds deep links to a match. Absent unless the service is configured with PUBLIC_IMMICH_URL.

type Match

type Match struct {
	AssetID          string  `json:"assetId"`
	OriginalFileName string  `json:"originalFileName"`
	Type             string  `json:"type"`
	LocalDateTime    string  `json:"localDateTime,omitempty"`
	FileCreatedAt    string  `json:"fileCreatedAt,omitempty"`
	OwnerID          string  `json:"ownerId,omitempty"`
	Distance         float64 `json:"distance"`
	Similarity       float64 `json:"similarity"`
	Links            *Links  `json:"links,omitempty"`
}

Match is one visually-nearest asset, ascending by Distance.

type Options

type Options struct {
	Limit       int
	MaxDistance float64
	All         bool
	Type        string
}

Options maps 1:1 to the /v1/similar query parameters.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions mirrors the service defaults (openapi.yaml).

func (Options) Validate

func (o Options) Validate() error

Validate rejects values outside the service's closed set before any I/O.

type Query

type Query struct {
	FileName   string `json:"fileName,omitempty"`
	Bytes      int64  `json:"bytes"`
	Width      int    `json:"width"`
	Height     int    `json:"height"`
	Normalized bool   `json:"normalized"`
	Model      string `json:"model"`
	Dimensions int    `json:"dimensions"`
}

Query describes what the service actually embedded.

type SimilarResponse

type SimilarResponse struct {
	Query       Query    `json:"query"`
	Duplicate   bool     `json:"duplicate"`
	MaxDistance float64  `json:"maxDistance"`
	Matches     []Match  `json:"matches"`
	Timings     *Timings `json:"timings,omitempty"`
}

SimilarResponse is the POST /v1/similar payload. An empty Matches array is a normal result (nothing close enough).

type Timings

type Timings struct {
	NormalizeMs int64 `json:"normalizeMs,omitempty"`
	EmbedMs     int64 `json:"embedMs,omitempty"`
	QueryMs     int64 `json:"queryMs,omitempty"`
	TotalMs     int64 `json:"totalMs,omitempty"`
}

Timings holds per-stage wall-clock milliseconds.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL