百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

langchain-rust

> AI 编程
开源

️LangChain 为 Rust 提供了最简单的方法,可以在 Rust 中编写基于 LLM 的程序

1.3K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

️LangChain 为 Rust 提供了最简单的方法,可以在 Rust 中编写基于 LLM 的程序

️LangChain Rust

⚡ Building applications with LLMs through composability, with Rust! ⚡

What is this?

This is the Rust language implementation of LangChain.

Current Features

  • LLMs

    • OpenAi
    • Azure OpenAi
    • Ollama
    • Anthropic Claude
  • Embeddings

    • OpenAi
    • Azure OpenAi
    • Ollama
    • Local FastEmbed
    • MistralAI
  • VectorStores

    • OpenSearch
    • Postgres
    • Qdrant
    • Sqlite
    • SurrealDB
  • Chain

    • LLM Chain
    • Conversational Chain
    • Conversational Retriever Simple
    • Conversational Retriever With Vector Store
    • Sequential Chain
    • Q&A Chain
    • SQL Chain
  • Agents

    • Chat Agent with Tools
    • Open AI Compatible Tools Agent
  • Tools

    • Serpapi/Google
    • DuckDuckGo Search
    • Wolfram/Math
    • Command line
    • Text2Speech
  • Semantic Routing

    • Static Routing
    • Dynamic Routing
  • Document Loaders

    • PDF

      use futures_util::StreamExt;
      
      async fn main() {
          let path = "./src/document_loaders/test_data/sample.pdf";
      
          let loader = PdfExtractLoader::from_path(path).expect("Failed to create PdfExtractLoader");
          // let loader = LoPdfLoader::from_path(path).expect("Failed to create LoPdfLoader");
      
          let docs = loader
              .load()
              .await
              .unwrap()
              .map(|d| d.unwrap())
              .collect::>()
              .await;
      
      }
      
    • Pandoc

      use futures_util::StreamExt;
      
      async fn main() {
      
          let path = "./src/document_loaders/test_data/sample.docx";
      
          let loader = PandocLoader::from_path(InputFormat::Docx.to_string(), path)
              .await
              .expect("Failed to create PandocLoader");
      
          let docs = loader
              .load()
              .await
              .unwrap()
              .map(|d| d.unwrap())
              .collect::>()
              .await;
      }
      
    • HTML

      use futures_util::StreamExt;
      use url::Url;
      
      async fn main() {
          let path = "./src/document_loaders/test_data/example.html";
          let html_loader = HtmlLoader::from_path(path, Url::parse("https://example.com/").unwrap())
              .expect("Failed to create html loader");
      
          let documents = html_loader
              .load()
              .await
              .unwrap()
              .map(|x| x.unwrap())
              .collect::>()
              .await;
      }
      
    • HTML To Markdown

…
  • CSV

    use futures_util::StreamExt;
    
    async fn main() {
        let path = "./src/document_loaders/test_data/test.csv";
        let columns = vec![
            "name".to_string(),
            "age".to_string(),
            "city".to_string(),
            "country".to_string(),
        ];
        let csv_loader = CsvLoader::from_path(path, columns).expect("Failed to create csv loader");
    
        let documents = csv_loader
            .load()
            .await
            .unwrap()
            .map(|x| x.unwrap())
            .collect::>()
            .await;
    }
    
  • Git commits

    use futures_util::StreamExt;
    
    async fn main() {
        let path = "/path/to/git/repo";
        let git_commit_loader = GitCommitLoader::from_path(path).expect("Failed to create git commit loader");
    
        let documents = csv_loader
            .load()
            .await
            .unwrap()
            .map(|x| x.unwrap())
            .collect::>()
            .await;
    }
    
  • Source code

    
    let loader_with_dir =
    SourceCodeLoader::from_path("./src/document_loaders/test_data".to_string())
    .with_dir_loader_options(DirLoaderOptions {
    glob: None,
    suffixes: Some(vec!["rs".to_string()]),
    exclude: None,
    });
    
    let stream = loader_with_dir.load().await.unwrap();
    let documents = stream.map(|x| x.unwrap()).collect::>().await;
    

Installation

This library heavily relies on serde_json for its operation.

Step 1: Add serde_json

First, ensure serde_json is added to your Rust project.

cargo add serde_json

Step 2: Add langchain-rust

Then, you can add langchain-rust to your Rust project.

Simple install

cargo add langchain-rust

With Sqlite

sqlite-vss

Download additional sqlite_vss libraries from

cargo add langchain-rust --features sqlite-vss
sqlite-vec

Download additional sqlite_vec libraries from

cargo add langchain-rust --features sqlite-vec

With Postgres

cargo add langchain-rust --features postgres

With SurrialDB

cargo add langchain-rust --features surrealdb

With Qdrant

cargo add langchain-rust --features qdrant

Please remember to replace the feature flags sqlite, postgres or surrealdb based on your specific use case.

This will add both serde_json and langchain-rust as dependencies in your Cargo.toml file. Now, when you build your project, both dependencies will be fetched and compiled, and will be available for use in your project.

Remember, serde_json is a necessary dependencies, and sqlite, postgres and surrealdb are optional features that may be added according to project needs.

Quick Start Conversational Chain

…

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

核心特点

  • •[x] OpenAi
  • •[x] Azure OpenAi
  • •[x] Ollama
  • •[x] Anthropic Claude
  • •Embeddings
  • •[x] OpenAi
  • •[x] Azure OpenAi
  • •[x] Ollama
  • •[x] Local FastEmbed
  • •[x] MistralAI

> 标签

Rustlangchainllmllmsopenai

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类AI 编程
定价开源

> 相关工具

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.