Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] gpt4free无法正常使用 #1328

Open
3 tasks done
liu2-3zhi opened this issue Mar 3, 2024 · 0 comments
Open
3 tasks done

[BUG] gpt4free无法正常使用 #1328

liu2-3zhi opened this issue Mar 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@liu2-3zhi
Copy link
Contributor

提交 issue 前,请先确认:

  • 我已看过 FAQ,此问题不在列表中
  • 我已看过其他 issue,他们不能解决我的问题
  • 我认为这不是 Mirai 或者 OpenAI 的 BUG

表现
gpt4free无法正常使用

运行环境:

  • 操作系统:linux

使用的时候收到了错误提示

2024-03-03 06:56:31.390 | INFO     | manager.bot:login_gpt4free:349 - 正在解析第 1  gpt4free 模型
2024-03-03 06:56:31.390 | ERROR    | manager.bot:login_gpt4free:355 - 解析失败2024-03-03 06:56:31.391 | ERROR    | manager.bot:login_gpt4free:356 - Cannot run the event loop while another loop is running
Traceback (most recent call last):

  File "/app/bot.py", line 14, in <module>
    loop.run_until_complete(botManager.login())
    │    │                  │          └ <function BotManager.login at 0x7fb8f62d8310>
    │    │                  └ <manager.bot.BotManager object at 0x7fb92b469450>
    │    └ <function BaseEventLoop.run_until_complete at 0x7fb92cb9c4c0><_UnixSelectorEventLoop running=True closed=False debug=False>

  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 636, in run_until_complete
    self.run_forever()
    │    └ <function BaseEventLoop.run_forever at 0x7fb92cb9c430><_UnixSelectorEventLoop running=True closed=False debug=False>
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 603, in run_forever
    self._run_once()
    │    └ <function BaseEventLoop._run_once at 0x7fb92cb9df30><_UnixSelectorEventLoop running=True closed=False debug=False>
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1909, in _run_once
    handle._run()
    │      └ <function Handle._run at 0x7fb92cb3d900><Handle <TaskStepMethWrapper object at 0x7fb92d1a7d90>()>
  File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
    │    │            │    │           │    └ <member '_args' of 'Handle' objects>
    │    │            │    │           └ <Handle <TaskStepMethWrapper object at 0x7fb92d1a7d90>()>
    │    │            │    └ <member '_callback' of 'Handle' objects>
    │    │            └ <Handle <TaskStepMethWrapper object at 0x7fb92d1a7d90>()>
    │    └ <member '_context' of 'Handle' objects><Handle <TaskStepMethWrapper object at 0x7fb92d1a7d90>()>

  File "/app/manager/bot.py", line 173, in login
    login_func()
    └ <bound method BotManager.login_gpt4free of <manager.bot.BotManager object at 0x7fb92b469450>>

> File "/app/manager/bot.py", line 351, in login_gpt4free
    if g4f_helper.g4f_check_account(account):
       │          │                 └ G4fModels(provider='g4f.Provider.Bing', model='gpt-4', alias='gpt-4', description='gpt4free的gpt-4')
       │          └ <function g4f_check_account at 0x7fb8fc53dea0><module 'adapter.gpt4free.g4f_helper' from '/app/adapter/gpt4free/g4f_helper.py'>

  File "/app/adapter/gpt4free/g4f_helper.py", line 11, in g4f_check_account
    response = g4f.ChatCompletion.create(
               │   │              └ <staticmethod(<function ChatCompletion.create at 0x7fb8f62a7ac0>)>
               │   └ <class 'g4f.ChatCompletion'><module 'g4f' from '/usr/local/lib/python3.10/site-packages/g4f/__init__.py'>

  File "/usr/local/lib/python3.10/site-packages/g4f/__init__.py", line 52, in create
    return result if stream else ''.join(result)
           │         │                   └ <generator object AsyncGeneratorProvider.create_completion at 0x7fb8f49885f0>
           │         └ False<generator object AsyncGeneratorProvider.create_completion at 0x7fb8f49885f0>
  File "/usr/local/lib/python3.10/site-packages/g4f/Provider/base_provider.py", line 93, in create_completion
    yield from run_generator(cls.create_async_generator(model, messages, stream=stream, **kwargs))
               │             │   │                      │      │                │         └ {}
               │             │   │                      │      │                └ False
               │             │   │                      │      └ [{'role': 'user', 'content': 'hello'}]
               │             │   │                      └ 'gpt-4'
               │             │   └ <staticmethod(<function Bing.create_async_generator at 0x7fb8fc2224d0>)>
               │             └ <class 'g4f.Provider.Bing.Bing'><function run_generator at 0x7fb8fc2211b0>
  File "/usr/local/lib/python3.10/site-packages/g4f/Provider/base_provider.py", line 122, in run_generator
    yield loop.run_until_complete(gen.__anext__())
          │    │                  │   └ <slot wrapper '__anext__' of 'async_generator' objects>
          │    │                  └ <async_generator object stream_generate at 0x7fb8f638b040>
          │    └ <function BaseEventLoop.run_until_complete at 0x7fb92cb9c4c0><_UnixSelectorEventLoop running=False closed=False debug=False>
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 625, in run_until_complete
    self._check_running()
    │    └ <function BaseEventLoop._check_running at 0x7fb92cb9c3a0><_UnixSelectorEventLoop running=False closed=False debug=False>
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 586, in _check_running
    raise RuntimeError(

RuntimeError: Cannot run the event loop while another loop is running
@liu2-3zhi liu2-3zhi added the bug Something isn't working label Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant