souljoy commited on
Commit
5df5961
1 Parent(s): c995ecb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -54,11 +54,12 @@ def chat_pdf_ep(content: Text = None):
54
  }
55
  ]
56
  obj = json.loads(content.content)
 
57
  history = obj['history']
58
  for his in history:
59
  messages.append({"role": "user", "content": his[0]})
60
  messages.append({"role": "assistant", "content": his[1]})
61
- messages.append({"role": "user", "content": obj['question'] + '\n根据以下文章回答:\n' + obj['doc']})
62
  data = {
63
  "model": "gpt-3.5-turbo",
64
  "messages": messages
@@ -69,9 +70,9 @@ def chat_pdf_ep(content: Text = None):
69
  headers=headers
70
  )
71
  res = str(result.json()['choices'][0]['message']['content']).strip()
72
- print('res:', res)
73
- res = {'content': res}
74
- return JSONResponse(content=res)
75
 
76
 
77
  @app.post("/embeddings")
 
54
  }
55
  ]
56
  obj = json.loads(content.content)
57
+ messages.append({"role": "system", "content": "文章内容:\n"+obj['doc']})
58
  history = obj['history']
59
  for his in history:
60
  messages.append({"role": "user", "content": his[0]})
61
  messages.append({"role": "assistant", "content": his[1]})
62
+ messages.append({"role": "user", "content": obj['question']})
63
  data = {
64
  "model": "gpt-3.5-turbo",
65
  "messages": messages
 
70
  headers=headers
71
  )
72
  res = str(result.json()['choices'][0]['message']['content']).strip()
73
+ content = {'content': res}
74
+ print('content:', content)
75
+ return JSONResponse(content=content)
76
 
77
 
78
  @app.post("/embeddings")