vtrv.vls commited on
Commit
cce3c9c
·
1 Parent(s): 8f4c6d6
Files changed (2) hide show
  1. app.py +42 -4
  2. utils.py +5 -3
app.py CHANGED
@@ -14,22 +14,60 @@ TINY_LLAMA = None
14
 
15
  S3_SESSION = None
16
 
17
- def giga_gen(content):
18
  res = generate(content,'auth_token.json')
19
  send_to_s3(res, f'protobench/giga_{str(datetime.now()).replace(" ", "_")}.json', S3_SESSION)
20
  return res
21
 
22
- def tiny_gen(content):
23
  res = response_tiny_llama(TINY_LLAMA, content)
24
  send_to_s3(res, f'protobench/tiny_{str(datetime.now()).replace(" ", "_")}.json', S3_SESSION)
25
  return res
26
 
 
27
  def tab_arena():
28
  with gradio.Row():
29
  with gradio.Column():
30
- gradio.Interface(fn=giga_gen, inputs="text", outputs="text", allow_flagging=False, title='Giga') # arena =
31
  with gradio.Column():
32
- gradio.Interface(fn=tiny_gen, inputs="text", outputs="text", allow_flagging=False, title='TinyLlama') # arena =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  # arena.launch()
35
 
 
14
 
15
  S3_SESSION = None
16
 
17
+ def giga_gen(content, history):
18
  res = generate(content,'auth_token.json')
19
  send_to_s3(res, f'protobench/giga_{str(datetime.now()).replace(" ", "_")}.json', S3_SESSION)
20
  return res
21
 
22
+ def tiny_gen(content, history):
23
  res = response_tiny_llama(TINY_LLAMA, content)
24
  send_to_s3(res, f'protobench/tiny_{str(datetime.now()).replace(" ", "_")}.json', S3_SESSION)
25
  return res
26
 
27
+
28
  def tab_arena():
29
  with gradio.Row():
30
  with gradio.Column():
31
+ chatbot_left = gradio.Chatbot()
32
  with gradio.Column():
33
+ chatbot_right = gradio.Chatbot()
34
+
35
+ with gradio.Row():
36
+ gradio.Button('Both Good')
37
+ gradio.Button('Left Better')
38
+ gradio.Button('Right Better')
39
+ gradio.Button('Both Bad')
40
+
41
+ msg = gradio.Textbox()
42
+ clear = gradio.ClearButton([msg, chatbot_left, chatbot_right])
43
+
44
+ # def respond(message, chat_history):
45
+ # bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
46
+ # chat_history.append((message, bot_message))
47
+ # time.sleep(2)
48
+ # return "", chat_history
49
+
50
+ msg.submit(giga_gen, [msg, chatbot_left], [msg, chatbot_left])
51
+ msg.submit(tiny_gen, [msg, chatbot_right], [msg, chatbot_right])
52
+
53
+ # with gradio.Column():
54
+ # gradio.ChatInterface(
55
+ # fn=giga_gen,
56
+ # examples=[{"text": "hello"}, {"text": "hola"}, {"text": "merhaba"}],
57
+ # title="Giga",
58
+ # multimodal=True,
59
+ # )
60
+ # with gradio.Column():
61
+ # gradio.ChatInterface(
62
+ # fn=tiny_gen,
63
+ # examples=[{"text": "hello"}, {"text": "hola"}, {"text": "merhaba"}],
64
+ # title="Tiny",
65
+ # multimodal=True,
66
+ # )
67
+ # with gradio.Column():
68
+ # gradio.Interface(fn=giga_gen, inputs="text", outputs="text", allow_flagging=False, title='Giga') # arena =
69
+ # with gradio.Column():
70
+ # gradio.Interface(fn=tiny_gen, inputs="text", outputs="text", allow_flagging=False, title='TinyLlama') # arena =
71
 
72
  # arena.launch()
73
 
utils.py CHANGED
@@ -6,10 +6,11 @@ import boto3
6
 
7
 
8
  def gen_auth_token(auth_file):
9
-
10
- url = "https://ngw.devices.sberbank.ru:9443/api/v2/oauth"
11
 
12
  payload='scope=GIGACHAT_API_CORP'
 
13
  headers = {
14
  'Content-Type': 'application/x-www-form-urlencoded',
15
  'Accept': 'application/json',
@@ -24,7 +25,8 @@ def gen_auth_token(auth_file):
24
 
25
 
26
  def get_text(content='Привет!', auth_token=None):
27
- url = "https://gigachat.devices.sberbank.ru/api/v1/chat/completions"
 
28
 
29
  payload = json.dumps({
30
  "model": "GigaChat",
 
6
 
7
 
8
  def gen_auth_token(auth_file):
9
+ # url = "https://ngw.devices.sberbank.ru:9443/api/v2/oauth"
10
+ url = "https://api.mlrnd.ru/api/v2/oauth"
11
 
12
  payload='scope=GIGACHAT_API_CORP'
13
+ payload='scope=API_v1'
14
  headers = {
15
  'Content-Type': 'application/x-www-form-urlencoded',
16
  'Accept': 'application/json',
 
25
 
26
 
27
  def get_text(content='Привет!', auth_token=None):
28
+ # url = "https://gigachat.devices.sberbank.ru/api/v1/chat/completions"
29
+ url = "https://api.mlrnd.ru/api/v1/chat/completions"
30
 
31
  payload = json.dumps({
32
  "model": "GigaChat",