Skip to content

Commit

Permalink
add option to switch between v2/v3 transformers in SMart EMbed
Browse files Browse the repository at this point in the history
  • Loading branch information
brianpetro committed Sep 2, 2024
1 parent bb3674e commit 4830b56
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
9 changes: 9 additions & 0 deletions smart-embed-model/adapters/transformers_iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,14 @@ export class SmartEmbedTransformersIframeAdapter extends SmartEmbedIframeAdapter
constructor(smart_embed) {
super(smart_embed);
this.connector = transformers_connector;
if(this.smart_embed.env.settings.legacy_transformers){
this.connector = this.connector
.replace('@xenova/transformers', 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]')
;
this.smart_embed.opts.use_gpu = false;
}
else this.connector = this.connector
.replace('@xenova/transformers', 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]')
;
}
}
2 changes: 1 addition & 1 deletion smart-embed-model/build/esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function build_transformers_iframe_connector() {

const outputContent = result.outputFiles[0].text;
const wrappedContent = `export const transformers_connector = ${JSON.stringify(outputContent)};`
.replace('@xenova/transformers', 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]')
// .replace('@xenova/transformers', 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]')
// escape ${}
// .replace(/\$\{([\w.]+)\}/g, '\\`+$1+\\`')
;
Expand Down
Loading

0 comments on commit 4830b56

Please sign in to comment.