parse response
Browse files- modules/chat_func.py +5 -0
modules/chat_func.py
CHANGED
|
@@ -223,6 +223,9 @@ def predict_all(
|
|
| 223 |
False,
|
| 224 |
selected_model,
|
| 225 |
)
|
|
|
|
|
|
|
|
|
|
| 226 |
logging.info(f"初次响应推荐店铺:{response}")
|
| 227 |
# 将response中的店铺和菜名提取出来
|
| 228 |
import re
|
|
@@ -276,6 +279,8 @@ def predict_all(
|
|
| 276 |
True,
|
| 277 |
selected_model,
|
| 278 |
)
|
|
|
|
|
|
|
| 279 |
|
| 280 |
logging.info(f"得到食物中的营养成分:{response_ingredient}")
|
| 281 |
|
|
|
|
| 223 |
False,
|
| 224 |
selected_model,
|
| 225 |
)
|
| 226 |
+
response = json.loads(response.text)
|
| 227 |
+
response = response["choices"][0]["message"]["content"]
|
| 228 |
+
|
| 229 |
logging.info(f"初次响应推荐店铺:{response}")
|
| 230 |
# 将response中的店铺和菜名提取出来
|
| 231 |
import re
|
|
|
|
| 279 |
True,
|
| 280 |
selected_model,
|
| 281 |
)
|
| 282 |
+
response_ingredient = json.loads(response.text)
|
| 283 |
+
response_ingredient = response_ingredient["choices"][0]["message"]["content"]
|
| 284 |
|
| 285 |
logging.info(f"得到食物中的营养成分:{response_ingredient}")
|
| 286 |
|