From c2c6071c14a356ebd53c483fc963a3a7255053a6 Mon Sep 17 00:00:00 2001 From: dylan <58234511@qq.com> Date: Thu, 20 Apr 2023 13:44:13 +0800 Subject: [PATCH] 1 --- jd_comment.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jd_comment.py b/jd_comment.py index 1471e58..a7979d4 100644 --- a/jd_comment.py +++ b/jd_comment.py @@ -18,7 +18,7 @@ import random import sys import time,re import urllib.parse - +import jdspider try: import jieba # just for linting @@ -27,7 +27,7 @@ try: #import yaml from lxml import etree import zhon.hanzi - import openai + except: print('解决依赖问题...稍等') os.system('pip3 install lxml &> /dev/null') @@ -42,8 +42,13 @@ except: import requests import openai -import jdspider - +if "OPENAI_API_KEY" in os.environ: + print('已启用AI评价'); + try: + import openai + except: + print('安装openai模块') + os.system('pip3 install openai &> /dev/null') # constants CONFIG_PATH = './config.yml'