presencePenalty method

OpenAIBuilder presencePenalty(
  1. double penalty
)

Sets presence penalty for encouraging topic diversity (-2.0 to 2.0)

Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

  • Negative values: Encourage staying on topic
  • 0.0: No penalty (default)
  • Positive values: Encourage new topics
  • Range: -2.0 to 2.0

Implementation

OpenAIBuilder presencePenalty(double penalty) {
  _baseBuilder.extension('presencePenalty', penalty);
  return this;
}