forked from run-llama/LlamaIndexTS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: polyfill for cloudflare worker (run-llama#919)
- Loading branch information
Showing
7 changed files
with
114 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"llamaindex": patch | ||
"@llamaindex/core-e2e": patch | ||
"@llamaindex/cloudflare-worker-agent-test": patch | ||
--- | ||
|
||
fix: polyfill for cloudflare worker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { ImageType } from "../Node.js"; | ||
import { MultiModalEmbedding } from "./MultiModalEmbedding.js"; | ||
|
||
/** | ||
* Cloudflare worker doesn't support image embeddings for now | ||
*/ | ||
export class CloudflareWorkerMultiModalEmbedding extends MultiModalEmbedding { | ||
getImageEmbedding(images: ImageType): Promise<number[]> { | ||
throw new Error("Method not implemented."); | ||
} | ||
getTextEmbedding(text: string): Promise<number[]> { | ||
throw new Error("Method not implemented."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export async function getImageEmbedModel() { | ||
if (globalThis.navigator?.userAgent === "Cloudflare-Workers") { | ||
return (await import("../../embeddings/CloudflareWorkerEmbedding.js")) | ||
.CloudflareWorkerMultiModalEmbedding; | ||
} else { | ||
return (await import("../../embeddings/ClipEmbedding.js")).ClipEmbedding; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.