Skip to main content

· One min read

We are excited to announce the release of LLM Chain version 0.8.2! This update introduces some important improvements to our library, making it even more powerful and easy to use.

What's new in 0.8.2

New extract_labeled_text function

We've added a new function called extract_labeled_text in the parsing module. This function is designed to help you parse labeled text that is often generated by LLMs (Language Learning Machines). LLMs typically generate text like this:

- *foo*: bar
- hello: world

Improved find_yaml function

In this update, we have also improved the find_yaml function. It now returns the results in the order they appear in the document, making it more consistent and easier to work with.

Get started with 0.8.2

To start using LLM Chain version 0.8.2, update your dependency in your Cargo.toml file:

llm_chain = "0.8.2"

We hope you enjoy these new features and improvements! As always, if you have any questions or feedback, please feel free to reach out to our team.

· 3 min read

We are excited to announce the release of version 0.8.1, which brings two major improvements to our Large Language Model (LLM) library: an enhanced prompt! macro and a new Conversational chain type. These updates make it even easier for developers to create rich and interactive applications powered by LLMs.

Enhanced Prompt Macro with Prefixes

The prompt! macro has been updated to support prefixes, making it more expressive and convenient to use. With this new feature, you can now create chat prompts by simply prefixing them with user:, assistant:, or system:. Here's an example of how to use the new syntax:


let user_prompt = prompt!(user: "Hello, Mr Bot, help me figure out what to do next");
let system_prompt = prompt!(system: "You are a clever assistant that");

By using these prefixes, you can create more complex and interactive prompts for various use cases, such as building chatbots, automating tasks, or generating text.

New Conversational Chain Type

We're also introducing the Conversational chain type, which enables you to have ongoing conversations with LLMs. Conversational chains manage the conversation history and context, ensuring that the LLM's responses remain relevant and coherent throughout the interaction. This new chain type is particularly useful for chatbot applications, multi-step interactions, and any scenario where context is essential.

Here's a quick example of a Conversational chain:

use llm_chain::{
chains::conversation::Chain, executor, output::Output, parameters, prompt, step::Step,
};
use tokio;

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new ChatGPT executor.
let exec = executor!()?;

// Create a new Chain with the executor.
let mut chain = Chain::new(
prompt!(system: "You are a robot assistant for making personalized greetings."),
)?;

// Define the conversation steps.
let step1 = Step::for_prompt_template(prompt!(user: "Make a personalized greeting for Joe."));
let step2 =
Step::for_prompt_template(prompt!(user: "Now, create a personalized greeting for Jane."));
let step3 = Step::for_prompt_template(
prompt!(user: "Finally, create a personalized greeting for Alice."),
);

let step4 = Step::for_prompt_template(prompt!(user: "Remind me who did we just greet."));

// Execute the conversation steps.
let res1 = chain.send_message(step1, &parameters!(), &exec).await?;
println!("Step 1: {}", res1.primary_textual_output().await.unwrap());

let res2 = chain.send_message(step2, &parameters!(), &exec).await?;
println!("Step 2: {}", res2.primary_textual_output().await.unwrap());

let res3 = chain.send_message(step3, &parameters!(), &exec).await?;
println!("Step 3: {}", res3.primary_textual_output().await.unwrap());

let res4 = chain.send_message(step4, &parameters!(), &exec).await?;
println!("Step 4: {}", res4.primary_textual_output().await.unwrap());

Ok(())
}

With the Conversational chain, you can now easily send multiple messages and manage the conversation context without having to worry about manual context management.

Upgrade Today

We encourage you to upgrade to version 0.8.1 and take advantage of these new features. The enhanced prompt! macro and the new Conversational chain type will make your LLM-powered applications even more interactive and engaging.

As always, we appreciate your feedback and suggestions. Feel free to reach out to our team for any questions or concerns. Happy coding!

· 2 min read
will rudenmalm

We're excited to announce the release of llm-chain v0.8.0, a significant update to our LLM library. This release introduces a host of improvements and new features, including a completely revamped Prompt system and more streamlined handling of Parameters. Let's dive into the details!

Revamped Prompt System

Our new Prompt system has been redesigned from the ground up to provide greater flexibility and efficiency in working with language models. In llm-chain v0.8.0, we've introduced new structs and enums to better represent chat messages and their roles, such as ChatMessage, ChatMessageCollection, and ChatRole. The Data enum has also been introduced to represent either a collection of chat messages or a single text, making it easier to work with different types of data.

Furthermore, we've created a more powerful PromptTemplate system that allows you to format prompts with a set of parameters. This enables you to dynamically generate prompts for your language models without the need for cumbersome string manipulation.

Executors No Longer Handle Parameters

With the release of llm-chain v0.8.0, we've shifted the responsibility of handling Parameters from the executors to the main llm-chain crate. This change simplifies the process of working with executors, allowing developers to focus more on the core functionality of their language models.

What's Next?

This release marks a significant step forward in the evolution. However, we're not stopping here! We'll continue to refine and expand the capabilities of llm-chain, making it even more powerful and user-friendly.

We encourage you to check out llm-chain v0.8.0 and experience the benefits of the improved Prompt system and streamlined handling of Parameters. As always, we appreciate your feedback and contributions to help make llm-chain the best language model library out there.

Upgrade to llm-chain v0.8.0 today and take your language models to the next level!

· 2 min read
will rudenmalm

We are thrilled to announce the release of llm-chain v0.6.0, which introduces significant enhancements to our library. This update focuses on making the llm-chain more robust and versatile, allowing developers to build even more advanced applications with ease.

Major updates

1. The switch to the tera template language

One of the most significant changes in this release is the introduction of the tera template language. This powerful and flexible templating system enables developers to create dynamic and complex templates for their projects. The tera language allows for more advanced control structures and filters, making it a substantial upgrade from the previous templating system.

2. Improved prompt system

Another notable update is the revamped prompt system. With llm-chain v0.6.0, the prompt system now supports both Chat and completion-style models. This improvement means developers no longer need to worry about whether they are using a completion or chat model when crafting prompts. This unified approach simplifies the development process and makes it easier to work with various types of language models.

3. Updated LLaMA.cpp

The latest version of LLaMA.cpp has been integrated into this release, ensuring better performance and stability for your projects.

Other improvements

1. Safer error handling

In addition to the major updates, llm-chain v0.6.0 also brings improvements to error handling. Templates now return Result rather than panicking on errors, making it more convenient to handle any issues that may arise during development. Similarly, Executors also return Result instead of panicking on errors, providing a more consistent and safer API.

Time to move on from the old templating system

With the introduction of the tera template language, we strongly recommend moving away from the old templating system. This update provides a solid foundation for building even more advanced applications using the llm-chain library.

We hope you're as excited about these enhancements as we are! As always, we appreciate your feedback and support. If you have any questions or need help, please don't hesitate to reach out on Discord !

Happy coding! 🚀

· 2 min read
will rudenmalm

In this blog post, we'll explore how to use ChatGPT in Rust with the help of the llm-chain library. We will walk through a simple example that demonstrates how to generate responses using OpenAI's ChatGPT model.

Getting Started

First, let's start by installing the necessary packages using cargo add. You will need the llm-chain and llm-chain-openai libraries:

cargo add llm-chain llm-chain-openai

Now, let's dive into the code:


use llm_chain::{traits::StepExt, Parameters};
use llm_chain_openai::chatgpt::{Executor, Model, Role, Step};

#[tokio::main(flavor = "current_thread")]
async fn main() {
let exec = Executor::new_default();
let chain = Step::new(
Model::ChatGPT3_5Turbo,
[
(
Role::System,
"You are a helpful assistant",
),
(Role::User, "Tell me about the Rust programming language"),
],
)
.to_chain();
let res = chain.run(Parameters::new(), &exec).await.unwrap();
println!("{:?}", res);
}

In the code snippet above, we begin by importing the necessary modules and functions from the llm-chain and llm-chain-openai libraries. We then define a simple main function that uses the Executor and Step structs to create a conversational chain.

The Model::ChatGPT3_5Turbo model is used as the language model in this example. We also define two steps in the conversation: the first one sets the role of the assistant and the second one asks a question about the Rust programming language.

Finally, we execute the conversation chain using the run method and print the generated response.

Wrapping Up

As you can see, using ChatGPT in Rust with llm-chain is a straightforward and efficient process. The library makes it easy to build and manage conversational agents in Rust, allowing developers to focus on creating more powerful and interactive applications.

To continue learning about ChatGPT in Rust and how to make the most of the llm-chain library, try our tutorial .

· 2 min read
will rudenmalm

We're excited to announce the release of LLM-chain, a Rust library designed to help developers work with Large Language Models (LLMs) more effectively. Our primary focus is on providing 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. This includes, but is not limited to, summarizing lengthy texts or performing advanced data processing tasks.

Features of LLM-chain

LLM-chain comes with a variety of features that make it easier to work with LLMs, including:

  • 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: Currently supports ChatGPT models, with plans to add support for more LLMs in the future, such as LLaMa and Stanford's Alpaca models.
  • 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 and new models are developed.
  • Community-driven: We welcome and encourage contributions from the community to help improve and expand the capabilities of LLM-chain.

Connect with Us

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

Getting Started with LLM-chain

Check out our Github repository or the documentation to get started.