Skip to content

Conversation

caarlos0
Copy link
Member

@caarlos0 caarlos0 commented Jul 9, 2025

Since even if left out of the config/flags it will be 0, and zero is valid, we can disable these options by setting them to a negative number.

closes #480

Since even if left out of the config/flags it will be 0, and zero is
valid, we can disable these options by setting them to a negative
number.
@caarlos0 caarlos0 self-assigned this Jul 9, 2025
@caarlos0 caarlos0 requested a review from Copilot July 9, 2025 13:11
@caarlos0 caarlos0 added the bug Something isn't working label Jul 9, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the completion command to disable temperature, top_p, and top_k parameters when set to negative values by introducing a helper function that returns nil for negatives.

  • Replace direct pointers to cfg.Temperature/TopP/TopK with ptrOrNil calls
  • Add a generic ptrOrNil helper that returns nil when the value is negative
Comments suppressed due to low confidence (1)

mods.go:758

  • Add unit tests for ptrOrNil to verify that it returns nil for negative values and a valid pointer for zero and positive values, ensuring the disable logic behaves as expected.
func ptrOrNil[T number](t T) *T {

@caarlos0 caarlos0 merged commit bb7f141 into main Jul 10, 2025
16 checks passed
@caarlos0 caarlos0 deleted the 480 branch July 10, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow turning off temperature and topp completely
1 participant