Packages
langchain
0.4.0-rc.2
0.9.2
0.9.1
0.9.0
0.8.14
0.8.13
0.8.12
0.8.11
0.8.10
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.0
0.6.3
0.6.2
0.6.1
0.6.0
0.5.2
0.5.1
0.5.0
0.4.1
0.4.0
0.4.0-rc.3
0.4.0-rc.2
0.4.0-rc.1
0.4.0-rc.0
0.3.3
0.3.2
0.3.1
0.3.0
0.3.0-rc.2
0.3.0-rc.1
0.3.0-rc.0
0.2.0
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
Elixir implementation of a LangChain style framework that lets Elixir projects integrate with and leverage LLMs.
Current section
Files
Jump to
Current section
Files
lib/config.ex
defmodule LangChain.Config do
@moduledoc """
Utility that handles interaction with the application's configuration.
"""
@doc """
Resolves the given key from the application's configuration returning the
wrapped expanded value. If the value is a function it gets evaluated, if the
value is a tuple of three elements it gets applied.
"""
@spec resolve(atom, any) :: any
def resolve(key, default \\ nil)
def resolve(key, default) when is_atom(key) do
Application.get_env(:langchain, key, default)
|> expand_value()
end
def resolve(key, _) do
raise(
ArgumentError,
message: "#{__MODULE__} expected key '#{key}' to be an atom"
)
end
defp expand_value({module, function, args})
when is_atom(function) and is_list(args) do
apply(module, function, args)
end
defp expand_value(value) when is_function(value) do
value.()
end
defp expand_value(value), do: value
end