Skip to content

Commit

Permalink
fix: error is always a tuple of two
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistingTwists committed Jun 27, 2024
1 parent bf40821 commit 20dacde
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/instructor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ defmodule Instructor do
{:ok, Ecto.Schema.t()}
| {:error, Ecto.Changeset.t()}
| {:error, String.t()}
| {:error, any()}
| Stream.t()
def chat_completion(params, config \\ nil) do
params =
Expand Down Expand Up @@ -436,7 +437,7 @@ defmodule Instructor do
{:ok, changeset |> Ecto.Changeset.apply_changes()}
else
{:llm, {:error, error}} ->
{:error, :adapter_error, error}
{:error, { :adapter_error,error}}

{:valid_json, {:error, error}} ->
# pass the error as it is to the user consuming API
Expand All @@ -445,7 +446,7 @@ defmodule Instructor do
# So, a smaller model like claude-haiku for subsequent LLM call
# https://github.com/thmsmlr/instructor_ex/pull/55/files
Logger.error(error: "Invalid JSON returned from LLM: #{inspect(error)}")
{:error, :invalid_json, error}
{:error, { :invalid_json, error}}

{:validation, changeset, response} ->
if max_retries > 0 do
Expand Down

0 comments on commit 20dacde

Please sign in to comment.