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
ChatGPT provider fails to read .har file #1896
Comments
Is the .har file in /mnt/docs? |
Yes, it's the same place I always placed it and it worked before. I'm also obtaining the HAR file exactly like I used to before so not sure why it doesn't work anymore? |
Are you able to reproduce the issue on your end? Is there an alternative way to supply it with the login credentials without the HAR file such as email and password or some session key? Thanks. |
.har files are needed for plus accounts. Others work with NoDriver too. The .har file must be in the current directory and must end with .har. |
I'm using ChatGPT v3.5 (I don't think it's ChatGPT v4 which is a plus account). So do I still need the .har file? If not, what do I need to supply it with alternatively? Yes, it's placed same place as before and it stopped working:
Does it work for you? Thanks. |
@hlohaus Any updates on this? Thanks. |
Are your .har files created correctly? The .har file solution works for me and other users. |
To create the HAR file, I follow these instructions:
It generates a file I save as "chatgpt.har" and copy it to mnt/docs folder where chatgpt.py is located. It worked before, but it stopped working so I'm not doing anything different than what I did before. Is there a tool or script to fetch the .har from chrome browser automatically to make sure I'm not doing anything wrong when fetching it manually following these instructions? I also just updated the g4f package but I still get the same message:
Any alternative way to specify the auth for ChatGPT 3.5 provider (free account) without using the .HAR file? Do you have Discord to discuss? Does it matter what's the full name of the file or as long as it's *.har it should be ok? Is there any way to inspect the .har or debug this case to see why it can't find or fetch the .har file? Thanks. |
@hlohaus I just tried a second windows pc with python, I'm encountering the same issue. I downloaded the .har multiple times, trying to write multiple times to chatgpt before saving the .har file, but I still keep getting the same error message. It can't be that I'm the only one that's reporting this issue? Thanks. |
@plia7 PS. I had the same problem, but version 0.3.0.7 solved it. |
I put it in both the root folder where chatgpt.py is located as well as inside /mnt/docs. Do you have some basic code snippet that I can try that works for you to make sure my chatgpt.py script is not causing the issue? Do you have a Discord channel or user I can show you the problem? @hlohaus @iG8R Is there any guaranteed folder where I can put the .har file like python site packages or something or is there a way I can force it to read the file from a specific location? @iG8R Your issue doesn't sound the same as mine as yours doesn't say that "har file is missing?" so I think you had a different issue than mine? Thanks. |
@plia7 I do not have Linux, but I suggest you try the following on Windows, which works fine for me:
|
I don't use any code snippets, just API calls from other applications, e.g.
|
Hey, @plia7! How do you run your script? Do you just type |
Yes, I change directory where chatgpt.py is located and then I run it by the command "python3 chatgpt.py" but that's failing. Thanks. |
My friend was able to get this to work in his newly set environment after getting the same error about missing har file although he placed it. He updated to 0.3.1.0 and then it started to work. I tried to do the same but I still get the error. I made sure to remove any har file copies I had so it doesn't take the wrong one. @hlohaus Could you explain please how it determines which HAR file to use? Is there a place I can put the file to ensure it will take priority over any other har file in the running path? I think this is not environment issue rather it's a code issue that should be fixed, because it's clearly failing to pick up on the har file as in my case. Thanks. |
Hey, why can't you just put the .har file in the current directory? It reads all the .har files, but then only uses the last one it finds that matches alphabetically. |
I already placed it in the current directory. It doesn't work. |
@iG8R Thanks for the detailed reply. http://127.0.0.1:1337/v1/chat/completions?provider=OpenaiChat What body do you use? When I try to make a REST POST call to http://127.0.0.1:1337/v1/chat/completions?provider=OpenaiChat INFO: 127.0.0.1:64627 - "POST /v1/chat/completions?provider=OpenaiChat HTTP/1.1" 422 Unprocessable Entity And this is the response body I get:
Thanks. |
@plia7 |
Do I have to install both of these programs? |
Any will do. |
Ok so when I try to add the call in the pot program as in your screenshot, this is the message I get:
Any idea what does it mean? I tried to place the .har file inside: C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts But the error indicates something was unauthorized? I used a single space for the api key like you said (and tried also without it and I get the same error). That seems to be inline with the error that I get in OpenaiChat.py:
Thanks. |
@hlohaus @iG8R Could it be a problem with my ChatGPT account? Could it be I got shadow banned or something where the .HAR that gets generated doesn't work anymore? Is it possible? Does the error I get indicates it can't find the .HAR file or could it be it does find it, but the content inside the file can't be used? Would there be a different error in that case? The code seem to point to this error:
So I get status 401 unauthorized response. Moreover, I noticed that if I go to the following URL/login to my chatgpt account:
But other people told me they are able to use this too, and provided a screenshot: So I wonder if this is related and part of the root cause to the problem that I experience with the .har file (401 unauthorized response), what do you think? Thanks. |
@hlohaus @iG8R Ok in one environment, I was able to get this to work with a new .HAR I just downloaded, so it must be something with my other two environments. It doesn't seem like a problem with my ChatGPT account. But why in two environments it would get screwy like that out of the blue? Everything was working fine prior to that, it doesn't make any sense. @hlohaus It doesn't make sense that I need to re-create the environment, re-install python and g4f just to get this to work? Why would it work in one environment with the same .HAR file but then it would fail in another environment with the same .HAR file? Could you please fix it, so it's environment agnostic and never fails? Is there a way to force it to use the .HAR file somehow? Can I modify some code to tell it to use the file directly? Could you please direct me what to change and try it and see if it fixes the problem? I can modify: C:\users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\g4f\Provider\needs_auth\OpenaiChat.py Just tell me what to change to force it to read my .HAR file that's located in: C:\Users\me\Documents\chat.openai.com.har Thanks. |
Please enable the logging or debug mode. This will allow you to view the .har files that are loaded in the log. |
How do I do that? python3 chatgpt.py So where do I enable logging for it? Thanks. |
Read once more my post #1896 (comment) and repeat it exactly as it was described. |
@iG8R Sorry but I don't want to recreate my environment from scratch, I have other things there that I want to keep. |
@plia7 |
I'm running it on a linux x86 emulator which is very slow to uninstall/install g4f. |
@hlohaus @iG8R I enabled logging but I don't see it shows what .har it uses. I enabled it by adding the logging as follows to my script: g4f.debug.logging = True # enable logging Any other things I can add to my script that can shed some light why this issue only happens with this environment? Please don't tell me to reinstall the environment to set up a new virtual environment, I have other stuff in it I want to keep and it's too slow to reinstall it. There must be other ways to get this to work. Thanks.
|
Yo, I'll create a function that sets the cookies dir for you. This way, it won't search for files in the wrong directory. Sound good? |
Perfect, I appreciate it. Please let me know if I can do anything to help to test the function or the new package version when it comes out to see it fixes the issue for me. Thanks. |
Hey, I just dropped the new version! Check out the readme for an example of how to use the set cookies dir function. |
I just tried it, and this is the message that I get now:
I only placed the .har file inside the folder (I never needed any other files like cookies and it works fine in another environment just with this same .har file so not sure why it's complaining about cookies or something). This is the beginning of my script file:
I don't think you need cookies files for ChatGPT provider? Thanks. |
Alright. It now finds the .har file. But I don't think it's valid. Do you have an error message? Did you track a chat action? Did you reload the website after opening the browser console? |
Yes I did reload the website and track a chat action when fetching the .har file. The error which can be seen in the stack trace I posted in previous comment is:
So looks like it fails here: cls._cookies[c.key if hasattr(c, "key") else c.name] = c.value TypeError: 'NoneType' object does not support item assignment It tries to assign a NoneType object to the cookies dictionary? But why does it even try to go to this code if I didn't provide any cookies and it's not applicable to ChatGPT? Please correct me if I'm wrong. Thanks. |
The error occurs only when no .har file is found. Consider using OpenaiAccount instead, as it does not check for the free service. |
@hlohaus Sorry I'm a little bit confused:
Thanks. |
The cookies are also included in the .har file. Your last error message indicates that the cookies are not available and cannot be updated. |
Ok but as I mentioned the same .har file works fine in another working environment. Thanks. |
Do you agree @hlohaus ? Why I don't have this issue with other packages that I use? Could you please fix it? Thanks. |
Hello.
It seems like it doesn't work anymore?
I updated g4f to latest version and added a new HAR file, but I'm still getting a message that HAR file is missing?
Does it still work for you?
Thanks.
The text was updated successfully, but these errors were encountered: