EdgeGPT
EdgeGPT copied to clipboard
Python依赖环境版本和cookie.json模板问题
麻烦先看下运行报错问题吧:
Traceback (most recent call last):
File "/home/lemu/Documents/Dingding_Bot_Chatgpt/main/edge_gpt.py", line 34, in <module>
asyncio.run(main())
File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/home/lemu/Documents/Dingding_Bot_Chatgpt/main/edge_gpt.py", line 27, in main
bot = Chatbot(cookies=newbing_cookie)
File "/usr/local/lib/python3.8/dist-packages/EdgeGPT.py", line 325, in __init__
Conversation(self.cookiePath, self.cookies, self.proxy)
File "/usr/local/lib/python3.8/dist-packages/EdgeGPT.py", line 214, in __init__
self.session.cookies.set(cookie["name"], cookie["value"])
TypeError: string indices must be integers
- 出现这个问题是我去升级了
prompt_toolkit
这个包,由于没有提示使用什么版本,我直接更新了最新的版本,然后运行就报这样的错误了 -
cookie.json
至少提供一个模板吧,方便查看使用该文件格式和替换里面的内容,不然提示TypeError: string indices must be integers
,感觉用下来还有很多问题要解决,辛苦作者可以解决这些小问题,感谢。
贴上主函数的代码:
import asyncio
import json
import os
from EdgeGPT import Chatbot
# 配置文件路径
config_path = os.path.join(os.path.dirname(__file__), "config.json")
# 读取配置文件
with open(config_path, 'r', encoding='utf8') as f:
config = json.load(f)
newbing_cookie = config['NewBingCookie']
async def main():
bot = Chatbot(cookies=newbing_cookie)
resp = await bot.ask(prompt="Hello, are you an AI?")
print(resp['item']['messages'])
await bot.close()
if __name__ == "__main__":
asyncio.run(main())
cookie.json是访问bing.com时用浏览器插件Cookie-Editor导出来的,重定向也没事儿,只要你之前成功登陆过就可以。你要是之前没登陆过。那就比较麻烦了应该
cookie.json
不是直接Cookie-Editor导出来就行吗。你这步是干啥newbing_cookie = config['NewBingCookie']
,直接bot = Chatbot(cookies=config)
就行了,而且prompt_toolkit
依赖应该不影响,我现在也是最新的
This issue is stale because it has been open for 2 days with no activity.
This issue was closed because it has been inactive for 3 days since being marked as stale.