GitHub Actions commited on
Commit
43acb84
·
1 Parent(s): d50d3f8

Sync from GitHub repo

Browse files
Files changed (3) hide show
  1. .gitignore +3 -1
  2. app.py +4 -17
  3. models.py +11 -2
.gitignore CHANGED
@@ -49,4 +49,6 @@ Thumbs.db
49
  # Uploads
50
  static/temp_audio
51
 
52
- votes/
 
 
 
49
  # Uploads
50
  static/temp_audio
51
 
52
+ votes/
53
+
54
+ .claude
app.py CHANGED
@@ -690,8 +690,8 @@ def generate_tts():
690
  "cache_hit": False,
691
  }
692
 
693
- # Mark sentence as consumed for direct usage
694
- mark_sentence_consumed(text, session_id=session_id, usage_type='direct')
695
 
696
  # Return audio file paths and session
697
  return jsonify(
@@ -827,13 +827,7 @@ def submit_vote():
827
  if error:
828
  return jsonify({"error": error}), 500
829
 
830
- # Mark sentence as consumed AFTER successful vote recording (only for dataset sentences)
831
- if vote and vote.sentence_origin == 'dataset' and vote.counts_for_public_leaderboard:
832
- try:
833
- mark_sentence_consumed(session_data["text"], session_id=session_id, usage_type='voted')
834
- app.logger.info(f"Marked dataset sentence as consumed after vote: '{session_data['text'][:50]}...'")
835
- except Exception as e:
836
- app.logger.error(f"Error marking sentence as consumed after vote: {str(e)}")
837
 
838
  # --- Save preference data ---
839
  try:
@@ -1134,14 +1128,7 @@ def submit_podcast_vote():
1134
  if error:
1135
  return jsonify({"error": error}), 500
1136
 
1137
- # Mark sentence as consumed AFTER successful vote recording (only for dataset sentences)
1138
- # Note: Conversational votes typically use custom scripts, not dataset sentences
1139
- if vote and vote.sentence_origin == 'dataset' and vote.counts_for_public_leaderboard:
1140
- try:
1141
- mark_sentence_consumed(session_data["text"], session_id=session_id, usage_type='voted')
1142
- app.logger.info(f"Marked dataset sentence as consumed after conversational vote: '{session_data['text'][:50]}...'")
1143
- except Exception as e:
1144
- app.logger.error(f"Error marking sentence as consumed after conversational vote: {str(e)}")
1145
 
1146
  # --- Save preference data ---\
1147
  try:
 
690
  "cache_hit": False,
691
  }
692
 
693
+ # Don't mark as consumed yet - wait until vote is submitted to maintain security
694
+ # while allowing legitimate votes to count for ELO
695
 
696
  # Return audio file paths and session
697
  return jsonify(
 
827
  if error:
828
  return jsonify({"error": error}), 500
829
 
830
+ # Sentence consumption is now handled within record_vote function
 
 
 
 
 
 
831
 
832
  # --- Save preference data ---
833
  try:
 
1128
  if error:
1129
  return jsonify({"error": error}), 500
1130
 
1131
+ # Sentence consumption is now handled within record_vote function
 
 
 
 
 
 
 
1132
 
1133
  # --- Save preference data ---\
1134
  try:
models.py CHANGED
@@ -243,8 +243,8 @@ def record_vote(user_id, text, chosen_model_id, rejected_model_id, model_type,
243
 
244
  if all_dataset_sentences and text in all_dataset_sentences:
245
  sentence_origin = 'dataset'
246
- # Only count for public leaderboard if sentence was unconsumed when used
247
- # Check if it was consumed BEFORE this vote (don't consume yet)
248
  counts_for_public = not is_sentence_consumed(text)
249
  else:
250
  sentence_origin = 'custom'
@@ -316,6 +316,15 @@ def record_vote(user_id, text, chosen_model_id, rejected_model_id, model_type,
316
  )
317
 
318
  db.session.add_all([chosen_history, rejected_history])
 
 
 
 
 
 
 
 
 
319
  db.session.commit()
320
 
321
  return vote, None
 
243
 
244
  if all_dataset_sentences and text in all_dataset_sentences:
245
  sentence_origin = 'dataset'
246
+ # For dataset sentences, check if already consumed to prevent fraud
247
+ # But now we'll mark as consumed AFTER successful vote recording
248
  counts_for_public = not is_sentence_consumed(text)
249
  else:
250
  sentence_origin = 'custom'
 
316
  )
317
 
318
  db.session.add_all([chosen_history, rejected_history])
319
+
320
+ # Mark sentence as consumed AFTER successful vote recording (only for dataset sentences that count)
321
+ if counts_for_public and sentence_origin == 'dataset':
322
+ try:
323
+ mark_sentence_consumed(text, usage_type='voted')
324
+ except Exception as e:
325
+ # If consumption marking fails, log but don't fail the vote
326
+ logging.error(f"Failed to mark sentence as consumed after vote: {str(e)}")
327
+
328
  db.session.commit()
329
 
330
  return vote, None