greyfoss commited on
Commit
9eb29f6
1 Parent(s): cd0df34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -7,6 +7,8 @@ from optimum.onnxruntime import ORTModelForCausalLM
7
 
8
  import itertools
9
  import regex as re
 
 
10
 
11
 
12
  user_token = "<User>"
@@ -14,6 +16,15 @@ eos_token = "<EOS>"
14
  bos_token = "<BOS>"
15
  bot_token = "<Assistant>"
16
 
 
 
 
 
 
 
 
 
 
17
  max_context_length = 750
18
 
19
  def format(history):
@@ -25,7 +36,7 @@ def format(history):
25
  else:
26
  prompt += f"{bot_token}{txt}"
27
  prompt += bot_token
28
- print(prompt)
29
  return prompt
30
 
31
  def remove_spaces_between_chinese(text):
@@ -133,9 +144,9 @@ def gradio(model, tokenizer):
133
  undo_btn = "↩️ Remove last turn",
134
  clear_btn = "➕ New conversation",
135
  examples=[
136
- ["给我5个英文名。", 100, 0.9, 0.95, 1.2, 1],
137
- ["给我讲一个笑话。", 50, 0.8, 0.9, 1.3, 6],
138
- ["Describe spring in english.", 50, 0.9, 1.0, 1, 5]
139
  ]
140
  )
141
 
 
7
 
8
  import itertools
9
  import regex as re
10
+ import logging
11
+
12
 
13
 
14
  user_token = "<User>"
 
16
  bos_token = "<BOS>"
17
  bot_token = "<Assistant>"
18
 
19
+
20
+ logger = logging.getLogger()
21
+ handler = logging.StreamHandler()
22
+ formatter = logging.Formatter(
23
+ '%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
24
+ handler.setFormatter(formatter)
25
+ logger.addHandler(handler)
26
+ logger.setLevel(logging.INFO)
27
+
28
  max_context_length = 750
29
 
30
  def format(history):
 
36
  else:
37
  prompt += f"{bot_token}{txt}"
38
  prompt += bot_token
39
+ logger.info(prompt)
40
  return prompt
41
 
42
  def remove_spaces_between_chinese(text):
 
144
  undo_btn = "↩️ Remove last turn",
145
  clear_btn = "➕ New conversation",
146
  examples=[
147
+ ["写一篇介绍人工智能的文章。", 30, 0.9, 0.95, 1.2, 5],
148
+ ["给我讲一个笑话。", 50, 0.8, 0.9, 1.2, 6],
149
+ ["Can you describe spring in English?", 50, 0.9, 1.0, 1, 5]
150
  ]
151
  )
152