Spaces:
Paused
Paused
Update app.py
Browse files
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 |
-
|
11 |
-
return
|
12 |
|
13 |
css = '''
|
14 |
.input_text, .output_text {
|
@@ -32,5 +35,5 @@ css = '''
|
|
32 |
}
|
33 |
'''
|
34 |
|
35 |
-
iface = gr.Interface(fn=chat, inputs="
|
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")
|