This commit is contained in:
Manav Rathi
2024-06-26 11:22:36 +05:30
parent 3d91e1c481
commit a5a7c4fcb2
3 changed files with 48 additions and 9 deletions

View File

@@ -1,3 +1,4 @@
import type { EmbeddingModel } from "@/new/photos/services/embedding";
import { inWorker } from "@/next/env";
import log from "@/next/log";
import { apiOrigin } from "@/next/origins";
@@ -9,7 +10,6 @@ import localForage from "@ente/shared/storage/localForage";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import type {
Embedding,
EmbeddingModel,
EncryptedEmbedding,
GetEmbeddingDiffResponse,
PutEmbeddingRequest,

View File

@@ -1,11 +1,4 @@
/**
* The embeddings that we (the current client) knows how to handle.
*
* This is an exhaustive set of values we pass when PUT-ting encrypted
* embeddings on the server. However, we should be prepared to receive an
* {@link EncryptedEmbedding} with a model value different from these.
*/
export type EmbeddingModel = "onnx-clip" | "file-ml-clip-face";
import type { EmbeddingModel } from "@/new/photos/services/embedding";
export interface EncryptedEmbedding {
fileID: number;

View File

@@ -0,0 +1,46 @@
/**
* The embeddings that we (the current client) knows how to handle.
*
* It is vernacularly called a model, but strictly speaking this is not the
* model, but the embedding produced by a particular model with a particular set
* of pre-/post- processing steps and related hyperparameters. It is better
* thought of as an "type" of embedding produced or consumed by the client.
*
* The embeddings themselves have a version included in them, so it is possible
* for us to make backward compatible updates to the indexing process on newer
* clients. Alternatively, if the changes are not backward compatible and can
* only be consumed by clients with the relevant scaffolding, then we change
* this "model" (i.e "type") field to create a new universe of embeddings.
*
* This is an exhaustive set of values we pass when GET-ing or PUT-ting
* encrypted embeddings from remote. However, we should be prepared to receive
* an {@link EncryptedEmbedding} with a model value different from these.
*/
export type EmbeddingModel = "onnx-clip" | "file-ml-clip-face";
/**
* Ask remote for what all changes have happened to the face embeddings that it
* knows about since the last time we synced. Then update our local state to
* reflect those changes.
*
* It takes no parameters since it saves the last sync time in local storage.
*/
export const syncRemoteFaceEmbeddings = async () => {
return 0;
};
// const getFaceEmbeddings = async () => {
// }
/**
* GET /embeddings/diff for the given model and changes {@link sinceTime}.
*
* @param model The {@link EmbeddingModel} whose diff we wish for.
*
* @param sinceTime The last time we synced (epoch ms).
*/
// const getEmbeddingsDiff = async (model: EmbeddingModel, sinceTime: number) => {
// // const params = new URLSearchParams()
// }