souljoy commited on
Commit
7588dc2
1 Parent(s): e0e4bcd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -39
app.py CHANGED
@@ -75,44 +75,6 @@ def chat_pdf_ep(content: Text = None):
75
  return JSONResponse(content=content)
76
 
77
 
78
- @app.post("/dic")
79
- def dic_ep(content: Text = None):
80
- url = 'https://api.openai.com/v1/chat/completions'
81
- messages = [
82
- {
83
- "role": "system",
84
- "content": "你是小鹏汽车数据智能中心(简称DIC)的IT服务台的智能助手"
85
- + "根据提供的参考文章,生成文本来回答问题。答案包含参考文章内容中HTML样式的图片、网址、超链接。准确、有用、清晰。"
86
- + "模仿提供的参考对话来有用的回复用户,进行多轮对话。"
87
- + "根据参考文章和参考对话来回答用户的IT类问题,无法回答非IT类问题。"
88
- + "你是一个对话机器人,无法提供对话之外的服务(如远程协助、到现场解决故障等)。用户有对话之外服务的需求,请回复他:正在转人工。"
89
- }
90
- ]
91
- obj = json.loads(content.content)
92
- if 'ref_doc' in obj:
93
- messages.append({"role": "system", "content": "参考文章:\n" + obj['ref_doc']})
94
- if 'ref_dialog' in obj:
95
- messages.append({"role": "system", "content": "参考对话:\n" + obj['ref_dialog']})
96
- history = obj['history']
97
- for his in history:
98
- messages.append({"role": "user", "content": his[0]})
99
- messages.append({"role": "assistant", "content": his[1]})
100
- messages.append({"role": "user", "content": obj['question']})
101
- data = {
102
- "model": "gpt-3.5-turbo",
103
- "messages": messages
104
- }
105
- print("messages = \n", messages)
106
- result = requests.post(url=url,
107
- data=json.dumps(data),
108
- headers=headers
109
- )
110
- res = str(result.json()['choices'][0]['message']['content']).strip()
111
- content = {'content': res}
112
- print('content:', content)
113
- return JSONResponse(content=content)
114
-
115
-
116
  @app.post("/sale")
117
  def sale_ep(content: Text = None):
118
  url = 'https://api.openai.com/v1/chat/completions'
@@ -144,7 +106,7 @@ def sale_ep(content: Text = None):
144
  return JSONResponse(content=content)
145
 
146
 
147
- @app.post("/chat_gpt")
148
  def chat_gpt_ep(content: Text = None):
149
  url = 'https://api.openai.com/v1/chat/completions'
150
  obj = json.loads(content.content)
 
75
  return JSONResponse(content=content)
76
 
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  @app.post("/sale")
79
  def sale_ep(content: Text = None):
80
  url = 'https://api.openai.com/v1/chat/completions'
 
106
  return JSONResponse(content=content)
107
 
108
 
109
+ @app.post("/chatgpt")
110
  def chat_gpt_ep(content: Text = None):
111
  url = 'https://api.openai.com/v1/chat/completions'
112
  obj = json.loads(content.content)