Skip to content

Make top-p configurable via .sgptrc (closes #425) - #789

Open
gandzekas wants to merge 1 commit into
TheR1D:mainfrom
gandzekas:feat/default-top-p-config
Open

Make top-p configurable via .sgptrc (closes #425)#789
gandzekas wants to merge 1 commit into
TheR1D:mainfrom
gandzekas:feat/default-top-p-config

Conversation

@gandzekas

Copy link
Copy Markdown

PR: Make top-p (top-probability) configurable via .sgptrccloses #425

Summary

Issue #425 asks to set a default temperature and top-probability via the
runtime config file (~/.config/shell_gpt/.sgptrc).

  • Temperature config support already landed in Added default temperature to config #723 (DEFAULT_TEMPERATURE).
  • This PR completes the issue by making top-p config-driven too, via a new
    DEFAULT_TOP_P key. Previously top_p was hardcoded to 1.0 in app.py, so
    the config file had no effect on it.

Changes

  1. sgpt/config.py — add DEFAULT_TOP_P to DEFAULT_CONFIG (default 1.0,
    overridable via DEFAULT_TOP_P env var, consistent with DEFAULT_TEMPERATURE).
  2. sgpt/app.pytop_p typer.Option default now reads cfg.get("DEFAULT_TOP_P")
    instead of the literal 1.0.
  3. README.md — document both DEFAULT_TEMPERATURE and DEFAULT_TOP_P in the
    runtime config example block (temperature was previously undocumented).

Behavior

  • Default behavior is unchanged: DEFAULT_TOP_P defaults to 1.0, identical to
    the previous hardcoded value.
  • Users can now set DEFAULT_TOP_P=0.9 (or any 0.0–1.0 value) in .sgptrc to
    apply a default nucleus-sampling probability without passing --top-p every run.
  • Explicit --top-p on the command line still overrides the config, as before.

Verification

  • python3 -m py_compile sgpt/config.py sgpt/app.py passes.
  • Existing test suite passes (run in isolated venv:
    OPENAI_API_KEY=dummy sgpt-venv/bin/python -m pytest tests/ -q).

Test plan for maintainers

  • sgpt "hello" with no --top-p uses DEFAULT_TOP_P from config (default 1.0).
  • Setting DEFAULT_TOP_P=0.5 in .sgptrc changes the default without flags.
  • --top-p 0.3 still overrides the config value.

Make top-p (top-probability / nucleus sampling) configurable via the
runtime config file, completing issue TheR1D#425.

- Add DEFAULT_TOP_P to DEFAULT_CONFIG (default 1.0, env-overridable)
- Wire top_p typer.Option default to cfg.get("DEFAULT_TOP_P")
- Document DEFAULT_TEMPERATURE and DEFAULT_TOP_P in README config example

Default behavior is unchanged (1.0). Closes TheR1D#425.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set temperature and top-probability via config?

1 participant