Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.
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.

2 changes: 1 addition & 1 deletion server/bleep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ gix = { git = "https://github.com/BloopAI/gitoxide", version="0.55.2", features

# semantic
qdrant-client = { version = "1.5.0", default-features = false }
tiktoken-rs = "0.4.5"
tiktoken-rs = "0.5.7"
tokenizers = { version = "0.14.0", default-features = false, features = ["progressbar", "cli", "onig", "esaxx_fast"] }

# answer parsing
Expand Down
4 changes: 2 additions & 2 deletions server/bleep/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ fn trim_history(
} => {
if role == "assistant" && content != HIDDEN {
*content = HIDDEN.into();
tm.content = HIDDEN.into();
tm.content = Some(HIDDEN.into());
true
} else {
false
Expand All @@ -515,7 +515,7 @@ fn trim_history(
ref mut content,
} if content != HIDDEN => {
*content = HIDDEN.into();
tm.content = HIDDEN.into();
tm.content = Some(HIDDEN.into());
true
}
_ => false,
Expand Down
15 changes: 12 additions & 3 deletions server/bleep/src/llm_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ impl From<&api::Message> for tiktoken_rs::ChatCompletionRequestMessage {
api::Message::PlainText { role, content } => {
tiktoken_rs::ChatCompletionRequestMessage {
role: role.clone(),
content: content.clone(),
content: Some(content.clone()),
name: None,
function_call: None,
}
}
api::Message::FunctionReturn {
Expand All @@ -170,17 +171,25 @@ impl From<&api::Message> for tiktoken_rs::ChatCompletionRequestMessage {
content,
} => tiktoken_rs::ChatCompletionRequestMessage {
role: role.clone(),
content: content.clone(),
content: Some(content.clone()),
name: Some(name.clone()),
function_call: None,
},
api::Message::FunctionCall {
role,
function_call,
content: _,
} => tiktoken_rs::ChatCompletionRequestMessage {
role: role.clone(),
content: serde_json::to_string(&function_call).unwrap(),
content: None,
name: None,
function_call: Some(tiktoken_rs::FunctionCall {
name: function_call
.name
.clone()
.expect("FunctionCall has no name"),
arguments: function_call.arguments.clone(),
}),
},
}
}
Expand Down
9 changes: 6 additions & 3 deletions server/bleep/src/webserver/studio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,9 @@ async fn token_counts(
let empty_context = generate_llm_context(app.clone(), &[], &[]).await?;
let empty_system_message = tiktoken_rs::ChatCompletionRequestMessage {
role: "system".to_owned(),
content: prompts::studio_article_prompt(&empty_context),
content: Some(prompts::studio_article_prompt(&empty_context)),
name: None,
function_call: None,
};

let baseline =
Expand All @@ -523,13 +524,15 @@ async fn token_counts(
let tiktoken_messages = messages.iter().cloned().map(|message| match message {
Message::User(content) => tiktoken_rs::ChatCompletionRequestMessage {
role: "user".to_owned(),
content,
content: Some(content),
name: None,
function_call: None,
},
Message::Assistant(content) => tiktoken_rs::ChatCompletionRequestMessage {
role: "assistant".to_owned(),
content,
content: Some(content),
name: None,
function_call: None,
},
});

Expand Down