souljoy commited on
Commit
bb75b27
1 Parent(s): 18ed61d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -54,6 +54,10 @@ def chat_pdf_ep(content: Text = None):
54
  }
55
  ]
56
  obj = json.loads(content.content)
 
 
 
 
57
  messages.append({"role": "user", "content": obj['question'] + '\n根据以下文章回答:\n' + obj['doc']})
58
  data = {
59
  "model": "gpt-3.5-turbo",
@@ -81,4 +85,4 @@ def embeddings_ep(content: Text = None):
81
  data=json.dumps(data),
82
  headers=headers
83
  )
84
- return JSONResponse(content=result.json())
 
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",
 
85
  data=json.dumps(data),
86
  headers=headers
87
  )
88
+ return JSONResponse(content=result.json())