feat: use CONTEXT_SIZE env variable in trimPrompt function (default 128_000)

- Added CONTEXT_SIZE variable to .env.local.
- Updated trimPrompt in providers.ts to use Number(process.env.CONTEXT_SIZE) with a default of 128_000.
This commit is contained in:
Ben Nasedkin
2025-02-07 01:46:28 +02:00
parent 43869014d8
commit 6289c740a8

View File

@@ -44,7 +44,10 @@ const MinChunkSize = 140;
const encoder = getEncoding('o200k_base');
// trim prompt to maximum context size
export function trimPrompt(prompt: string, contextSize = 120_000) {
export function trimPrompt(
prompt: string,
contextSize = Number(process.env.CONTEXT_SIZE) || 128_000,
) {
if (!prompt) {
return '';
}