Skip to content

Commit

Permalink
feat: fallback to gpt-3.5-turbo if api 404s
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby Padilla authored and toby committed May 12, 2023
1 parent 33fe990 commit 25f7418
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mods.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ func (m *Mods) startCompletionCmd(content string) tea.Cmd {
ae := &openai.APIError{}
if errors.As(err, &ae) {
switch ae.HTTPStatusCode {
case http.StatusNotFound:
if m.Config.Model != "gpt-3.5-turbo" {
m.Config.Model = "gpt-3.5-turbo"
return m.retry(content, modsError{err: err, reason: "OpenAI API server error."})
}
case http.StatusBadRequest:
if ae.Code == "context_length_exceeded" {
pe := modsError{err: err, reason: "Maximum prompt size exceeded."}
Expand Down

0 comments on commit 25f7418

Please sign in to comment.