Skip to content

fix(init): wizard probes openai Python client (closes #407)#408

Merged
memtomem merged 2 commits intomainfrom
fix/wizard-openai-probe
Apr 23, 2026
Merged

fix(init): wizard probes openai Python client (closes #407)#408
memtomem merged 2 commits intomainfrom
fix/wizard-openai-probe

Conversation

@memtomem
Copy link
Copy Markdown
Owner

Closes #407 (follow-up to #405 / #403 / #402).

Problem

Three of the four provider/tokenizer axes in the wizard already probe the Python client before prompting:

The OpenAI path didn't — it only validated the API key (_test_openai_key, network). Meanwhile mm init -y --provider openai refuses upfront if the openai Python client is missing (_collect_missing_extras). So:

  • Wizard + no openai package + valid key → silent pass, config saved, runtime falls back or errors later.
  • -y --provider openai + no openai package → refuses upfront.

A user who copied a successful wizard choice into a scripted -y install hit the same discoverability gap #405 closed for the other three axes.

Change

Mirror the Ollama pattern in the OpenAI branch, before the API-key prompt:

if not _have_module("openai"):
    click.secho("  openai Python client not installed.", fg="yellow")
    click.echo(f"  Install with: {_extra_install_hint(['openai'], state)}")
    click.echo(_y_refuse_hint("--provider openai", "openai"))
    click.echo("  Saving OpenAI config now so you're ready after install.")
    state.setdefault("_extras_warned_inline", set()).add("openai")

Key validation + save still run after the warning — the user still gets a clean key-check and the warn-and-save semantic is preserved. _extras_warned_inline marker prevents the post-wizard summary from duplicating.

Pin test extended with a fourth axis (_count_calls(embedding_src, "--provider openai", "openai") >= 1).

Test plan

  • uv run pytest packages/memtomem/tests/test_init_cmd.py -k "YRefuseHint": 2 passed.
  • Full test_init_cmd.py: 202 passed.
  • ruff check + ruff format --check: clean.

Scope

Four-axis coverage now complete. No behavior change for users who have the openai package installed. No change to -y semantics.

pandas-studio and others added 2 commits April 23, 2026 13:09
The wizard's OpenAI branch validated the API key over the network but
skipped the ``_have_module("openai")`` probe that the other three
provider/tokenizer axes use. Meanwhile ``mm init -y --provider openai``
refuses upfront when the ``openai`` Python client is missing (#402). A
user who ran the wizard, watched a successful API-key test, and then
copied the same choice into a scripted ``-y`` install hit the same
discoverability gap #405 closed for Ollama/ONNX/kiwipiepy.

Mirror the Ollama pattern: before prompting for the API key, warn if
the client is missing, surface the install hint + ``-y`` refuse note,
and mark ``openai`` inline-warned so the post-wizard summary doesn't
duplicate. The key-validation + save flow runs regardless — the user
still gets a clean check that their key works.

Pin test extended with a fourth axis (count >= 1 for openai).

Co-Authored-By: Claude <[email protected]>
#408)

All three preceding branches print "Install with → Saving config now →
-y refuse note" in that order. OpenAI had save-msg after the refuse
hint, which is cosmetic but breaks reader expectation.

Co-Authored-By: Claude <[email protected]>
@memtomem memtomem merged commit 833e28a into main Apr 23, 2026
7 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 23, 2026
@memtomem memtomem deleted the fix/wizard-openai-probe branch April 27, 2026 14:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

init: OpenAI wizard path skips openai-package probe (asymmetric with -y refuse, #405 follow-up)

2 participants