Skip to content

Commit fcd2746

Browse files
authored
docs: fix error handling example (#63)
1 parent ca5c3ca commit fcd2746

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,15 @@ $ export AI21_LOG_LEVEL=debug
222222
```python
223223
from ai21 import errors as ai21_errors
224224
from ai21 import AI21Client, AI21APIError
225+
from ai21.models import ChatMessage
225226

226227
client = AI21Client()
227228

228229
system = "You're a support engineer in a SaaS company"
229230
messages = [
230-
{
231-
"text": "Hello, I need help with a signup process.",
232-
"role": "user",
233-
"name": "Alice",
234-
},
235-
]
231+
# Notice the given role does not exist and will be the reason for the raised error
232+
ChatMessage(text="Hello, I need help with a signup process.", role="Non-Existent-Role"),
233+
]
236234

237235
try:
238236
chat_completion = client.chat.create(

0 commit comments

Comments
 (0)