File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,12 @@ pub async fn generate_embeddings(
50
50
let bpe = Arc :: new ( cl100k_base ( ) . map_err ( |e| ServerError :: Tiktoken ( e. to_string ( ) ) ) ?) ;
51
51
52
52
const CONCURRENCY_LIMIT : usize = 8 ; // Number of concurrent requests
53
- const TOKEN_LIMIT : usize = 8000 ; // Keep a buffer below the 8192 limit
53
+
54
+ // Our default model only supports roughly 8k tokens
55
+ let token_limit: usize = std:: env:: var ( "EMBEDDING_TOKEN_LIMIT" )
56
+ . ok ( )
57
+ . and_then ( |lim| lim. trim ( ) . parse ( ) . ok ( ) )
58
+ . unwrap_or ( 8000 ) ;
54
59
55
60
let results = stream:: iter ( documents. iter ( ) . enumerate ( ) )
56
61
. map ( |( index, doc) | {
@@ -64,12 +69,12 @@ pub async fn generate_embeddings(
64
69
// Calculate token count for this document
65
70
let token_count = bpe. encode_with_special_tokens ( & doc. content ) . len ( ) ;
66
71
67
- if token_count > TOKEN_LIMIT {
72
+ if token_count > token_limit {
68
73
// eprintln!(
69
74
// " Skipping document {}: Actual tokens ({}) exceed limit ({}). Path: {}",
70
75
// index + 1,
71
76
// token_count,
72
- // TOKEN_LIMIT ,
77
+ // token_limit ,
73
78
// doc.path
74
79
// );
75
80
// Return Ok(None) to indicate skipping, with 0 tokens processed for this doc
You can’t perform that action at this time.
0 commit comments