Skip to content

fix: validate model string format before splitting in LLM methods#224

Open
crazywriter1 wants to merge 1 commit intoOpenGradient:mainfrom
crazywriter1:fix/validate-model-format
Open

fix: validate model string format before splitting in LLM methods#224
crazywriter1 wants to merge 1 commit intoOpenGradient:mainfrom
crazywriter1:fix/validate-model-format

Conversation

@crazywriter1
Copy link
Copy Markdown

Summary

  • LLM.completion() and LLM.chat() call model.split("/")[1] to extract the model ID, which raises an unhandled IndexError if the string has no / separator
  • Added an explicit format check that raises ValueError with a helpful message (e.g. expected 'provider/model') before the split
  • Updated docstrings to document the new ValueError
  • Added tests covering: no-slash input, trailing-slash input, both completion() and chat()

Test plan

  • test_completion_rejects_model_without_slash
  • test_completion_rejects_model_with_trailing_slash
  • test_chat_rejects_model_without_slash
  • All 11 tests in client_test.py pass

…) and LLM.chat()

model.split('/')[1] raises IndexError when the model string has no slash.
Add an explicit check and raise ValueError with a helpful message instead.

Signed-off-by: crazywriter1 <crazywriter1@users.noreply.github.com>
@crazywriter1
Copy link
Copy Markdown
Author

@adambalogh

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.

1 participant