Skip to main content

2 posts tagged with "introduction"

View All Tags

· 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.