Skip to content

Commit 198bfcc

Browse files
authored
feat(chat): Add current UTC time to user messages (#1670)
1 parent 8099446 commit 198bfcc

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/q_chat/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ url.workspace = true
5151
uuid.workspace = true
5252
winnow.workspace = true
5353
strip-ansi-escapes = "0.2.1"
54+
chrono = "0.4.41"
5455

5556
[dev-dependencies]
5657
tracing-subscriber.workspace = true

crates/q_chat/src/conversation_state.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ impl ConversationState {
195195
warn!("input must not be empty when adding new messages");
196196
"Empty prompt".to_string()
197197
} else {
198-
input
198+
// Add current UTC time in XML tags at the end of the message
199+
let now = chrono::Utc::now();
200+
let formatted_time = now.format("%Y-%m-%d %H:%M:%S").to_string();
201+
format!("{}\n\n<currentTimeUTC>\n{}\n</currentTimeUTC>", input, formatted_time)
199202
};
200203

201204
let msg = UserMessage::new_prompt(input);

0 commit comments

Comments
 (0)