You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -236,6 +236,35 @@ Task {
236
236
237
237
To learn more about structured outputs, check out the [OpenAI documentation](https://platform.openai.com/docs/guides/structured-outputs/introduction).
238
238
239
+
### Error Handling
240
+
241
+
`LLMChatOpenAI` provides structured error handling through the `LLMChatOpenAIError` enum. This enum contains three cases that represent different types of errors you might encounter:
242
+
243
+
```swift
244
+
let messages = [
245
+
ChatMessage(role: .system, content: "You are a helpful assistant."),
246
+
ChatMessage(role: .user, content: "What is the capital of Indonesia?")
247
+
]
248
+
249
+
do {
250
+
let completion =tryawait chat.send(model: "gpt-4o", messages: messages)
Copy file name to clipboardExpand all lines: Sources/LLMChatOpenAI/Documentation.docc/Documentation.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -207,6 +207,35 @@ Task {
207
207
208
208
To learn more about structured outputs, check out the [OpenAI documentation](https://platform.openai.com/docs/guides/structured-outputs/introduction).
209
209
210
+
### Error Handling
211
+
212
+
``LLMChatOpenAI`` provides structured error handling through the ``LLMChatOpenAIError`` enum. This enum contains three cases that represent different types of errors you might encounter:
213
+
214
+
```swift
215
+
let messages = [
216
+
ChatMessage(role: .system, content: "You are a helpful assistant."),
217
+
ChatMessage(role: .user, content: "What is the capital of Indonesia?")
218
+
]
219
+
220
+
do {
221
+
let completion =tryawait chat.send(model: "gpt-4o", messages: messages)
0 commit comments