Brasd99 commited on
Commit
ad9e41c
1 Parent(s): 7bd8688
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -18,13 +18,11 @@ system_prompt = config['SYSTEM_PROMPT']
18
  use_sage = config['USE_SAGE']
19
  sage_token = os.environ['SAGE_TOKEN']
20
 
21
- client = poe.Client(sage_token)
22
-
23
- def get_answer(question: str) -> Dict[str, Any]:
24
-
25
  if use_sage:
26
  for chunk in client.send_message('capybara', question, with_chat_break=True):
27
  pass
 
28
  return {
29
  'status': True,
30
  'content': chunk['text']
@@ -101,12 +99,15 @@ def find_answers(tags: str, questions: str, progress=gr.Progress()) -> str:
101
 
102
  tags_str = ''.join([f'[{tag}]' for tag in tags])
103
 
 
 
 
104
  results = []
105
  for question in progress.tqdm(questions):
106
  time.sleep(wait_time)
107
  tagged_question = f'{tags_str} {question}'
108
  for attempt in range(max_attempts):
109
- answer = get_answer(tagged_question)
110
  if answer['status']:
111
  results.append((question, answer['content']))
112
  break
 
18
  use_sage = config['USE_SAGE']
19
  sage_token = os.environ['SAGE_TOKEN']
20
 
21
+ def get_answer(question: str, client: poe.Client=None) -> Dict[str, Any]:
 
 
 
22
  if use_sage:
23
  for chunk in client.send_message('capybara', question, with_chat_break=True):
24
  pass
25
+ client.delete_message(chunk['messageId'])
26
  return {
27
  'status': True,
28
  'content': chunk['text']
 
99
 
100
  tags_str = ''.join([f'[{tag}]' for tag in tags])
101
 
102
+ if use_sage:
103
+ client = poe.Client(sage_token)
104
+
105
  results = []
106
  for question in progress.tqdm(questions):
107
  time.sleep(wait_time)
108
  tagged_question = f'{tags_str} {question}'
109
  for attempt in range(max_attempts):
110
+ answer = get_answer(tagged_question, client)
111
  if answer['status']:
112
  results.append((question, answer['content']))
113
  break