Update app.py
Browse files
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']
|
| 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 |
-
|
| 73 |
-
|
| 74 |
-
return JSONResponse(content=
|
| 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")
|