Skip to content

Commit

Permalink
Fix temperature & maxToken params
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Mar 23, 2024
1 parent 7750bb3 commit 6b3584b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class GptPromptExtension extends PluginExtensionPoint {
final ai = new GptPromptModel(session)
.withModel(opts.model as String)
.withDebug(opts.debug as Boolean)
.withTemperature(opts.temperature as Double)
.withMaxToken(opts.maxTokens as Integer)
.build()
// run the prompt
final response = ai.prompt(query, opts.schema as Map)
Expand All @@ -84,6 +86,8 @@ class GptPromptExtension extends PluginExtensionPoint {
final ai = new GptPromptModel(session)
.withModel(opts.model as String)
.withDebug(opts.debug as Boolean)
.withTemperature(opts.temperature as Double)
.withMaxToken(opts.maxTokens as Integer)
.build()

final target = CH.createBy(source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ class GptPromptModel {

GptPromptModel build() {
final modelName = model ?: config.model()
final temp = temperature ?: config.temperature()
final temperature = this.temperature ?: config.temperature()
final tokens = maxTokens ?: config.maxTokens()
log.debug "Creating OpenAI chat model: $modelName; api-key: ${StringUtils.redact(config.apiKey())}; temperature: $temp; maxTokens: ${maxTokens}"
log.debug "Creating OpenAI chat model: $modelName; api-key: ${StringUtils.redact(config.apiKey())}; temperature: $temperature; maxTokens: ${maxTokens}"
client = OpenAiChatModel.builder()
.apiKey(config.apiKey())
.modelName(modelName)
.logRequests(debug)
.logResponses(debug)
.temperature(temperature)
.maxTokens(maxTokens)
.maxTokens(tokens)
.responseFormat("json_object")
.build();
return this
Expand Down

0 comments on commit 6b3584b

Please sign in to comment.