instructor_ex
instructor_ex copied to clipboard
ArgumentError with Ecto 3.12
I upgraded to Ecto 3.12, and now Instructor.completion
fails immediately with an ArgumentError:
** (ArgumentError) errors were found at the given arguments:
* 1st argument: not an atom
(erts 15.0) :erlang.function_exported({:parameterized, {Ecto.Embedded, %Ecto.Embedded{cardinality: :many, field: :transportation, owner: Ido.Emails.OpenAI.TravelPlan, related: Ido.Emails.OpenAI.TransportationItem, on_cast: nil, on_replace: :raise, unique: true, ordered: true}}}, :to_json_schema, 0)
(instructor 0.0.5) lib/instructor/json_schema.ex:292: Instructor.JSONSchema.for_type/1
(instructor 0.0.5) lib/instructor/json_schema.ex:79: anonymous fn/2 in Instructor.JSONSchema.bfs_from_ecto_schema/2
(elixir 1.17.1) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
(instructor 0.0.5) lib/instructor/json_schema.ex:77: Instructor.JSONSchema.bfs_from_ecto_schema/2
(instructor 0.0.5) lib/instructor/json_schema.ex:13: Instructor.JSONSchema.from_ecto_schema/1
(instructor 0.0.5) lib/instructor.ex:536: Instructor.params_for_mode/3
(instructor 0.0.5) lib/instructor.ex:421: Instructor.do_chat_completion/3
I think this was caused by Ecto's change of the parameterized type:
[Ecto.ParameterizedType] Parameterized types are now represented internally as {:parameterized, {mod, state}}. While this representation is private, projects may have been relying on it, and therefore they need to adapt accordingly. Use Ecto.ParameterizedType.init/2 to instantiate parameterized types.