Wendyy commited on
Commit
64e3877
·
1 Parent(s): 0688f0f

Update modules/chat_func.py

Browse files
Files changed (1) hide show
  1. modules/chat_func.py +61 -61
modules/chat_func.py CHANGED
@@ -216,15 +216,15 @@ def predict_all(
216
  # logging.info(f"system_prompt:{system_prompt}")
217
  # logging.info(f"history:{history}")
218
  # # 如果能传入index,则此处里获得初筛后的店铺和菜名
219
- # response = get_response(
220
- # openai_api_key,
221
- # system_prompt,
222
- # history,
223
- # temperature,
224
- # top_p,
225
- # False,
226
- # selected_model,
227
- # )
228
  # response = json.loads(response.text)
229
  # logging.info(f"初次响应推荐店铺:{response}")
230
  # response = response["choices"][0]["message"]["content"]
@@ -258,68 +258,68 @@ def predict_all(
258
  #
259
  # dishes = '、'.join(dishes)
260
 
261
- dishes = "半熟芝士拿铁、白桃半熟芝士拿铁、招牌烤全羊、羊肉串"
262
 
263
- # 将初筛后的店铺和菜品送入构建好的CoT
264
- prompt_with_ingredient = f"""
265
- 我需要你推测一些菜可能的原料以及其营养成分,输出格式如下:
266
- -----------------------
267
- 菜品名称:[]
268
- 菜品原料:[原料1,原料2...]
269
- 营养成分:[成分(含量)]
270
- -----------------------
271
- 注意,其中营养成分包括蛋白质、脂肪、碳水化合物、纤维素、维生素等,你可以根据你的知识添加其他成分。营养成分的含量分为无、低、中、高四个等级,需要填在成分后的括号内。
272
- 以下是需要你推测的菜品名称,不同菜品用顿号隔开:
273
- -----------------------
274
- {dishes}
275
- -----------------------
276
- 每个菜品按照以上格式分开回复,但是注意,除了以上格式的内容,不要回复其他内容。
277
- """
278
 
279
- logging.info(f"分析食物中营养成分的prompt构建完成:{prompt_with_ingredient}")
280
 
281
 
282
- history_ingredient=[]
283
- history_ingredient.append(construct_user(prompt_with_ingredient))
284
- history_ingredient.append(construct_assistant(""))
285
 
286
- logging.info(f"history_ingredient:{history_ingredient}")
287
 
288
- response_ingredient = get_response(
289
- openai_api_key,
290
- "你是一个营养分析专家",
291
- history_ingredient,
292
- temperature,
293
- top_p,
294
- True,
295
- selected_model,
296
- )
297
- response_ingredient = json.loads(response_ingredient.text)
298
- response_ingredient = response_ingredient["choices"][0]["message"]["content"]
299
 
300
- logging.info(f"得到食物中的营养成分:{response_ingredient}")
301
 
302
- prompt_rec = f"""
303
- 以下是一些菜品名称和所属的店铺,我需要你根据我的需求从其中推荐��家店铺的一种或多种菜品,并给出推荐的理由。我的需求为:我有糖尿病,而且今天不想吃太油腻的食物。
304
- -----------------------
305
- {response_ingredient}
306
- -----------------------
307
- """
308
- history_rec = []
309
- history_rec.append(construct_user(prompt_rec))
310
- history_rec.append(construct_assistant(""))
311
 
312
- logging.info(f"history_rec:{history_rec}")
313
 
314
- response = get_response(
315
- openai_api_key,
316
- "你是一个美食推荐家",
317
- history_rec,
318
- temperature,
319
- top_p,
320
- True,
321
- selected_model,
322
- )
323
  except requests.exceptions.ConnectTimeout:
324
  status_text = (
325
  standard_error_msg + connection_timeout_prompt + error_retrieve_prompt
 
216
  # logging.info(f"system_prompt:{system_prompt}")
217
  # logging.info(f"history:{history}")
218
  # # 如果能传入index,则此处里获得初筛后的店铺和菜名
219
+ response = get_response(
220
+ openai_api_key,
221
+ system_prompt,
222
+ history,
223
+ temperature,
224
+ top_p,
225
+ False,
226
+ selected_model,
227
+ )
228
  # response = json.loads(response.text)
229
  # logging.info(f"初次响应推荐店铺:{response}")
230
  # response = response["choices"][0]["message"]["content"]
 
258
  #
259
  # dishes = '、'.join(dishes)
260
 
261
+ # dishes = "半熟芝士拿铁、白桃半熟芝士拿铁、招牌烤全羊、羊肉串"
262
 
263
+ # # 将初筛后的店铺和菜品送入构建好的CoT
264
+ # prompt_with_ingredient = f"""
265
+ # 我需要你推测一些菜可能的原料以及其营养成分,输出格式如下:
266
+ # -----------------------
267
+ # 菜品名称:[]
268
+ # 菜品原料:[原料1,原料2...]
269
+ # 营养成分:[成分(含量)]
270
+ # -----------------------
271
+ # 注意,其中营养成分包括蛋白质、脂肪、碳水化合物、纤维素、维生素等,你可以根据你的知识添加其他成分。营养成分的含量分为无、低、中、高四个等级,需要填在成分后的括号内。
272
+ # 以下是需要你推测的菜品名称,不同菜品用顿号隔开:
273
+ # -----------------------
274
+ # {dishes}
275
+ # -----------------------
276
+ # 每个菜品按照以上格式分开回复,但是注意,除了以上格式的内容,不要回复其他内容。
277
+ # """
278
 
279
+ # logging.info(f"分析食物中营养成分的prompt构建完成:{prompt_with_ingredient}")
280
 
281
 
282
+ # history_ingredient=[]
283
+ # history_ingredient.append(construct_user(prompt_with_ingredient))
284
+ # history_ingredient.append(construct_assistant(""))
285
 
286
+ # logging.info(f"history_ingredient:{history_ingredient}")
287
 
288
+ # response_ingredient = get_response(
289
+ # openai_api_key,
290
+ # "你是一个营养分析专家",
291
+ # history_ingredient,
292
+ # temperature,
293
+ # top_p,
294
+ # True,
295
+ # selected_model,
296
+ # )
297
+ # response_ingredient = json.loads(response_ingredient.text)
298
+ # response_ingredient = response_ingredient["choices"][0]["message"]["content"]
299
 
300
+ # logging.info(f"得到食物中的营养成分:{response_ingredient}")
301
 
302
+ # prompt_rec = f"""
303
+ # 以下是一些菜品名称和所属的店铺,我需要你根据我的需求从其中推荐一家店铺的一种或多种菜品,并给出推荐的理由。我的需求为:我有糖尿病,而且今天不想吃太油腻的食物。
304
+ # -----------------------
305
+ # {response_ingredient}
306
+ # -----------------------
307
+ # """
308
+ # history_rec = []
309
+ # history_rec.append(construct_user(prompt_rec))
310
+ # history_rec.append(construct_assistant(""))
311
 
312
+ # logging.info(f"history_rec:{history_rec}")
313
 
314
+ # response = get_response(
315
+ # openai_api_key,
316
+ # "你是一个美食推荐家",
317
+ # history_rec,
318
+ # temperature,
319
+ # top_p,
320
+ # True,
321
+ # selected_model,
322
+ # )
323
  except requests.exceptions.ConnectTimeout:
324
  status_text = (
325
  standard_error_msg + connection_timeout_prompt + error_retrieve_prompt