Skip to content

Commit

Permalink
fix: ChatGPTNextWeb#3186 enable max_tokens in chat payload
Browse files Browse the repository at this point in the history
(cherry picked from commit d0a1d91)
  • Loading branch information
Yidadaa authored and Endlessworld committed Nov 16, 2023
1 parent 842a922 commit ec6aa4a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/client/platforms/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class ChatGPTApi implements LLMApi {
top_p: modelConfig.top_p,
functions: functions,
function_call: options.messages[messages.length - 1].function_call,
max_tokens: Math.max(modelConfig.max_tokens, 1024),
};

console.log("[Request] openai payload: ", requestPayload);
Expand Down
4 changes: 2 additions & 2 deletions app/components/model-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ export function ModelConfigList(props: {
>
<input
type="number"
min={100}
max={100000}
min={1024}
max={512000}
value={props.modelConfig.max_tokens}
onChange={(e) =>
props.updateConfig(
Expand Down
4 changes: 2 additions & 2 deletions app/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const DEFAULT_CONFIG = {
modelConfig: {
model: "gpt-3.5-turbo-1106" as ModelType,
temperature: 0.5,
max_tokens: 4096,
top_p: 1,
max_tokens: 8192,
presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true,
Expand Down Expand Up @@ -101,7 +101,7 @@ export const ModalConfigValidator = {
if (model == "gpt-3.5-turbo-16k" || model == "gpt-3.5-turbo-16k-0613") {
return limitNumber(x, 0, 16000, 4096);
}
return limitNumber(x, 0, 32000, 4096);
return limitNumber(x, 0, 512000, 4096);
},
presence_penalty(x: number) {
return limitNumber(x, -2, 2, 0);
Expand Down

0 comments on commit ec6aa4a

Please sign in to comment.