clarkchan commited on
Commit
a169d7c
1 Parent(s): 556b1ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -3,12 +3,15 @@ import requests
3
  #from transformers import AutoTokenizer
4
  #tokenizer = AutoTokenizer.from_pretrained("liam168/c2-roberta-base-finetuned-dianping-chinese")
5
  def chat(input):
 
6
  url = 'http://dark.21cnai.com:5000/api/chat'
7
  data = { "message": input }
8
  headers = {"Content-Type": "Application/json","Authorization":"Bearer kdfjwoieskdflasdnf"}
 
 
9
  response = requests.post(url, json=data, headers=headers)
10
- print(response.text)
11
- return response.text
12
 
13
  css = '''
14
  .input_text, .output_text {
@@ -32,5 +35,5 @@ css = '''
32
  }
33
  '''
34
 
35
- iface = gr.Interface(fn=chat, inputs="text", outputs="text",css=css)
36
  iface.launch(server_name="0.0.0.0")
 
3
  #from transformers import AutoTokenizer
4
  #tokenizer = AutoTokenizer.from_pretrained("liam168/c2-roberta-base-finetuned-dianping-chinese")
5
  def chat(input):
6
+ global conversation_history
7
  url = 'http://dark.21cnai.com:5000/api/chat'
8
  data = { "message": input }
9
  headers = {"Content-Type": "Application/json","Authorization":"Bearer kdfjwoieskdflasdnf"}
10
+ response = f"您说:{input_text}\n"
11
+ conversation_history += response
12
  response = requests.post(url, json=data, headers=headers)
13
+ conversation_history += ”chatGPT:"+response.text
14
+ return conversation_history
15
 
16
  css = '''
17
  .input_text, .output_text {
 
35
  }
36
  '''
37
 
38
+ iface = gr.Interface(fn=chat, inputs=gr.inputs.Textbox(lines=3, placeholder="在此输入您的问题..."), outputs=gr.outputs.Textbox(),title="ChatGPT 对话",description="请输入您的问题,然后按回车键或单击提交。",css=css)
39
  iface.launch(server_name="0.0.0.0")