|
@@ -75,7 +75,6 @@ class CLIPService {
|
|
private onFileUploadedHandler:
|
|
private onFileUploadedHandler:
|
|
| ((arg: { enteFile: EnteFile; localFile: globalThis.File }) => void)
|
|
| ((arg: { enteFile: EnteFile; localFile: globalThis.File }) => void)
|
|
| null = null;
|
|
| null = null;
|
|
- private unsupportedPlatform = false;
|
|
|
|
|
|
|
|
constructor() {
|
|
constructor() {
|
|
this.liveEmbeddingExtractionQueue = new PQueue({
|
|
this.liveEmbeddingExtractionQueue = new PQueue({
|
|
@@ -85,7 +84,7 @@ class CLIPService {
|
|
}
|
|
}
|
|
|
|
|
|
isPlatformSupported = () => {
|
|
isPlatformSupported = () => {
|
|
- return isElectron() && !this.unsupportedPlatform;
|
|
|
|
|
|
+ return isElectron();
|
|
};
|
|
};
|
|
|
|
|
|
private logoutHandler = async () => {
|
|
private logoutHandler = async () => {
|
|
@@ -99,9 +98,6 @@ class CLIPService {
|
|
|
|
|
|
setupOnFileUploadListener = async () => {
|
|
setupOnFileUploadListener = async () => {
|
|
try {
|
|
try {
|
|
- if (this.unsupportedPlatform) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
if (this.onFileUploadedHandler) {
|
|
if (this.onFileUploadedHandler) {
|
|
log.info("file upload listener already setup");
|
|
log.info("file upload listener already setup");
|
|
return;
|
|
return;
|
|
@@ -188,26 +184,12 @@ class CLIPService {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
- getTextEmbedding = async (text: string): Promise<Float32Array> => {
|
|
|
|
- try {
|
|
|
|
- return ensureElectron().clipTextEmbedding(text);
|
|
|
|
- } catch (e) {
|
|
|
|
- if (e?.message?.includes(CustomError.UNSUPPORTED_PLATFORM)) {
|
|
|
|
- this.unsupportedPlatform = true;
|
|
|
|
- }
|
|
|
|
- log.error("Failed to compute CLIP text embedding", e);
|
|
|
|
- throw e;
|
|
|
|
- }
|
|
|
|
|
|
+ getTextEmbedding = async (text: string) => {
|
|
|
|
+ return ensureElectron().clipTextEmbedding(text);
|
|
};
|
|
};
|
|
|
|
|
|
private runClipEmbeddingExtraction = async (canceller: AbortController) => {
|
|
private runClipEmbeddingExtraction = async (canceller: AbortController) => {
|
|
try {
|
|
try {
|
|
- if (this.unsupportedPlatform) {
|
|
|
|
- log.info(
|
|
|
|
- `skipping clip embedding extraction, platform unsupported`,
|
|
|
|
- );
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
const user = getData(LS_KEYS.USER);
|
|
const user = getData(LS_KEYS.USER);
|
|
if (!user) {
|
|
if (!user) {
|
|
return;
|
|
return;
|
|
@@ -254,11 +236,6 @@ class CLIPService {
|
|
e,
|
|
e,
|
|
);
|
|
);
|
|
}
|
|
}
|
|
- if (
|
|
|
|
- e?.message?.includes(CustomError.UNSUPPORTED_PLATFORM)
|
|
|
|
- ) {
|
|
|
|
- this.unsupportedPlatform = true;
|
|
|
|
- }
|
|
|
|
if (
|
|
if (
|
|
e?.message === CustomError.REQUEST_CANCELLED ||
|
|
e?.message === CustomError.REQUEST_CANCELLED ||
|
|
e?.message?.includes(CustomError.UNSUPPORTED_PLATFORM)
|
|
e?.message?.includes(CustomError.UNSUPPORTED_PLATFORM)
|