atrytone commited on
Commit
cded25d
·
1 Parent(s): 4351e0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -17,6 +17,7 @@ SPREADSHEET_ID = '1o0iKPxWYKYKEPjqB2YwrTgrLzvGyb9ULj9tnw_cfJb0'
17
  service = build('sheets', 'v4', credentials=creds)
18
  LEFT_MODEL = None
19
  RIGHT_MODEL = None
 
20
 
21
  with open("article_list.pkl","rb") as articles:
22
  article_list = tuple(pickle.load(articles))
@@ -44,9 +45,10 @@ def get_matchup():
44
  return left, right
45
 
46
  def get_comp(prompt):
 
47
  left, right = get_matchup()
48
- left_output = inference(prompt,left)
49
- right_output = inference(prompt,right)
50
  return left_output, right_output
51
 
52
  def get_article():
@@ -54,6 +56,7 @@ def get_article():
54
 
55
 
56
  def send_result(l_output, r_output, prompt, pick):
 
57
  global LEFT_MODEL, RIGHT_MODEL
58
  # with open('results.csv','a') as res_file:
59
  # writer = csv.writer(res_file)
@@ -62,12 +65,13 @@ def send_result(l_output, r_output, prompt, pick):
62
  pick = LEFT_MODEL
63
  else:
64
  pick = RIGHT_MODEL
65
- row = [USER_ID,prompt,LEFT_MODEL,RIGHT_MODEL,pick]
66
  row = [str(x) for x in row]
67
  body = {'values': [row]}
68
  result = service.spreadsheets().values().append(spreadsheetId=SPREADSHEET_ID, range='A1:E1', valueInputOption='RAW', body=body).execute()
69
  print(f"Appended {result['updates']['updatedCells']} cells.")
70
  new_prompt = get_article()
 
71
  return new_prompt,gr.State.update(value=new_prompt)
72
 
73
 
@@ -126,6 +130,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
126
  article = get_article()
127
  models = gr.State(value=get_matchup())
128
  prompt = gr.State(value=article)
 
129
  abst = gr.Textbox(value = article, label="Abstract", lines=10)
130
  action_btn = gr.Button(value="Get comparison")
131
  with gr.Group():
 
17
  service = build('sheets', 'v4', credentials=creds)
18
  LEFT_MODEL = None
19
  RIGHT_MODEL = None
20
+ PROMPT = None
21
 
22
  with open("article_list.pkl","rb") as articles:
23
  article_list = tuple(pickle.load(articles))
 
45
  return left, right
46
 
47
  def get_comp(prompt):
48
+ global PROMPT
49
  left, right = get_matchup()
50
+ left_output = inference(PROMPT,left)
51
+ right_output = inference(PROMPT,right)
52
  return left_output, right_output
53
 
54
  def get_article():
 
56
 
57
 
58
  def send_result(l_output, r_output, prompt, pick):
59
+ global PROMPT
60
  global LEFT_MODEL, RIGHT_MODEL
61
  # with open('results.csv','a') as res_file:
62
  # writer = csv.writer(res_file)
 
65
  pick = LEFT_MODEL
66
  else:
67
  pick = RIGHT_MODEL
68
+ row = [USER_ID,PROMPT,LEFT_MODEL,RIGHT_MODEL,pick]
69
  row = [str(x) for x in row]
70
  body = {'values': [row]}
71
  result = service.spreadsheets().values().append(spreadsheetId=SPREADSHEET_ID, range='A1:E1', valueInputOption='RAW', body=body).execute()
72
  print(f"Appended {result['updates']['updatedCells']} cells.")
73
  new_prompt = get_article()
74
+ PROMPT = new_prompt
75
  return new_prompt,gr.State.update(value=new_prompt)
76
 
77
 
 
130
  article = get_article()
131
  models = gr.State(value=get_matchup())
132
  prompt = gr.State(value=article)
133
+ PROMPT = article
134
  abst = gr.Textbox(value = article, label="Abstract", lines=10)
135
  action_btn = gr.Button(value="Get comparison")
136
  with gr.Group():