Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit 81386e9

Browse files
authored
adjust model tokens (#147)
1 parent 6ea311e commit 81386e9

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

dist/index.js

Lines changed: 15 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ export class TokenLimits {
146146

147147
constructor(model = 'gpt-3.5-turbo') {
148148
if (model === 'gpt-4-32k') {
149-
this.max_tokens = 32000
149+
this.max_tokens = 32700
150150
this.response_tokens = 4000
151151
} else if (model === 'gpt-4') {
152-
this.max_tokens = 5000
153-
this.response_tokens = 1500
152+
this.max_tokens = 8100
153+
this.response_tokens = 2000
154154
} else {
155155
this.max_tokens = 4000
156156
this.response_tokens = 1000

src/review-comment.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ export const handleReviewComment = async (
147147
prompts.summarize_file_diff.split('$file_content').length - 1
148148
const file_content_tokens = tokenizer.get_token_count(file_content)
149149
if (
150+
file_content_count > 0 &&
150151
tokens + file_content_tokens * file_content_count <=
151-
options.heavy_token_limits.request_tokens
152+
options.heavy_token_limits.request_tokens
152153
) {
153154
tokens += file_content_tokens * file_content_count
154155
inputs.file_content = file_content
@@ -165,8 +166,9 @@ export const handleReviewComment = async (
165166
prompts.summarize_file_diff.split('$file_diff').length - 1
166167
const file_diff_tokens = tokenizer.get_token_count(file_diff)
167168
if (
169+
file_diff_count > 0 &&
168170
tokens + file_diff_tokens * file_diff_count <=
169-
options.heavy_token_limits.request_tokens
171+
options.heavy_token_limits.request_tokens
170172
) {
171173
tokens += file_diff_tokens * file_diff_count
172174
inputs.file_diff = file_diff

src/review.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ ${hunks.old_hunk}
198198
prompts.summarize_file_diff.split('$file_content').length - 1
199199
const file_content_tokens = tokenizer.get_token_count(file_content)
200200
if (
201+
file_content_count > 0 &&
201202
tokens + file_content_tokens * file_content_count <=
202-
options.light_token_limits.request_tokens
203+
options.light_token_limits.request_tokens
203204
) {
204205
tokens += file_content_tokens * file_content_count
205206
ins.file_content = file_content
@@ -381,10 +382,10 @@ ${
381382
const file_content_count =
382383
prompts.summarize_file_diff.split('$file_content').length - 1
383384
const file_content_tokens = tokenizer.get_token_count(file_content)
384-
385385
if (
386+
file_content_count > 0 &&
386387
tokens + file_content_tokens * file_content_count <=
387-
options.heavy_token_limits.request_tokens
388+
options.heavy_token_limits.request_tokens
388389
) {
389390
ins.file_content = file_content
390391
tokens += file_content_tokens * file_content_count

0 commit comments

Comments
 (0)