ivnban27-ctl commited on
Commit
13be379
1 Parent(s): 238098c

priority change and clear memory bug

Browse files
Files changed (2) hide show
  1. mongo_utils.py +36 -28
  2. pages/comparisor.py +1 -1
mongo_utils.py CHANGED
@@ -102,41 +102,49 @@ def new_completion_error(client, comparison_id, username, model):
102
  def get_non_assesed_comparison(client, username):
103
  from bson.son import SON
104
  pipeline = [
105
- {'$lookup': {
106
- 'from': DB_BATTLES,
107
- 'localField': '_id',
108
- 'foreignField': 'comparison_id',
109
- "pipeline": [
110
- {"$match": {"username":username}},
111
- ],
112
- 'as': 'battles'
113
- }},
114
- {'$lookup': {
115
- 'from': DB_CONVOS,
116
- 'localField': 'convo_id',
117
- 'foreignField': '_id',
118
- 'as': 'convo_info'
119
- }},
120
- {"$match":{
121
- "battles": {"$size":0},
122
- }},
123
- {"$addFields": {
124
- "priority": {
125
  "$cond":[
126
  {"$eq": ["$source","manual"]},
127
  1,
128
  0
129
  ]
130
  },
131
- }},
132
- {"$sort": SON([
133
- ("priority", -1),
134
- ("prompt_timestamp", 1),
135
- ("convo_id", 1),
136
- ])
137
  },
138
- {"$limit": 1}
139
- ]
 
 
 
 
 
 
 
 
140
 
141
  db = client[DB_SCHEMA]
142
  return list(db[DB_COMPLETIONS].aggregate(pipeline))
 
102
  def get_non_assesed_comparison(client, username):
103
  from bson.son import SON
104
  pipeline = [
105
+ {'$lookup': {
106
+ 'from': DB_BATTLES,
107
+ 'localField': '_id',
108
+ 'foreignField': 'comparison_id',
109
+ "pipeline": [
110
+ {"$match": {"username":username}},
111
+ ],
112
+ 'as': 'battles'
113
+ }},
114
+ {'$lookup': {
115
+ 'from': DB_CONVOS,
116
+ 'localField': 'convo_id',
117
+ 'foreignField': '_id',
118
+ 'as': 'convo_info'
119
+ }},
120
+ {"$match":{
121
+ "battles": {"$size":0},
122
+ }},
123
+ {"$addFields": {
124
+ "is_manual": {
125
  "$cond":[
126
  {"$eq": ["$source","manual"]},
127
  1,
128
  0
129
  ]
130
  },
131
+ "is_eval":{
132
+ "$cond":[
133
+ {"$eq": ["$subset","eval"]},
134
+ 1,
135
+ 0
136
+ ]
137
  },
138
+ "priority": {"$sum": ["is_manual","is_eval"]}
139
+ }},
140
+ {"$sort": SON([
141
+ ("priority", -1),
142
+ ("prompt_timestamp", 1),
143
+ ("convo_id", 1),
144
+ ])
145
+ },
146
+ {"$limit": 1}
147
+ ]
148
 
149
  db = client[DB_SCHEMA]
150
  return list(db[DB_COMPLETIONS].aggregate(pipeline))
pages/comparisor.py CHANGED
@@ -129,7 +129,7 @@ with st.sidebar:
129
 
130
  # regenA = sbcol1.button("Regenerate A", on_click=regenerateA)
131
  # regenB = sbcol2.button("Regenerate B", on_click=regenerateB)
132
- clear = st.button("Clear History", on_click=clear_memory, args=(memories,))
133
 
134
  memories = {
135
  'memoryA': {"issue": issue, "source": sourceA},
 
129
 
130
  # regenA = sbcol1.button("Regenerate A", on_click=regenerateA)
131
  # regenB = sbcol2.button("Regenerate B", on_click=regenerateB)
132
+ clear = st.button("Clear History", on_click=clear_memory, kwargs={"memories":memories, "username":username, "language":language})
133
 
134
  memories = {
135
  'memoryA': {"issue": issue, "source": sourceA},