Skip to content

Commit f80fdbb

Browse files
committed
Ensuring we don't overflow embeddings model's size
1 parent 0927f0b commit f80fdbb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

backend/files/system/openai/magic.startup/magic.ai.get-context.hl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ slots.create:magic.ai.get-context
3131
convert:x:@.arguments/*/threshold
3232
type:double
3333

34+
// Making sure we don't overflow model's context window.
35+
if
36+
mt
37+
openai.tokenize:x:@.arguments/*/prompt
38+
.:int:8100
39+
.lambda
40+
set-value:x:@.arguments/*/prompt
41+
strings.substring:x:@.arguments/*/prompt
42+
.:int:0
43+
.:int:16000
44+
3445
// Retrieving embeddings.
3546
.token
3647
set-value:x:@.token

0 commit comments

Comments
 (0)