add CoT
Browse files- modules/chat_func.py +42 -40
modules/chat_func.py
CHANGED
@@ -213,50 +213,52 @@ def predict_all(
|
|
213 |
else:
|
214 |
all_token_counts.append(count_token(construct_user(inputs)))
|
215 |
try:
|
216 |
-
logging.info(f"system_prompt๏ผ{system_prompt}")
|
217 |
-
logging.info(f"history๏ผ{history}")
|
218 |
-
# ๅฆๆ่ฝไผ ๅ
ฅindex๏ผๅๆญคๅค้่ทๅพๅ็ญๅ็ๅบ้บๅ่ๅ
|
219 |
-
response = get_response(
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
)
|
228 |
-
response = json.loads(response.text)
|
229 |
-
logging.info(f"ๅๆฌกๅๅบๆจ่ๅบ้บ๏ผ{response}")
|
230 |
-
response = response["choices"][0]["message"]["content"]
|
231 |
-
|
232 |
-
logging.info(f"ๅๆฌกๅๅบๆจ่ๅบ้บ๏ผ{response}")
|
233 |
-
# ๅฐresponseไธญ็ๅบ้บๅ่ๅๆๅๅบๆฅ
|
234 |
-
import re
|
235 |
-
|
236 |
-
# text = """
|
237 |
-
# ๅฅฝ็๏ผ้ๅฏนๆจๆณๅ้ฉๅผ็ค่็้ๆฑ๏ผๆๅๆจๆจ่ไปฅไธๅบ้บๅ่ๅ๏ผ
|
238 |
#
|
239 |
-
#
|
|
|
|
|
240 |
#
|
241 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
#
|
243 |
-
#
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
dishes
|
256 |
-
|
257 |
-
|
258 |
|
259 |
-
dishes =
|
260 |
|
261 |
# ๅฐๅ็ญๅ็ๅบ้บๅ่ๅ้ๅ
ฅๆๅปบๅฅฝ็CoT
|
262 |
prompt_with_ingredient = f"""
|
|
|
213 |
else:
|
214 |
all_token_counts.append(count_token(construct_user(inputs)))
|
215 |
try:
|
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"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
#
|
232 |
+
# logging.info(f"ๅๆฌกๅๅบๆจ่ๅบ้บ๏ผ{response}")
|
233 |
+
# # ๅฐresponseไธญ็ๅบ้บๅ่ๅๆๅๅบๆฅ
|
234 |
+
# import re
|
235 |
#
|
236 |
+
# # text = """
|
237 |
+
# # ๅฅฝ็๏ผ้ๅฏนๆจๆณๅ้ฉๅผ็ค่็้ๆฑ๏ผๆๅๆจๆจ่ไปฅไธๅบ้บๅ่ๅ๏ผ
|
238 |
+
# #
|
239 |
+
# # ๅบ้บๅ็งฐ๏ผโ้ๅนด็ค่ๅบโ ๆจ่่ๅ๏ผ็ค็่ใ็ค็ช่ใ็ค็พ่
|
240 |
+
# #
|
241 |
+
# # ๅบ้บๅ็งฐ๏ผโ่ฅฟ่ฅฟ้็ค่ๅบโ ๆจ่่ๅ๏ผ็ค็่ไธฒใ็คๆ้ชจใ็ค้ธก่
|
242 |
+
# #
|
243 |
+
# # ๅบ้บๅ็งฐ๏ผโ้ฉๅผ็ค่ๅบโ ๆจ่่ๅ๏ผ็ณ้
ๆ้ฅญใ้ๆฟ็งใ็ค็่"""
|
244 |
#
|
245 |
+
# pattern = r'ๅบ้บๅ็งฐ๏ผ(.+?) ๆจ่่ๅ๏ผ(.+)ใ'
|
246 |
+
#
|
247 |
+
# results = re.findall(pattern, response)
|
248 |
+
#
|
249 |
+
# dicts = {}
|
250 |
+
# import string
|
251 |
+
# for result in results:
|
252 |
+
# dicts[result[0]] = result[1].split('ใ')
|
253 |
+
#
|
254 |
+
# logging.info(f"ๅ็ญๅ็ๅบ้บๅ่ๅ๏ผ{dicts}")
|
255 |
+
# dishes = []
|
256 |
+
# for restaurant, dish in dicts.items():
|
257 |
+
# dishes.extend(dish)
|
258 |
+
#
|
259 |
+
# dishes = 'ใ'.join(dishes)
|
260 |
|
261 |
+
dishes = "ๅ็่ๅฃซๆฟ้ใ็ฝๆกๅ็่ๅฃซๆฟ้ใๆ็็คๅ
จ็พใ็พ่ไธฒ"
|
262 |
|
263 |
# ๅฐๅ็ญๅ็ๅบ้บๅ่ๅ้ๅ
ฅๆๅปบๅฅฝ็CoT
|
264 |
prompt_with_ingredient = f"""
|