Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency in getting adapter from config via function params? #42

Open
noozo opened this issue Apr 5, 2024 · 2 comments
Open

Inconsistency in getting adapter from config via function params? #42

noozo opened this issue Apr 5, 2024 · 2 comments

Comments

@noozo
Copy link

noozo commented Apr 5, 2024

Hi all,

I noticed this function in completions.ex:

defp adapter(%{adapter: adapter}) when is_atom(adapter), do: adapter
defp adapter(_), do: Application.get_env(:instructor, :adapter, Instructor.Adapters.OpenAI)

Looking into how the adapters use the config internally, seems like they all expect config to be a keyword list, not a map. My take is that the first clause there is wrong and makes passing in the adapter via explicit config impossible atm.

Am i wrong?

@noozo
Copy link
Author

noozo commented Apr 5, 2024

Something like this would work?

defp adapter(config),
    do:
      if(config[:adapter],
        do: config[:adapter],
        else: Application.get_env(:instructor, :adapter, Instructor.Adapters.OpenAI)
      )

@noozo
Copy link
Author

noozo commented Apr 5, 2024

Created PR #43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant