Current section

Files

Jump to
langchain mix.exs
Raw

mix.exs

defmodule LangChain.MixProject do
use Mix.Project
@source_url "https://github.com/brainlid/langchain"
@version "0.8.13"
def project do
[
app: :langchain,
version: @version,
elixir: "~> 1.17",
elixirc_paths: elixirc_paths(Mix.env()),
test_options: [docs: true],
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps(),
dialyzer: [
ignore_warnings: ".dialyzer_ignore.exs",
plt_file: {:no_warn, "priv/plts/project.plt"},
plt_core_path: "priv/plts"
],
package: package(),
docs: &docs/0,
name: "LangChain",
homepage_url: @source_url,
description: """
Elixir implementation of a LangChain style framework that lets Elixir projects integrate with and leverage LLMs.
"""
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end
def cli do
[
preferred_envs: [precommit: :test]
]
end
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:ecto, "~> 3.10 or ~> 3.11"},
{:gettext, "~> 0.26.2 or ~> 1.0.0"},
{:req, ">= 0.5.3"},
{:mint_web_socket, "~> 1.0", optional: true},
{:nimble_parsec, "~> 1.4", optional: true},
{:abacus, "~> 2.1.0", optional: true},
{:nx, ">= 0.7.0", optional: true},
{:ex_doc, "~> 0.40", only: :dev, runtime: false},
{:mimic, "~> 1.8", only: :test},
{:dotenvy, "~> 1.1"},
{:req_llm, ">= 1.6.0", optional: true},
{:sobelow, "~> 0.14", only: [:dev, :test], runtime: false, warn_if_outdated: true},
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
{:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false}
]
end
# Aliases are shortcuts or tasks specific to the current project.
# For example, before performing a commit, run the following checks:
#
# $ mix precommit
#
# See the documentation for `Mix` for more info on aliases.
defp aliases do
[
precommit: [
"compile --warning-as-errors",
"deps.unlock --unused",
"format",
"sobelow",
"deps.audit",
"test"
]
]
end
defp docs do
[
main: "readme",
source_ref: "v#{@version}",
source_url: @source_url,
assets: %{"notebooks/files" => "files"},
skip_undefined_reference_warnings_on: ["CHANGELOG.md"],
logo: "images/elixir-langchain-link-logo_32px.png",
extra_section: "Guides",
extras: extras(),
groups_for_extras: [
Guides: ["guides/evaluation.md"],
Notebooks: Path.wildcard("notebooks/*.livemd")
],
groups_for_modules: [
"Chat Models": [
LangChain.ChatModels.ChatModel,
LangChain.ChatModels.ChatOpenAI,
LangChain.ChatModels.ChatOpenAIResponses,
LangChain.ChatModels.ChatAnthropic,
LangChain.ChatModels.ChatAwsMantle,
LangChain.ChatModels.ChatBumblebee,
LangChain.ChatModels.ChatGoogleAI,
LangChain.ChatModels.ChatVertexAI,
LangChain.ChatModels.ChatMistralAI,
LangChain.ChatModels.ChatOllamaAI,
LangChain.ChatModels.ChatPerplexity,
LangChain.ChatModels.ChatGrok,
LangChain.ChatModels.ChatDeepSeek,
LangChain.ChatModels.ChatReqLLM
],
Chains: [
LangChain.Chains.LLMChain,
LangChain.Chains.TextToTitleChain,
LangChain.Chains.SummarizeConversationChain,
LangChain.Chains.DataExtractionChain
],
"Run Modes": [
LangChain.Chains.LLMChain.Mode,
LangChain.Chains.LLMChain.Mode.Steps,
LangChain.Chains.LLMChain.Modes.WhileNeedsResponse,
LangChain.Chains.LLMChain.Modes.UntilSuccess,
LangChain.Chains.LLMChain.Modes.Step,
LangChain.Chains.LLMChain.Modes.UntilToolUsed
],
Messages: [
LangChain.Message,
LangChain.MessageDelta,
LangChain.Message.ContentPart,
LangChain.Message.ToolCall,
LangChain.Message.ToolResult,
LangChain.PromptTemplate,
LangChain.MessageProcessors,
LangChain.MessageProcessors.JsonProcessor,
LangChain.TokenUsage
],
Functions: [
LangChain.Function,
LangChain.FunctionParam
],
Callbacks: [
LangChain.Callbacks,
LangChain.Chains.ChainCallbacks
],
Routing: [
LangChain.Chains.RoutingChain,
LangChain.Routing.PromptRoute
],
"File Uploaders": [
LangChain.FileUploader,
LangChain.FileUploader.FileOpenAI,
LangChain.FileUploader.FileAnthropic,
LangChain.FileUploader.FileGoogle,
LangChain.FileUploader.FileResult
],
Images: [
LangChain.Images,
LangChain.Images.OpenAIImage,
LangChain.Images.GeneratedImage
],
"Text Splitter": [
LangChain.TextSplitter.CharacterTextSplitter,
LangChain.TextSplitter.RecursiveCharacterTextSplitter,
LangChain.TextSplitter.LanguageSeparators
],
Tools: [
LangChain.Tools.Calculator,
LangChain.Tools.DeepResearch,
LangChain.Tools.DeepResearchClient,
LangChain.Tools.DeepResearch.ResearchRequest,
LangChain.Tools.DeepResearch.ResearchStatus,
LangChain.Tools.DeepResearch.ResearchResult
],
WebSocket: [
LangChain.WebSocket
],
Evaluation: [
LangChain.Trajectory,
LangChain.Trajectory.Assertions
],
Utils: [
LangChain.Utils,
LangChain.Utils.BedrockConfig,
LangChain.Utils.ChatTemplates,
LangChain.Utils.ChainResult,
LangChain.Config,
LangChain.Gettext
]
],
before_closing_head_tag: &before_closing_head_tag/1,
before_closing_body_tag: &before_closing_body_tag/1
]
end
defp extras do
[
"README.md",
"CHANGELOG.md",
"guides/evaluation.md",
"notebooks/getting_started.livemd",
"notebooks/custom_functions.livemd",
"notebooks/context-specific-image-descriptions.livemd"
]
end
defp package do
# Note: the Livebook notebooks and related files are not included in the
# package.
[
files: ["lib", "mix.exs", "README*", "LICENSE*"],
maintainers: ["Mark Ericksen"],
licenses: ["Apache-2.0"],
links: %{"GitHub" => @source_url}
]
end
defp before_closing_head_tag(:html) do
"""
<!-- HTML injected at the end of the <head> element -->
"""
end
defp before_closing_head_tag(:epub), do: ""
defp before_closing_body_tag(:html) do
"""
<script defer src="https://cdn.jsdelivr.net/npm/mermaid@10.2.3/dist/mermaid.min.js"></script>
<script>
let initialized = false;
window.addEventListener("exdoc:loaded", () => {
if (!initialized) {
mermaid.initialize({
startOnLoad: false,
theme: document.body.className.includes("dark") ? "dark" : "default"
});
initialized = true;
}
let id = 0;
for (const codeEl of document.querySelectorAll("pre code.mermaid")) {
const preEl = codeEl.parentElement;
const graphDefinition = codeEl.textContent;
const graphEl = document.createElement("div");
const graphId = "mermaid-graph-" + id++;
mermaid.render(graphId, graphDefinition).then(({svg, bindFunctions}) => {
graphEl.innerHTML = svg;
bindFunctions?.(graphEl);
preEl.insertAdjacentElement("afterend", graphEl);
preEl.remove();
});
}
});
</script>
"""
end
defp before_closing_body_tag(:epub), do: ""
end