Liusuthu commited on
Commit
514b9d3
1 Parent(s): a1a92cb

Update chat.py

Browse files
Files changed (1) hide show
  1. chat.py +12 -14
chat.py CHANGED
@@ -5,19 +5,7 @@ import gradio as gr
5
  OpenAI.api_key = os.getenv("OPENAI_API_KEY")
6
  api_key = os.getenv("OPENAI_API_KEY")
7
  client = OpenAI(api_key=api_key)
8
- completion = client.chat.completions.create(
9
- model="gpt-3.5-turbo",
10
- messages=[
11
- {
12
- "role": "system",
13
- "content": "你是一个专业的中国心理医生,你的所有内容都需要用【中文】回答,你必须对你的患者耐心,你需要以【朋友】的身份和患者交流,这意味着你需要用更加【口语化】的文字回答,并且【不要长篇大论】,更【不要分点作答】。",
14
- },
15
- {
16
- "role": "user",
17
- "content": question,
18
- },
19
- ],
20
- )
21
 
22
 
23
  def predict(message, history):
@@ -28,7 +16,17 @@ def predict(message, history):
28
  history_openai_format.append({"role": "user", "content": message})
29
 
30
  response = client.chat.completions.create(model='gpt-3.5-turbo',
31
- messages= history_openai_format,
 
 
 
 
 
 
 
 
 
 
32
  temperature=1.0,
33
  stream=True)
34
 
 
5
  OpenAI.api_key = os.getenv("OPENAI_API_KEY")
6
  api_key = os.getenv("OPENAI_API_KEY")
7
  client = OpenAI(api_key=api_key)
8
+
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
 
11
  def predict(message, history):
 
16
  history_openai_format.append({"role": "user", "content": message})
17
 
18
  response = client.chat.completions.create(model='gpt-3.5-turbo',
19
+ # messages= history_openai_format,
20
+ messages=[
21
+ {
22
+ "role": "system",
23
+ "content": "你是一个专业的中国心理医生,你的所有内容都需要用【中文】回答,你必须对你的患者耐心,你需要以【朋友】的身份和患者交流,这意味着你需要用更加【口语化】的文字回答,并且【不要长篇大论】,更【不要分点作答】。",
24
+ },
25
+ {
26
+ "role": "user",
27
+ "content": question,
28
+ },
29
+ ],
30
  temperature=1.0,
31
  stream=True)
32