thmsmlr / instructor_ex

Structured outputs for LLMs in Elixir
https://hexdocs.pm/instructor
430 stars 48 forks source link

Get runtime adapter from params, not from config #27

Open maxdrift opened 4 months ago

maxdrift commented 4 months ago

@thmsmlr Thank you for this very cool library! I started experimenting with it a few days ago and noticed that the feature added in #23 didn't work when I tried to use it.

The docs HERE mention that the adapter can be specified at runtime in chat_completion/2 via params but the current implementation uses config instead. I think the docs are correct and so I fixed the implementation (and added a test).

Please let me know if this fix makes sense to you. Thanks.

thmsmlr commented 3 months ago

@cigrainger do you have opinions on this? We originally were thinking of having the adapter configurable through the second argument.

Docs wrong? or code wrong?

cigrainger commented 3 months ago

Oh totally. Docs wrong I think. Sorry about that. 🫠

maxdrift commented 3 months ago

@cigrainger @thmsmlr thanks for the clarification. Either way, if you test it, it doesn't work because both params and config are Keyword lists and you're matching on a Map HERE so it always falls back to the Application config. I have a fix (and test) ready for both scenarios anyway. (see HERE)