Skip to main content

vtcode_core/code/code_completion/learning/
mod.rs

1pub mod data;
2pub mod feedback;
3
4pub use data::CompletionLearningData;
5pub use feedback::FeedbackProcessor;
6
7use hashbrown::HashMap;
8
9/// Learning system for improving completion suggestions
10pub struct LearningSystem {
11    learning_data: CompletionLearningData,
12    feedback_processor: FeedbackProcessor,
13}
14
15impl Default for LearningSystem {
16    fn default() -> Self {
17        Self::new()
18    }
19}
20
21impl LearningSystem {
22    pub fn new() -> Self {
23        Self {
24            learning_data: CompletionLearningData::default(),
25            feedback_processor: FeedbackProcessor::new(),
26        }
27    }
28
29    /// Process user feedback to improve future suggestions
30    pub fn process_feedback(&mut self, suggestion_text: &str, accepted: bool, context: &str) {
31        self.feedback_processor
32            .process(suggestion_text, accepted, context);
33        self.learning_data
34            .update_from_feedback(suggestion_text, accepted);
35    }
36
37    /// Get learning insights for a given context
38    pub fn get_insights(&self, context: &str) -> HashMap<String, f64> {
39        self.learning_data.get_context_insights(context)
40    }
41}