Fix max_tokens bug in together provider

This commit is contained in:
Neal Shah
2026-06-21 19:35:55 -04:00
parent 748d9504a8
commit ac1edb8cec
@@ -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);