From ac1edb8cec9f623a554f3843173ffa666044facf Mon Sep 17 00:00:00 2001 From: Neal Shah Date: Sun, 21 Jun 2026 19:35:55 -0400 Subject: [PATCH] Fix max_tokens bug in together provider --- .../providers/together/TogetherAIProvider.ts | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/backend/drivers/ai-chat/providers/together/TogetherAIProvider.ts b/src/backend/drivers/ai-chat/providers/together/TogetherAIProvider.ts index 529cf0b23..07a156e80 100644 --- a/src/backend/drivers/ai-chat/providers/together/TogetherAIProvider.ts +++ b/src/backend/drivers/ai-chat/providers/together/TogetherAIProvider.ts @@ -150,21 +150,7 @@ export class TogetherAIProvider implements IChatProvider { messages, stream, ...(tools ? { tools } : {}), - // TODO: make this better but togetherai doesn't handle max tokens properly at all - ...(max_tokens - ? { - max_tokens: - max_tokens - - messages.reduce((acc, curr) => { - return ( - acc + - (curr.type === 'text' - ? curr.text.length / 2 - : 200) - ); - }, 0), - } - : {}), + ...(max_tokens ? { max_tokens } : {}), ...(temperature ? { temperature } : {}), ...(stream ? { stream_options: { include_usage: true } } : {}), } as Together.Chat.Completions.CompletionCreateParamsNonStreaming);