Skip to content

Commit

Permalink
[_]
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed May 23, 2023
1 parent 7e0363b commit bfdea0b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Will be replaced by the new vector process
*/

const MaxTokens = 2048;
const MaxTokens = 1536;
const distance = 0.2;
const distancePrompts = 2;
const pageSize = 9;
Expand Down Expand Up @@ -131,12 +131,17 @@ function Save(payload) {
*/
function Reduce(content) {
var tokenSize = MaxTokens;
if (content.length > 5000) {
content = content.substring(0, 5000);
}

while (tokenSize >= MaxTokens) {
// process: openai.Tiktoken
// args[0]: is the model name
// args[1]: is the content
tokenSize = Process("openai.Tiktoken", "gpt-3.5-turbo", content);
content = content.substring(0, content.length - 128);
console.log(`Reduce the content size to ${tokenSize}`);
}
return content;
}
Expand Down

0 comments on commit bfdea0b

Please sign in to comment.