HemanM commited on
Commit
61203b9
Β·
verified Β·
1 Parent(s): 4096d16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import gradio as gr
2
- from inference import evo_chat_predict, get_model_config, get_system_stats, get_gpt_response, retrain_from_feedback
3
  import pandas as pd
4
  import csv
5
  from datetime import datetime
@@ -37,21 +37,22 @@ with gr.Blocks(theme=gr.themes.Base(), css="body { background-color: #0f0f0f; co
37
  )
38
 
39
  # πŸ” Ask Evo
40
- def ask_evo(q, opt1, opt2, hist):
41
  result = evo_chat_predict(hist, q, [opt1, opt2])
42
  evo_text = f"Answer: {result['answer']} (Confidence: {result['confidence']})\n\nReasoning: {result['reasoning']}"
43
  gpt_text = get_gpt_response(q)
44
  stats = get_model_config()
45
  stats_text = f"Layers: {stats['num_layers']} | Heads: {stats['num_heads']} | FFN: {stats['ffn_dim']} | Memory: {stats['memory_enabled']} | Phase: {stats['phase']} | Accuracy: {stats['accuracy']}"
46
-
47
- # βœ… Safe conversation history update
48
  new_row = [q, opt1, opt2, result["answer"], result["confidence"], result["reasoning"], result["context_used"]]
49
  new_row_df = pd.DataFrame([new_row], columns=hist.columns)
50
- if hist.empty:
51
- updated_df = new_row_df
52
- else:
53
- updated_df = pd.concat([hist, new_row_df], ignore_index=True)
54
-
 
55
  return evo_text, gpt_text, stats_text, updated_df
56
 
57
  # πŸ” Actual retraining
@@ -78,7 +79,7 @@ with gr.Blocks(theme=gr.themes.Base(), css="body { background-color: #0f0f0f; co
78
  return "⚠️ No feedback to export."
79
 
80
  # πŸ”˜ Event bindings
81
- evo_btn.click(fn=ask_evo, inputs=[query, option1, option2, convo], outputs=[evo_box, gpt_box, evo_stats, convo])
82
  retrain_btn.click(fn=retrain_evo, inputs=[], outputs=[status_box])
83
  clear_btn.click(fn=clear_fields, inputs=[], outputs=[query, option1, option2, evo_box, gpt_box, convo])
84
  export_btn.click(fn=log_feedback_to_csv, inputs=[], outputs=[status_box])
 
1
  import gradio as gr
2
+ from inference import evo_chat_predict, get_model_config, get_gpt_response, retrain_from_feedback
3
  import pandas as pd
4
  import csv
5
  from datetime import datetime
 
37
  )
38
 
39
  # πŸ” Ask Evo
40
+ def ask_evo(q, opt1, opt2, hist, selected):
41
  result = evo_chat_predict(hist, q, [opt1, opt2])
42
  evo_text = f"Answer: {result['answer']} (Confidence: {result['confidence']})\n\nReasoning: {result['reasoning']}"
43
  gpt_text = get_gpt_response(q)
44
  stats = get_model_config()
45
  stats_text = f"Layers: {stats['num_layers']} | Heads: {stats['num_heads']} | FFN: {stats['ffn_dim']} | Memory: {stats['memory_enabled']} | Phase: {stats['phase']} | Accuracy: {stats['accuracy']}"
46
+
47
+ # Update history
48
  new_row = [q, opt1, opt2, result["answer"], result["confidence"], result["reasoning"], result["context_used"]]
49
  new_row_df = pd.DataFrame([new_row], columns=hist.columns)
50
+ updated_df = new_row_df if hist.empty else pd.concat([hist, new_row_df], ignore_index=True)
51
+
52
+ # Log feedback
53
+ if selected in ["Evo", "GPT"]:
54
+ feedback_log.append(new_row)
55
+
56
  return evo_text, gpt_text, stats_text, updated_df
57
 
58
  # πŸ” Actual retraining
 
79
  return "⚠️ No feedback to export."
80
 
81
  # πŸ”˜ Event bindings
82
+ evo_btn.click(fn=ask_evo, inputs=[query, option1, option2, convo, feedback], outputs=[evo_box, gpt_box, evo_stats, convo])
83
  retrain_btn.click(fn=retrain_evo, inputs=[], outputs=[status_box])
84
  clear_btn.click(fn=clear_fields, inputs=[], outputs=[query, option1, option2, evo_box, gpt_box, convo])
85
  export_btn.click(fn=log_feedback_to_csv, inputs=[], outputs=[status_box])