circlestarzero/EX-chatGPT

Dictionary Changed Size Duration Iteration

Yikai-Liao opened this issue · 4 comments

我在使用web模式时卡死,日志中出现如下报错

Chat history backup completed: chathistory_backup_20230323-1027.json
API calls: {'calls': [{'API': 'Google', 'query': '苏剑林 科学空间 LLMDecoder-only的架构 文章'}, {'API': 'WikiSearch', 'query': '苏剑林'}, {'API': 'Google', 'query': 'LLMDecoder-only的架构是什么?'}]}

Debugging middleware caught exception in streamed response at a point where response headers were already sent.
Traceback (most recent call last):
  File "/app/chatGPTEx/search.py", line 82, in detail
    call_res1 = search(APIExtraQuery(query,call_res0),1000)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/chatGPTEx/search.py", line 270, in search
    for key,value in call_res.items():
RuntimeError: dictionary changed size during iteration
127.0.0.1 - - [23/Mar/2023 10:27:00] "GET /api/query?mode=detail&uuid=da98b1a1-8719-4b44-89b3-14044dfc1145&prompt=&msg=给我介绍一下苏剑林在科学空间中发的《为什么现在的LLM都是Decoder-only的架构?》这篇文章 HTTP/1.1" 200 -
Chat history backup completed: chathistory_backup_20230323-1027.json
127.0.0.1 - - [23/Mar/2023 10:27:00] "POST /api/addChat HTTP/1.1" 200 -

阅读源代码后,应该是这段代码出现了问题

# File "/app/chatGPTEx/search.py", line 270, in search
for key,value in call_res.items():
    if len(str(value)) < 10:
        del call_res[key]

建议直接使用字典推导来实现这个功能

call_res = {key: value for key, value in call_res.items() if len(str(value)) >= 10}

阅读了其他issue后,发现与 #31 遇到的是同一个问题,但是这个问题与apiproxy没有任何关系,单纯是python语法的问题。@circlestarzero

是否能更新一次docker镜像?或者为docker镜像增加自动更新。这次提交目前还没有更新到docker hub

已经更新了,感谢