Allow for prompt caching to work by using baibot_conversation_start_time_utc instead of baibot_now_utc

This patch introduces a new `baibot_conversation_start_time_utc`
variable which indicates the time the conversation got started.

Using `baibot_now_utc` is still possible, but given that the current
time is a moving target, its use is in conflict with prompt caching.

Because the new `baibot_conversation_start_time_utc` prompt variable
is a more reasonable default, we're now using it in all sample configs.
This commit is contained in:
Slavi Pantaleev
2024-10-03 11:48:14 +03:00
parent db9422740c
commit 85e66406dc
25 changed files with 159 additions and 25 deletions

View File

@@ -86,6 +86,7 @@ pub mod test {
let message = super::Message {
author: super::Author::User,
message_text: "Hello there!".to_owned(),
timestamp: chrono::Utc::now(),
};
let tokens = super::calculate_token_size_for_message(&bpe, model, &message);
@@ -104,6 +105,7 @@ pub mod test {
let prompt = super::Message {
author: super::Author::Prompt,
message_text: "You are a bot!".to_owned(),
timestamp: chrono::Utc::now(),
};
let prompt_length = 10;
@@ -117,6 +119,7 @@ pub mod test {
let first = super::Message {
author: super::Author::User,
message_text: "Hello there!".to_owned(),
timestamp: chrono::Utc::now(),
};
let first_length = 8;
@@ -130,6 +133,7 @@ pub mod test {
let second = super::Message {
author: super::Author::Assistant,
message_text: "Hello!".to_owned(),
timestamp: chrono::Utc::now(),
};
let second_length = 7;
@@ -144,6 +148,7 @@ pub mod test {
author: super::Author::User,
message_text: "This is the 3rd message in this conversation. It shall be preserved."
.to_owned(),
timestamp: chrono::Utc::now(),
};
let third_length = 21;
@@ -157,6 +162,7 @@ pub mod test {
let forth = super::Message {
author: super::Author::Assistant,
message_text: "This is yet another message that shall be preserved.".to_owned(),
timestamp: chrono::Utc::now(),
};
let forth_length = 15;
@@ -201,6 +207,7 @@ pub mod test {
let prompt = super::Message {
author: super::Author::User,
message_text: "あなたはボットです。".to_owned(),
timestamp: chrono::Utc::now(),
};
let prompt_length = 14;
@@ -214,6 +221,7 @@ pub mod test {
let first = super::Message {
author: super::Author::User,
message_text: "こんにちは!".to_owned(),
timestamp: chrono::Utc::now(),
};
let first_length = 7;
@@ -227,6 +235,7 @@ pub mod test {
let second = super::Message {
author: super::Author::Assistant,
message_text: "こんにちは。今日は元気ですか。".to_owned(),
timestamp: chrono::Utc::now(),
};
let second_length = 15;
@@ -240,6 +249,7 @@ pub mod test {
let third = super::Message {
author: super::Author::User,
message_text: "これは第3のメッセージなので、保存されます。".to_owned(),
timestamp: chrono::Utc::now(),
};
let third_length = 22;
@@ -253,6 +263,7 @@ pub mod test {
let forth = super::Message {
author: super::Author::Assistant,
message_text: "これはもう一つの保存されますメッセージです。".to_owned(),
timestamp: chrono::Utc::now(),
};
let forth_length = 21;