IndexError: Cannot choose from an empty sequence // Werkzeug Debugger var CONSOLE_MODE = false, EVALEX = true, EVALEX_TRUSTED = false, SECRET = "Cztug1SITH6VWk19YYTC";
IndexError
IndexError: Cannot choose from an empty sequence
Traceback(most recent call last)
The above exception was the direct cause of the following exception:File "/usr/local/python3/lib/python3.7/site-packages/flask/app.py", line2551, in__call__
def __call__(self, environ: dict, start_response: t.Callable) -> t.Any:
"""The WSGI server calls the Flask application object as the
WSGI application. This calls :meth:`wsgi_app`, which can be
wrapped to apply middleware.
"""
return self.wsgi_app(environ, start_response)
File "/usr/local/python3/lib/python3.7/site-packages/flask/app.py", line2531, inwsgi_app
try:
ctx.push()
response = self.full_dispatch_request()
except Exception as e:
error = e
response = self.handle_exception(e)
except: # noqa: B001
error = sys.exc_info()[1]
raise
return response(environ, start_response)
finally:
File "/usr/local/python3/lib/python3.7/site-packages/flask/app.py", line2528, inwsgi_app
ctx = self.request_context(environ)
error: t.Optional[BaseException] = None
try:
try:
ctx.push()
response = self.full_dispatch_request()
except Exception as e:
error = e
response = self.handle_exception(e)
except: # noqa: B001
error = sys.exc_info()[1]
File "/usr/local/python3/lib/python3.7/site-packages/flask/app.py", line1825, infull_dispatch_request
request_started.send(self)
rv = self.preprocess_request()
if rv is None:
rv = self.dispatch_request()
except Exception as e:
rv = self.handle_user_exception(e)
return self.finalize_request(rv)
def finalize_request(
self,
rv: t.Union[ft.ResponseReturnValue, HTTPException],
File "/usr/local/python3/lib/python3.7/site-packages/flask/app.py", line1823, infull_dispatch_request
try:
request_started.send(self)
rv = self.preprocess_request()
if rv is None:
rv = self.dispatch_request()
except Exception as e:
rv = self.handle_user_exception(e)
return self.finalize_request(rv)
def finalize_request(
File "/usr/local/python3/lib/python3.7/site-packages/flask/app.py", line1799, indispatch_request
and req.method == "OPTIONS"
):
return self.make_default_options_response()
# otherwise dispatch to the handler for that endpoint
view_args: t.Dict[str, t.Any] = req.view_args # type: ignore[assignment]
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
def full_dispatch_request(self) -> Response:
"""Dispatches the request and on top of that performs request
pre and postprocessing as well as HTTP exception catching and
error handling.
File "/www/wwwroot/chat.py", line39, ingen_header
# post入参访问方式二:from-data(k-v)格式参数
@api.route('/gen_header', methods=['post'])
def gen_header():
wd = flask.request.values.get('wd')
future = executor.submit(do_heavy_work,wd)
return str(future.result())
def do_heavy_work(wd):
prompt = wd
#openai.api_key = api_key_list[-1]
openai.api_key = random.choice(api_key_list)
File "/usr/local/python3/lib/python3.7/concurrent/futures/_base.py", line435, inresult
self._condition.wait(timeout)
if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
raise CancelledError()
elif self._state == FINISHED:
return self.__get_result()
else:
raise TimeoutError()
def exception(self, timeout=None):
"""Return the exception raised by the call that the future represents.
File "/usr/local/python3/lib/python3.7/concurrent/futures/_base.py", line384, in__get_result
with self._condition:
return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]
def __get_result(self):
if self._exception:
raise self._exception
else:
return self._result
def add_done_callback(self, fn):
"""Attaches a callable that will be called when the future finishes.IndexError: Cannot choose from an empty sequence
This is the Copy/Paste friendly version of the traceback.
concurrent.futures.process._RemoteTraceback: """Traceback (most recent call last): File "/usr/local/python3/lib/python3.7/concurrent/futures/process.py", line 239, in _process_worker r = call_item.fn(*call_item.args, **call_item.kwargs) File "/www/wwwroot/chat.py", line 44, in do_heavy_work openai.api_key = random.choice(api_key_list) File "/usr/local/python3/lib/python3.7/random.py", line 261, in choice raise IndexError('Cannot choose from an empty sequence') from NoneIndexError: Cannot choose from an empty sequence"""The above exception was the direct cause of the following exception:Traceback (most recent call last): File "/usr/local/python3/lib/python3.7/site-packages/flask/app.py", line 2551, in __call__ return self.wsgi_app(environ, start_response) File "/usr/local/python3/lib/python3.7/site-packages/flask/app.py", line 2531, in wsgi_app response = self.handle_exception(e) File "/usr/local/python3/lib/python3.7/site-packages/flask/app.py", line 2528, in wsgi_app response = self.full_dispatch_request() File "/usr/local/python3/lib/python3.7/site-packages/flask/app.py", line 1825, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/python3/lib/python3.7/site-packages/flask/app.py", line 1823, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/python3/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "/www/wwwroot/chat.py", line 39, in gen_header return str(future.result()) File "/usr/local/python3/lib/python3.7/concurrent/futures/_base.py", line 435, in result return self.__get_result() File "/usr/local/python3/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result raise self._exceptionIndexError: Cannot choose from an empty sequenceThe debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error. If you enable JavaScript you can also use additional features such as code execution (if the evalex feature is enabled), automatic pasting of the exceptions and much more.Brought to you byDON'T PANIC, your friendly Werkzeug powered traceback interpreter.Console Locked
The console is locked and needs to be unlocked by entering the PIN. You can find the PIN printed out on the standard output of your shell that runs the server.
PIN:
如果你在街上随便问一个还未上学的小朋友,会背什么古诗。
隐娘完全想象得出答案:《锄禾》、《咏鹅》、《草》、《登鹳雀楼》。
这四首出镜率绝对最高。
确实,这四首古诗都收入了小学教材,成为儿童启蒙必背的古诗。
今天,隐娘想说的诗,是白居易的《草》。
白居易的《草》,全名《赋得古原草送别》,背后有一个“居长安不易”的故事流传甚广,诗的最后两句被南唐后主李煜化用成千古名句。
隐娘上小学时,这首诗入选小学课本,诗名叫《草》,当时,只有前四句,读来朗朗上口。
很多年以来,隐娘一直以为这首《草》诗就四句。长大后,才知道,这首诗有八句,全名为《赋得古原草送别》:
离离原上草,一岁一枯荣。
野火烧不尽,春风吹又生。
远芳侵古道,晴翠接荒城。
又送王孙去,萋萋满别情。
这首诗是白居易16岁时所作。
诗题中有“赋得”二字,按科考规矩,凡限定的诗题,题目前必须加“赋得”二字,作法与咏物诗相似。
可知这是白居易少年时准备应试的试帖诗习作,也就是说这是白居易模拟考试的作品。
离离原上草,一岁一枯荣。
这是一首送别诗,白居易安排了一个送别的典型环境:大地春回,芳草芊芊满草原。
原野上长满茂盛的青草,每年秋来枯黄,春天又绿色浓浓。
野草是一年生植物,春荣秋枯,岁岁循环不已。两个“一”字复叠,形成咏叹,又先状出一种生生不已的情味。

野火烧不尽,春风吹又生。
这是全诗的经典之句。
野草生命力顽强,野火燎原,瞬息后,大片枯草被烧得精光。
巨大的毁灭,让人生畏,可来年春天,春风一吹,野草顽强复苏,古原草恢复了勃勃生机。
柔弱的小草战胜了强大的烈火,小草积极的精神让人振奋。
远芳侵古道,晴翠接荒城。
在古道旁,小草散发着芬芳;在阳光下,青翠的小草连着荒城。
一个“侵”字,一个“接”字,再现了草顽强的生命力和古原草的生机勃勃。
又送王孙去,萋萋满别情。
最后两句点题,我在这里送友人归去,那萋萋的芳草尽是离别之情。
以草比离别之情,要知道,那连天的碧草,似乎每一片草叶都饱含别情。
可知这离愁别绪有多浓烈。
南唐后主李煜化用了白居易的这一句,写就了“离恨恰如春草,更行更远还生”的名句,读来意味不尽。
关于这首诗,还有一个流传很广的故事。
话说白居易初到长安参加科举考试的时候,拿着诗作去拜访当时的文坛盟主顾况。
顾况看了白居易的名字后,调侃道:年轻人,长安米价很贵,居此不容易哟。
说完之后,就翻看白居易的诗文,第一篇就是这首《赋得古原草送别》:
离离原上草,一岁一枯荣。
野火烧不尽,春风吹又生。
读完这四句,便不住地赞赏,对白居易说道:你写出这样句子,有这样的才华,住在长安,可是太容易了。
从此以后,顾况逢人就夸赞白居易的才华,白居易在长安的声名大噪。

可以说,这首诗已经成为国民诗词,几乎所有人都会背。
隐娘每当低落时,都会北背一背这首诗。
“野火烧不尽,春风吹又生”每每读来,让人感受到草的顽强与坚韧,这种坚韧通过诗句传到我们心中,让低落的心灵充满了力量。
诗词总有这样的魅力,能用简单而有力的语言,给我们以前进的力量。
版权声明:免责声明:本文来源网友投稿及网络整合仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。投诉邮箱:1765130767@qq.com.