Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cite blog post in docs #12

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
[Latest Version]: https://img.shields.io/crates/v/chat_splitter.svg
[crates.io]: https://crates.io/crates/chat_splitter

Never exceed [OpenAI](https://openai.com/)'s [chat models](https://platform.openai.com/docs/api-reference/chat)' [maximum number of tokens](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them) when using the [`async_openai`](https://github.com/64bit/async-openai) Rust crate.

`chat-splitter` splits chats into 'outdated' and 'recent' messages.
You can split by
both
maximum message count and
maximum chat completion token count.
We use [`tiktoken_rs`](https://github.com/zurawiki/tiktoken-rs) for counting tokens.
> For more information,
> please refer to the [blog announcement](https://schneiderfelipe.github.io/posts/chat-splitter-first-release/).

When utilizing the [`async_openai`](https://github.com/64bit/async-openai) [Rust](https://www.rust-lang.org/) crate,
it is crucial to ensure that you do not exceed
the [maximum number of tokens](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them) specified by [OpenAI](https://openai.com/)'s [chat models](https://platform.openai.com/docs/api-reference/chat).

[`chat-splitter`](https://crates.io/crates/chat_splitter) categorizes chat messages into 'outdated' and 'recent' messages,
allowing you to split them based on both the maximum
message count and the maximum chat completion token count.
The token counting functionality is provided by
[`tiktoken_rs`](https://github.com/zurawiki/tiktoken-rs).

## Usage

Expand Down
26 changes: 17 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
//! [Latest Version]: https://img.shields.io/crates/v/chat_splitter.svg
//! [crates.io]: https://crates.io/crates/chat_splitter
//!
//! Never exceed [OpenAI](https://openai.com/)'s [chat models](https://platform.openai.com/docs/api-reference/chat)' [maximum number of tokens](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them) when using the [`async_openai`](https://github.com/64bit/async-openai) Rust crate.
//! > For more information,
//! > please refer to the [blog announcement](https://schneiderfelipe.github.io/posts/chat-splitter-first-release/).
//!
//! `chat-splitter` splits chats into 'outdated' and 'recent' messages.
//! You can split by
//! both
//! maximum message count and
//! maximum chat completion token count.
//! We use [`tiktoken_rs`](https://github.com/zurawiki/tiktoken-rs) for counting tokens.
//! When utilizing the [`async_openai`](https://github.com/64bit/async-openai) [Rust](https://www.rust-lang.org/) crate,
//! it is crucial to ensure that you do not exceed
//! the [maximum number of tokens](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them) specified by [OpenAI](https://openai.com/)'s [chat models](https://platform.openai.com/docs/api-reference/chat).
//!
//! [`chat-splitter`](https://crates.io/crates/chat_splitter) categorizes chat messages into 'outdated' and 'recent' messages,
//! allowing you to split them based on both the maximum
//! message count and the maximum chat completion token count.
//! The token counting functionality is provided by
//! [`tiktoken_rs`](https://github.com/zurawiki/tiktoken-rs).
//!
//! # Usage
//!
Expand Down Expand Up @@ -51,7 +55,9 @@ use tiktoken_rs::model::get_context_size;
/// see the [crate documentation](`crate`).
#[derive(Clone, Debug)]
pub struct ChatSplitter {
/// The model to use for tokenization, e.g., `gpt-3.5-turbo`.
/// The model to use for tokenization,
/// e.g.,
/// `gpt-3.5-turbo`.
///
/// It is passed to [`tiktoken_rs`] to select the correct tokenizer.
model: String,
Expand Down Expand Up @@ -149,7 +155,9 @@ impl ChatSplitter {
self
}

/// Set the model to use for tokenization, e.g., `gpt-3.5-turbo`.
/// Set the model to use for tokenization,
/// e.g.,
/// `gpt-3.5-turbo`.
///
/// It is passed to [`tiktoken_rs`] to select the correct tokenizer.
#[inline]
Expand Down