Optimizes token usage for timed prompts
Reduces max tokens for timed prompts to improve latency and cost-efficiency Introduces dynamic max_tokens configuration based on prompt type, using a smaller token limit for time-sensitive requests
This commit is contained in:
1 file changed
+4
-1
@@ -39,9 +39,12 @@ export class AnthropicClient {
|
|||||||
}
|
}
|
||||||
finalSystemPrompt += this.SYSTEM_PROMPT_SUFFIX;
|
finalSystemPrompt += this.SYSTEM_PROMPT_SUFFIX;
|
||||||
|
|
||||||
|
// Use smaller max_tokens for timed prompts to reduce latency/cost
|
||||||
|
const maxTokens = type === 'timed' ? 256 : 1000;
|
||||||
|
|
||||||
const request: AnthropicRequest = {
|
const request: AnthropicRequest = {
|
||||||
model,
|
model,
|
||||||
max_tokens: 1000,
|
max_tokens: maxTokens,
|
||||||
messages: [{ role: 'user', content: userMessage }],
|
messages: [{ role: 'user', content: userMessage }],
|
||||||
system: finalSystemPrompt
|
system: finalSystemPrompt
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user