Skip to content

Commit

Permalink
Merge branch 'refactor' into release/v1.1.0-alpha.3
Browse files Browse the repository at this point in the history
  • Loading branch information
t83714 committed Jan 24, 2025
2 parents 6a6b0b5 + 1f70046 commit 772360e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"prebuild": "rimraf dist",
"build": "tsc",
"watch": "tsc -w",
"start": "npm run build && fastify start -T 60000 -l info dist/app.js",
"start": "npm run build && fastify start -T 60000 -l info dist/app.js -- --workerTaskTimeout 10000",
"download-default-model": "node ./dist/loadDefaultModel.js",
"dev": "npm run build && concurrently -k -p \"[{name}]\" -n \"TypeScript,App\" -c \"yellow.bold,cyan.bold\" \"npm:watch\" \"npm:dev:start\"",
"dev:start": "fastify start --ignore-watch=.ts$ -w -l info -P dist/app.js",
Expand Down
12 changes: 9 additions & 3 deletions src/libs/EmbeddingEncoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class EmbeddingEncoder {

// Run tokenization
const model_inputs = this.tokenizer(texts, {
padding: true,
padding: typeof texts !== "string",
truncation: true,
max_length:
typeof max_length !== "undefined" && max_length > 0
Expand Down Expand Up @@ -334,6 +334,8 @@ class EmbeddingEncoder {
`Model \`${model}\` is not supported. Supported models: ${this.supportModels.join(", ")}`
);
}
const modelOpts = this.getModelByName(model);
const { max_length } = modelOpts;
opts = {
...opts,
...(typeof opts.padding !== "boolean" ? { padding: true } : {}),
Expand All @@ -343,8 +345,12 @@ class EmbeddingEncoder {
};

return this.tokenizer(texts, {
padding: true,
truncation: true
padding: typeof texts !== "string",
truncation: true,
max_length:
typeof max_length !== "undefined" && max_length > 0
? max_length
: DEFAULT_MAX_LENGTH
});
}
}
Expand Down

0 comments on commit 772360e

Please sign in to comment.