HemanM commited on
Commit
95db7be
·
verified ·
1 Parent(s): 780da7b

Update inference.py

Browse files
Files changed (1) hide show
  1. inference.py +28 -2
inference.py CHANGED
@@ -87,8 +87,34 @@ def get_system_stats():
87
  }
88
 
89
  def retrain_from_feedback_csv():
90
- if not os.path.exists(FEEDBACK_LOG):
91
- return "⚠️ No feedback log file found."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
 
93
  data = []
94
  with open(FEEDBACK_LOG, "r", encoding="utf-8") as f:
 
87
  }
88
 
89
  def retrain_from_feedback_csv():
90
+ import pandas as pd
91
+ from evo_architecture import mutate_genome, log_genome, save_best_genome, build_model_from_config
92
+ from train_utils import train_model_on_feedback # your training function
93
+
94
+ if not os.path.exists("feedback_log.csv"):
95
+ return "⚠️ No feedback log found."
96
+
97
+ df = pd.read_csv("feedback_log.csv")
98
+
99
+ if df.empty or "vote" not in df.columns or df["vote"].dropna().empty:
100
+ return "⚠️ No usable feedback data. Make sure you selected Evo or GPT in previous interactions."
101
+
102
+ # Filter only rows with valid vote
103
+ df = df[df["vote"].isin(["Evo", "GPT"])]
104
+
105
+ if df.empty:
106
+ return "⚠️ No usable feedback data. Please vote on Evo or GPT in previous questions."
107
+
108
+ # Proceed with mutation & training...
109
+ new_config = mutate_genome(load_best_genome())
110
+ log_genome(new_config)
111
+
112
+ model = build_model_from_config(new_config)
113
+ score = train_model_on_feedback(model, df) # this should return a score or accuracy
114
+ save_best_genome({**new_config, "accuracy": score})
115
+
116
+ return f"✅ Evo retrained using feedback (score={score:.4f})"
117
+
118
 
119
  data = []
120
  with open(FEEDBACK_LOG, "r", encoding="utf-8") as f: