#llm #langchain #chatgpt #chain


A library for running chains of LLMs (such as ChatGPT) in series to complete complex tasks, such as text summation

29 releases (9 breaking)

0.12.3 Jun 27, 2023
0.12.0 May 31, 2023
0.1.1-rc.1 Mar 25, 2023

#14 in Science

Download history 177/week @ 2023-06-12 193/week @ 2023-06-19 317/week @ 2023-06-26 643/week @ 2023-07-03 686/week @ 2023-07-10 684/week @ 2023-07-17 680/week @ 2023-07-24 356/week @ 2023-07-31 287/week @ 2023-08-07 347/week @ 2023-08-14 270/week @ 2023-08-21 171/week @ 2023-08-28 364/week @ 2023-09-04 387/week @ 2023-09-11 477/week @ 2023-09-18 334/week @ 2023-09-25

1,567 downloads per month
Used in 7 crates

MIT license

3.5K SLoC

llm-chain πŸš€

llm-chain is a collection of Rust crates designed to help you create advanced LLM applications such as chatbots, agents, and more. As a comprehensive LLM-Ops platform we have strong support for both cloud and locally-hosted LLMs. We also provide robust support for prompt templates and chaining together prompts in multi-step chains, enabling complex tasks that LLMs can't handle in a single step. We also provide vector store integrations making it easy to give your model long-term memory and subject matter knowledge. This empowers you to build sophisticated applications.

This crate is the main crate for llm-chain. You will need driver crate such as llm-chain-openai, or llm-chain-local

Discord Crates.io License Docs: Tutorial

Examples πŸ’‘

To help you get started, here is an example demonstrating how to use llm-chain. You can find more examples in the examples folder in the repository.

let exec = executor!()?;
let res = prompt!(
    "You are a robot assistant for making personalized greetings",
    "Make a personalized greeting for Joe"
.run(parameters()!, &exec)
println!("{}", res);

➑️ tutorial: get started with llm-chain ➑️ quick-start: Create project based on our template

Features 🌟

  • Prompt templates: Create reusable and easily customizable prompt templates for consistent and structured interactions with LLMs.
  • Chains: Build powerful chains of prompts that allow you to execute more complex tasks, step by step, leveraging the full potential of LLMs.
  • ChatGPT support: Supports ChatGPT models, with plans to add OpenAI's other models in the future.
  • LLaMa support: Provides seamless integration with LLaMa models, enabling natural language understanding and generation tasks with Facebook's research models.
  • Alpaca support: Incorporates support for Stanford's Alpaca models, expanding the range of available language models for advanced AI applications.
  • Tools: Enhance your AI agents' capabilities by giving them access to various tools, such as running Bash commands, executing Python scripts, or performing web searches, enabling more complex and powerful interactions.
  • Extensibility: Designed with extensibility in mind, making it easy to integrate additional LLMs as the ecosystem grows.
  • Community-driven: We welcome and encourage contributions from the community to help improve and expand the capabilities of llm-chain.

Getting Started πŸš€

To start using llm-chain, add it as a dependency in your Cargo.toml:

cargo add llm-chain llm-chain-openai

The examples for llm-chain-openai require you to set the OPENAI_API_KEY environment variable which you can do like this:


Then, refer to the documentation and examples to learn how to create prompt templates, chains, and more.

Contributing 🀝

We warmly welcome contributions from everyone! If you're interested in helping improve llm-chain, please check out our CONTRIBUTING.md file for guidelines and best practices.

License πŸ“„

llm-chain is licensed under the MIT License.

Connect with Us 🌐

If you have any questions, suggestions, or feedback, feel free to open an issue or join our community discord. We're always excited to hear from our users and learn about your experiences with llm-chain.

We hope you enjoy using llm-chain to unlock the full potential of Large Language Models in your projects. Happy coding! πŸŽ‰


~511K SLoC