2025-12-30 02:08:26 +05:30
use crate ::gemini ::types ::OrganizationPlanResponse ;
2025-12-30 02:10:00 +05:30
use crate ::models ::{ FileCategory , OrganizationPlan } ;
2025-12-29 00:35:14 +05:30
impl OrganizationPlanResponse {
pub fn to_organization_plan ( self ) -> OrganizationPlan {
OrganizationPlan {
files : self
. files
. into_iter ( )
. map ( | f | FileCategory {
filename : f . filename ,
category : f . category ,
sub_category : String ::new ( ) ,
} )
. collect ( ) ,
}
}
}
#[ derive(Debug) ]
pub struct PromptBuilder {
file_list : String ,
}
impl PromptBuilder {
pub fn new ( file_list : Vec < String > ) -> Self {
Self {
file_list : file_list . join ( " , " ) ,
}
}
pub fn build_categorization_prompt ( & self ) -> String {
format! (
" I have these files in my Downloads folder: [{}]. \
Categorize them into these folders : ' Images ' , ' Documents ' , ' Installers ' , ' Music ' , ' Archives ' , ' Code ' , ' Misc ' . \
Return ONLY a JSON object with this structure : { { ' files ' : [ { { ' filename ' : ' name ' , ' category ' : ' folder ' } } ] } } " ,
self . file_list
)
}
pub fn build_subcategory_prompt (
filename : & str ,
parent_category : & str ,
content : & str ,
) -> String {
format! (
" I have a file named '{}' inside the '{}' folder. Here is the first 1000 characters of content: \n --- \n {} \n --- \n Based on this, suggest a single short sub-folder name (e.g., 'Invoices', 'Notes', 'Config'). Return ONLY the name of the sub-folder. Do not use markdown or explanations. " ,
filename , parent_category , content
)
}
}