rewrite my prompt
Browse files- modules/chat_func.py +11 -3
modules/chat_func.py
CHANGED
@@ -273,16 +273,20 @@ def predict_all(
|
|
273 |
|
274 |
logging.info(f"分析食物中营养成分的prompt构建完成:{prompt_with_ingredient}")
|
275 |
|
|
|
|
|
|
|
|
|
276 |
response_ingredient = get_response(
|
277 |
openai_api_key,
|
278 |
"",
|
279 |
-
|
280 |
temperature,
|
281 |
top_p,
|
282 |
True,
|
283 |
selected_model,
|
284 |
)
|
285 |
-
response_ingredient = json.loads(
|
286 |
response_ingredient = response_ingredient["choices"][0]["message"]["content"]
|
287 |
|
288 |
logging.info(f"得到食物中的营养成分:{response_ingredient}")
|
@@ -292,10 +296,14 @@ def predict_all(
|
|
292 |
|
293 |
{response_ingredient}
|
294 |
"""
|
|
|
|
|
|
|
|
|
295 |
response = get_response(
|
296 |
openai_api_key,
|
297 |
"",
|
298 |
-
|
299 |
temperature,
|
300 |
top_p,
|
301 |
True,
|
|
|
273 |
|
274 |
logging.info(f"分析食物中营养成分的prompt构建完成:{prompt_with_ingredient}")
|
275 |
|
276 |
+
history_ingredient=[]
|
277 |
+
history_ingredient.append(construct_user(prompt_with_ingredient))
|
278 |
+
history_ingredient.append(construct_assistant(""))
|
279 |
+
|
280 |
response_ingredient = get_response(
|
281 |
openai_api_key,
|
282 |
"",
|
283 |
+
history_ingredient,
|
284 |
temperature,
|
285 |
top_p,
|
286 |
True,
|
287 |
selected_model,
|
288 |
)
|
289 |
+
response_ingredient = json.loads(response_ingredient.text)
|
290 |
response_ingredient = response_ingredient["choices"][0]["message"]["content"]
|
291 |
|
292 |
logging.info(f"得到食物中的营养成分:{response_ingredient}")
|
|
|
296 |
|
297 |
{response_ingredient}
|
298 |
"""
|
299 |
+
history_rec = []
|
300 |
+
history_rec.append(construct_user(prompt_rec))
|
301 |
+
history_rec.append(construct_assistant(""))
|
302 |
+
|
303 |
response = get_response(
|
304 |
openai_api_key,
|
305 |
"",
|
306 |
+
history_rec,
|
307 |
temperature,
|
308 |
top_p,
|
309 |
True,
|