merge main

This commit is contained in:
jhqxxx
2026-02-02 21:30:52 +08:00
parent f2cb6bf976
commit 073723447f
13 changed files with 285 additions and 59 deletions
+30
View File
@@ -712,6 +712,25 @@ pub fn extract_user_text(mes: &ChatCompletionParameters) -> Result<String> {
Ok(ret)
}
pub fn extract_user_text_vec(mes: &ChatCompletionParameters) -> Result<Vec<String>> {
let mut ret = vec![];
for chat_mes in mes.messages.clone() {
if let ChatMessage::User { content, .. } = chat_mes.clone()
&& let ChatMessageContent::ContentPart(part_vec) = content
{
for part in part_vec {
if let ChatMessageContentPart::Text(text_part) = part {
let text = text_part.text;
if text.chars().count() > 0 {
ret.push(text);
}
}
}
}
}
Ok(ret)
}
pub fn get_default_save_dir() -> Option<String> {
home_dir().map(|mut path| {
path.push(".aha");
@@ -772,3 +791,14 @@ pub fn get_file_path(file: &str) -> Result<PathBuf> {
};
Ok(path)
}
pub fn capitalize_first_letter(input: &str) -> String {
if input.is_empty() {
return input.to_string();
}
let mut chars = input.chars();
let first_char = chars.next().unwrap().to_uppercase().collect::<String>();
let remaining = chars.as_str().to_lowercase();
format!("{}{}", first_char, remaining)
}