Skip to content

Commit

Permalink
conditionally include max_tokens and adjust default value
Browse files Browse the repository at this point in the history
  • Loading branch information
AAClause committed May 18, 2024
1 parent f9600b8 commit dee6ec4
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions addon/globalPlugins/openai/maindialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,11 @@ def run(self):
"model": model.id,
"messages": messages,
"temperature": temperature,
"max_tokens": maxTokens,
"top_p": topP,
"stream": stream
}
if maxTokens > 0:
params["max_tokens"] = maxTokens

if debug:
log.info("Client base URL: %s" % client.base_url)
Expand Down Expand Up @@ -968,11 +969,7 @@ def onModelChange(self, evt):
):
defaultMaxOutputToken = self.data[key_maxTokens]
else:
defaultMaxOutputToken = model.maxOutputToken // 2
if defaultMaxOutputToken < 1:
defaultMaxOutputToken = model.contextWindow // 2
if defaultMaxOutputToken < 1:
defaultMaxOutputToken = 1024
defaultMaxOutputToken = 0
self.maxTokensSpinCtrl.SetValue(defaultMaxOutputToken)
if self.conf["advancedMode"]:
self.temperatureSpinCtrl.SetRange(
Expand Down

0 comments on commit dee6ec4

Please sign in to comment.