Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "happycommit"
version = "0.2.0"
version = "0.2.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -9,7 +9,7 @@ edition = "2021"
dotenv = "0.15.0"
async-openai = "0.10.3"
tokio = { version="1.27.0", features=["full"] }
tiktoken-rs = { git="https://github.com/zurawiki/tiktoken-rs", version = "0.4.1", features=["async-openai"] }
tiktoken-rs = { git="https://github.com/zurawiki/tiktoken-rs", version = "0.4.2", features=["async-openai"] }
lazy_static = "1.4.0"
anyhow = "1.0.70"
futures = "0.3.28"
Expand Down
18 changes: 17 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,20 @@ install:
@cargo install --path .

# Run both 'format' and 'clippy' tasks
fix: format clippy
fix: format clippy

# Install dependencies
deps:
@cargo install cargo-bump

# Bump the patch
bump-patch: deps
@cargo bump patch --git-tag

# Bump the minor
bump-minor: deps
@cargo bump minor --git-tag

# Bump the major
bump-major: deps
@cargo bump major --git-tag
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,13 @@ async fn stream_multipart_commit_message(
) -> Result<Vec<String>, anyhow::Error> {
let tokenizer = cl100k_base().unwrap();
let max_tokens = 3500;
let tokenized_iter = tokenizer.split_by_token_with_special_tokens(code_changes);
let tokenized_iter = tokenizer.split_by_token_iter(code_changes, true);

let overlap = 200;
let mut split_code_changes = Vec::new();

let initial_prompt_tokens = tokenizer
.split_by_token_with_special_tokens(initial_prompt)
.collect::<Result<Vec<String>, _>>()?
.split_by_token(initial_prompt, true)?
.len();

let max_code_tokens = max_tokens - initial_prompt_tokens;
Expand Down