forked from coderabbitai/ai-pr-reviewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlimits.ts
29 lines (27 loc) · 856 Bytes
/
limits.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
export class TokenLimits {
maxTokens: number
requestTokens: number
responseTokens: number
knowledgeCutOff: string
constructor(model = 'gpt-3.5-turbo') {
this.knowledgeCutOff = '2021-09-01'
if (model === 'gpt-4-32k') {
this.maxTokens = 32600
this.responseTokens = 4000
} else if (model === 'gpt-3.5-turbo-16k') {
this.maxTokens = 16300
this.responseTokens = 3000
} else if (model === 'gpt-4') {
this.maxTokens = 8000
this.responseTokens = 2000
} else {
this.maxTokens = 4000
this.responseTokens = 1000
}
// provide some margin for the request tokens
this.requestTokens = this.maxTokens - this.responseTokens - 100
}
string(): string {
return `max_tokens=${this.maxTokens}, request_tokens=${this.requestTokens}, response_tokens=${this.responseTokens}`
}
}