ClueAI commited on
Commit
b8e17af
1 Parent(s): 9442824

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -9,7 +9,7 @@ model = T5ForConditionalGeneration.from_pretrained("ClueAI/ChatYuan-large-v2")
9
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
10
  model.to(device)
11
 
12
- base_info = "用户:你是谁?\n小元:我是元语智能公司研发的AI智能助手, 在不违反原则的情况下,我可以回答你的任何问题。"
13
  def preprocess(text):
14
  text = f"{base_info}{text}"
15
  text = text.replace("\n", "\\n").replace("\t", "\\t")
@@ -49,9 +49,9 @@ def chatyuan_bot(input, history):
49
 
50
  input_text = context + "\n用户:" + input + "\n小元:"
51
  output_text = answer(input_text)
52
- print("="*20)
53
  print(f"{input_text}\n{output_text}")
54
- print("="*20)
55
  history.append((input, output_text))
56
  #print(history)
57
  return history, history
@@ -103,9 +103,9 @@ def chatyuan_bot_api(api_key, input, history):
103
 
104
  input_text = context + "\n用户:" + input + "\n小元:"
105
  output_text = ChatYuan(api_key, input_text)
106
- print("="*20)
107
  print(f"api_key:{api_key}\n{input_text}\n{output_text}")
108
- print("="*20)
109
  history.append((input, output_text))
110
  #print(history)
111
  return history, history
 
9
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
10
  model.to(device)
11
 
12
+ base_info = "用户:你是谁?\n小元:我是元语智能公司研发的AI智能助手, 在不违反原则的情况下,我可以回答你的任何问题。\n"
13
  def preprocess(text):
14
  text = f"{base_info}{text}"
15
  text = text.replace("\n", "\\n").replace("\t", "\\t")
 
49
 
50
  input_text = context + "\n用户:" + input + "\n小元:"
51
  output_text = answer(input_text)
52
+ print("open_model".center(20, "="))
53
  print(f"{input_text}\n{output_text}")
54
+ #print("="*20)
55
  history.append((input, output_text))
56
  #print(history)
57
  return history, history
 
103
 
104
  input_text = context + "\n用户:" + input + "\n小元:"
105
  output_text = ChatYuan(api_key, input_text)
106
+ print("api".center(20, "="))
107
  print(f"api_key:{api_key}\n{input_text}\n{output_text}")
108
+ #print("="*20)
109
  history.append((input, output_text))
110
  #print(history)
111
  return history, history