Skip to content

Commit 2c394e6

Browse files
authored
Improve error handling for invalid model identifiers
Add a shared parser to validate model identifiers and raise a descriptive ValueError for invalid formats. Signed-off-by: AMATH <116212274+amathxbt@users.noreply.github.com>
1 parent 516f877 commit 2c394e6

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Summary
2+
3+
Fixes invalid model string handling in the LLM client.
4+
5+
`LLM.completion()` and `LLM.chat()` currently assume the model identifier always contains a `/` separator and directly access `model.split("/")[1]`. When a caller passes a plain string such as `"gpt-5"`, the SDK raises an unhelpful `IndexError` instead of a clear validation error.
6+
7+
This PR adds a shared parser that validates model identifiers and raises a descriptive `ValueError` when the input is not in `provider/model-name` format.
8+
9+
Fixes #249
10+
11+
## Problem
12+
13+
Both `LLM.completion()` and `LLM.chat()` strip the provider prefix with direct string splitting:
14+
15+
```python
16+
model.split("/")[1]

0 commit comments

Comments
 (0)