-
-
Notifications
You must be signed in to change notification settings - Fork 931
Description
- This is actually a bug report in Go SDK.
What Model are you using?
- gpt-4.1-nano-2025-04-14
Describe the bug
pkg/instructor/providers/openai/chat.go line 157 throws a panic
runtime panic: runtime error: index out of range [0] with length 0
To Reproduce
Just normal call, this issue happens from time to time, not able to reproduce manually, it looks like none was return by llm engine
messages := []openai.ChatCompletionMessage{
{
Role: openai.ChatMessageRoleSystem,
Content: systemPrompt,
},
}
if userPrompt != "" {
messages = append(messages, openai.ChatCompletionMessage{
Role: openai.ChatMessageRoleUser,
Content: userPrompt,
})
}
resp, err = client.CreateChatCompletion(
ctx,
openai.ChatCompletionRequest{
Model: model,
Messages: messages,
},
&out,
)
Expected behavior
Panic should be handled gracefully
Screenshots