Leiyan525 commited on
Commit
2ea8b8c
·
1 Parent(s): aab700e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -1,8 +1,8 @@
1
  import gradio as gr
2
  import openai
3
 
4
- # 初始化 chat_history 为空列表
5
- chat_history = []
6
 
7
  # 系统提示
8
  system_prompt = [
@@ -19,6 +19,8 @@ def clear(user_message, chat_history):
19
  # 响应用户消息
20
  def respond(openai_apikey, chat_history):
21
  openai.api_key = openai_apikey
 
 
22
  re_messages = system_prompt
23
  for chat in chat_history:
24
  re_messages.append({"role": "user", "content": chat[0]})
 
1
  import gradio as gr
2
  import openai
3
 
4
+
5
+
6
 
7
  # 系统提示
8
  system_prompt = [
 
19
  # 响应用户消息
20
  def respond(openai_apikey, chat_history):
21
  openai.api_key = openai_apikey
22
+ if chat_history is None:
23
+ chat_history = []
24
  re_messages = system_prompt
25
  for chat in chat_history:
26
  re_messages.append({"role": "user", "content": chat[0]})