Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import os
|
2 |
|
3 |
-
|
4 |
import requests
|
5 |
import json
|
6 |
import gradio as gr
|
@@ -18,7 +18,7 @@ headers = {
|
|
18 |
|
19 |
def predict(msg, history=[]):
|
20 |
messages = [{"role": "system", "content": "你是小鹏汽车的数据智能中心(DIC)的智能助手小D"}]
|
21 |
-
for i in range(len(history) - 1, max(0, len(history) - 3)):
|
22 |
messages.append({"role": "user", "content": history[i][0]})
|
23 |
messages.append({"role": "assistant", "content": history[i][1]})
|
24 |
messages.append({"role": "user", "content": msg})
|
@@ -40,10 +40,11 @@ with gr.Blocks() as demo:
|
|
40 |
chatbot = gr.Chatbot()
|
41 |
state = gr.State([])
|
42 |
|
43 |
-
with gr.
|
44 |
txt = gr.Textbox(label='输入框', placeholder='输入内容...')
|
45 |
bu = gr.Button(value='发送')
|
46 |
-
|
|
|
47 |
|
48 |
bu.click(predict, [txt, state], [chatbot, state, answer_text])
|
49 |
|
|
|
1 |
import os
|
2 |
|
3 |
+
os.system('git clone https://huggingface.co/souljoy/chatGPT')
|
4 |
import requests
|
5 |
import json
|
6 |
import gradio as gr
|
|
|
18 |
|
19 |
def predict(msg, history=[]):
|
20 |
messages = [{"role": "system", "content": "你是小鹏汽车的数据智能中心(DIC)的智能助手小D"}]
|
21 |
+
for i in range(len(history) - 1, max(0, len(history) - 3), -1):
|
22 |
messages.append({"role": "user", "content": history[i][0]})
|
23 |
messages.append({"role": "assistant", "content": history[i][1]})
|
24 |
messages.append({"role": "user", "content": msg})
|
|
|
40 |
chatbot = gr.Chatbot()
|
41 |
state = gr.State([])
|
42 |
|
43 |
+
with gr.Column():
|
44 |
txt = gr.Textbox(label='输入框', placeholder='输入内容...')
|
45 |
bu = gr.Button(value='发送')
|
46 |
+
with gr.Column():
|
47 |
+
answer_text = gr.Textbox(label='回复')
|
48 |
|
49 |
bu.click(predict, [txt, state], [chatbot, state, answer_text])
|
50 |
|