vtrv.vls commited on
Commit
e357d2f
·
1 Parent(s): e4fda99
Files changed (2) hide show
  1. app.py +2 -2
  2. utils.py +3 -1
app.py CHANGED
@@ -18,10 +18,10 @@ def giga_gen(content, chat_history):
18
  if chat_history is None:
19
  chat_history = []
20
  else:
21
- chat_history.append({"role": "user", "content": content})
22
  print(chat_history)
23
  res = generate(chat_history,'auth_token.json')
24
- chat_history.append({"role": "assistant", "content": res})
25
  send_to_s3(res, f'protobench/giga_{str(datetime.now()).replace(" ", "_")}.json', S3_SESSION)
26
  print(chat_history)
27
  return '', chat_history
 
18
  if chat_history is None:
19
  chat_history = []
20
  else:
21
+ chat_history.append(("user", content))
22
  print(chat_history)
23
  res = generate(chat_history,'auth_token.json')
24
+ chat_history.append(("assistant", res))
25
  send_to_s3(res, f'protobench/giga_{str(datetime.now()).replace(" ", "_")}.json', S3_SESSION)
26
  print(chat_history)
27
  return '', chat_history
utils.py CHANGED
@@ -49,7 +49,7 @@ def get_text(content, auth_token=None):
49
  return json.loads(response.text)
50
 
51
 
52
- def generate(content='Привет!', auth_file=None):
53
  if auth_file is None or not os.path.isfile(auth_file):
54
  gen_auth_token(auth_file)
55
 
@@ -61,6 +61,8 @@ def generate(content='Привет!', auth_file=None):
61
  with open(auth_file) as f:
62
  auth_token = json.load(f)
63
 
 
 
64
  resp = get_text(content, auth_token['access_token'])
65
 
66
  return resp["choices"][0]["message"]["content"]
 
49
  return json.loads(response.text)
50
 
51
 
52
+ def generate(content=None, auth_file=None):
53
  if auth_file is None or not os.path.isfile(auth_file):
54
  gen_auth_token(auth_file)
55
 
 
61
  with open(auth_file) as f:
62
  auth_token = json.load(f)
63
 
64
+ content = [{'role': x[0], 'content': x[1]} for x in content]
65
+
66
  resp = get_text(content, auth_token['access_token'])
67
 
68
  return resp["choices"][0]["message"]["content"]