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

gpt-4-turbo unusable, help needed #1942

Closed
AIUSRTMP opened this issue May 12, 2024 · 4 comments
Closed

gpt-4-turbo unusable, help needed #1942

AIUSRTMP opened this issue May 12, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@AIUSRTMP
Copy link

I couldn't use the gpt-4-turbo through bing provider, I use the newest package code and the error is

D:\Anaconda\envs\Evaluator\python.exe MAE\tmp.py 
Failed to check g4f version: Version not found
Traceback (most recent call last):
  File "MAE\tmp.py", line 22, in <module>
    message=handle_chat(prompt)
            ^^^^^^^^^^^^^^^^^^^
  File "MAE\tmp.py", line 14, in handle_chat
    response = client.chat.completions.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "MAE\g4f\client\client.py", line 114, in create
    return response if stream else next(response)
                                   ^^^^^^^^^^^^^^
  File "MAE\g4f\client\client.py", line 53, in iter_append_model_and_provider
    for chunk in response:
  File "MAE\g4f\client\client.py", line 28, in iter_response
    for idx, chunk in enumerate(response):
  File "MAE\g4f\providers\base_provider.py", line 216, in create_completion
    yield loop.run_until_complete(await_callback(gen.__anext__))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Anaconda\envs\Evaluator\Lib\site-packages\nest_asyncio.py", line 98, in run_until_complete
    return f.result()
           ^^^^^^^^^^
  File "D:\Anaconda\envs\Evaluator\Lib\asyncio\futures.py", line 203, in result
    raise self._exception.with_traceback(self._exception_tb)
  File "D:\Anaconda\envs\Evaluator\Lib\asyncio\tasks.py", line 277, in __step
    result = coro.send(None)
             ^^^^^^^^^^^^^^^
  File "MAE\g4f\providers\base_provider.py", line 45, in await_callback
    return await callback()
           ^^^^^^^^^^^^^^^^
  File "MAE\g4f\Provider\Bing.py", line 421, in stream_generate
    conversation = await create_conversation(session, headers, tone)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "MAE\g4f\Provider\bing\conversation.py", line 45, in create_conversation
    raise RuntimeError('Empty response: Failed to create conversation')
RuntimeError: Empty response: Failed to create conversation

My code is

import nest_asyncio

from g4f.Provider import Bing
from g4f.client import Client
from g4f.cookies import set_cookies

nest_asyncio.apply()

set_cookies("bing.com", {
    "_U": "1FTQmyLPCMg-..."
})


def handle_chat(prompt):
    client = Client()
    response = client.chat.completions.create(
        model="gpt-4-turbo",
        provider=Bing,
        messages=[{"role": "user", "content": prompt}],
    )
    return response.choices[0].message.content


prompt = 'Hello'
message = handle_chat(prompt)
print(message)

Would someone help me? thx in advance

@AIUSRTMP AIUSRTMP added the bug Something isn't working label May 12, 2024
@AIUSRTMP
Copy link
Author

I've closed the system firewall, same error

@AIUSRTMP
Copy link
Author

VPN works in TUN Mode, US, same error.

@AnonymousRendezvous
Copy link

AnonymousRendezvous commented May 12, 2024

I have previously also faced a similar problem as this when trying to use async with my chat function. This was solved by me simply removing asyncio from my code and using synchronous functions instead. Await also seems to be an issue especially when the format of continuous (cached) requests as put out in the wiki, is not followed. You might want to try removing async and trying with sync or simply check out the g4f wiki for cached requests. (Or use gpt4 instead of gpt4 turbo)

@hlohaus
Copy link
Collaborator

hlohaus commented May 15, 2024

Hey, you need to clear your cookies or add more to get past Microsoft's firewall.

@hlohaus hlohaus closed this as completed May 19, 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

4 participants