PawanOsman / ChatGPT.Net

C# library for ChatGPT using official OpenAI API
https://www.nuget.org/packages/ChatGPT.Net
MIT License
379 stars 71 forks source link

Exception in chatGpt.CreateClient #2

Closed Caulm closed 1 year ago

Caulm commented 1 year ago

My environment: .Net 6.0, Windows 10 I have installed playwright.ps1, referring to issue #1.

My steps: When calling chatGpt.WaitForReady(), the Chromium browser can pop up and display the login page. Then, when calling chatGpt.CreateClient with my SessionToken, the program throws an exception, saying: One or more errors occurred (Response status code does not indicate success: 403 (Forbidden).), while nothing changes in the browser.

I tried to login manually in this pop-up browser, using Google account, but it said: can not log in because this browser or application may not be secure. Not sure if it is as expected. In addition, I'm using VPN to access openai.com. Maybe a proxy problem?

Do you have any suggestions? Thank you

PawanOsman commented 1 year ago

The Chromium browser is utilized solely for sending requests and is not utilized for logging in. It will remain open at the login screen and will be used to send requests to ChatGPT. If you manually log in, the provided SessionToken will still be used.

Error 403 indicates that the token may have expired and a new one will be required, either obtained from the browser cookie or by using a Microsoft account and setting it in the ChatGPTClientConfig, which will automatically log in and retrieve the necessary Token.

PawanOsman commented 1 year ago

Regarding the use of a VPN or proxy, if you are able to successfully log in to ChatGPT through your browser and use it normally, then it means you can use this API.

dave-nikolas commented 1 year ago

I think I might have a related issue. I have defined the login information for the Microsoft account in the ChatGptClientConfig, but when it reaches the login screen, it does not log in automatically. I have also tried using a SessionToken, but with that it always gets stuck at the page where you can either log in or register.

That is the code I am using.

internal static async Task<Tuple<bool, string>> ChatGptTask(SocketMessage message)
{
    var chatGpt = new ChatGpt();
    await chatGpt.WaitForReady();
    var chatGptClient = await chatGpt.CreateClient(new ChatGptClientConfig
    {
        Account = new Account()
        {
            Type = AccountType.Microsoft,
            Email = "myEmail@outlook.de",
            Password = "myPassword",
        },
    });
    const string conversationId = "1";
    var response = await chatGptClient.Ask(message.Content, conversationId);
    Console.WriteLine(response);
    return new Tuple<bool, string>(true, response);
}

When I log in manually, I receive an error: System.Text.Json.JsonException: "'l' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0."

PawanOsman commented 1 year ago

I checked the login section, it's right when ChatGPT is at capacity it will freeze, I Fixed it, now when ChatGPT is at capacity it will wait till it is available again then it will log in, you can update the library to 1.0.3 to get the fix.

and another note, when you use account for authentication it will log in to ChatGPT for getting your account SessionToken, and after successful login even if you logout from the Chrome Window it will work, which means when you use SessionToken it will stop at login screen because it's not needed to log in again

dave-nikolas commented 1 year ago

Logging in seems to work now, but now i get another unhandled exception. It's happening at await chatGptClient.Ask("Something").

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: l. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
Caulm commented 1 year ago

Hi, I registered a new openai account with a Microsoft account. This time, the browser successfully logged in and entered the "New chat" page. However, the same exception is thrown after that at chatGpt.CreateClient.

One or more errors occurred. (Response status code does not indicate success: 403 (Forbidden).)
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at ChatGPT.Net.Session.ChatGptClient.<RefreshAccessToken>d__50.MoveNext()
   at ChatGPT.Net.ChatGpt.<CreateClient>d__62.MoveNext()
Caulm commented 1 year ago

I tried debugging and output the request content at ChatGptClient.RefreshAccessToken, like this

......
var response = await client.GetAsync("https://chat.openai.com/api/auth/session");
string responseContent = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
......

And I got the following

<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Just a moment...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="robots" content="noindex,nofollow">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="/cdn-cgi/styles/challenges.css" rel="stylesheet">
......

Seems that the request was blocked again?

PawanOsman commented 1 year ago

I tried debugging and output the request content at ChatGptClient.RefreshAccessToken, like this

......
var response = await client.GetAsync("https://chat.openai.com/api/auth/session");
string responseContent = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
......

And I got the following

<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Just a moment...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="robots" content="noindex,nofollow">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="/cdn-cgi/styles/challenges.css" rel="stylesheet">
......

Seems that the request was blocked again?

looks like your IP changed after the login, ensure that your IP is the same because the client is getting the Cloudflare cookies and it won't work with another IP address.

PawanOsman commented 1 year ago

Logging in seems to work now, but now i get another unhandled exception. It's happening at await chatGptClient.Ask("Something").

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: l. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)

Do you use a VPN too?

dave-nikolas commented 1 year ago

Do you use a VPN too?

No, i don't.

I think the error i get, has more to do with the query of ChatGPT's response itself. When Chromium opens, i can see that it gets to the chat window with GPT, but then crashes immediately.

I have noticed that the error for which this page was started for, is a slightly different one than the one I have. Is it okay for me to continue writing here, or should i start a new issue?

PawanOsman commented 1 year ago

Logging in seems to work now, but now i get another unhandled exception. It's happening at await chatGptClient.Ask("Something").

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: l. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)

Have you checked to ensure that your account is not rate-limited or tried using a different account? Additionally, you could try using a SessionToken to see if that helps. If you have already tried these suggestions and are still encountering the same error, please let me know and it's okay we can continue here or create a new issue, as you like.

It's important to note that this library is still under development, and I will be handling errors in future updates.

dave-nikolas commented 1 year ago

I've tried it with multiple accounts, but all of them resulted in the same outcome. I also tried using the SessionToken, but didn't get it to work.

I think I may be doing something wrong. I have attached a video below that shows how I am using it.

First, I start the program, it launches Chromium, gets to the login screen, but then nothing happens. If I try to log in myself, nothing further happens. But when I then restart the program, it is already logged in due to the previous attempt, but then gives me an error message.

After that, I try using the SessionToken. First, I log in to the same Chromium browser and then copy the SessionToken, paste it into the program, but it still gets stuck at the login-screen and then gives me an error.

The exception occurs at "JsonConvert.DeserializeObject(data)" at which point the value of the data variable is "l>".

https://user-images.githubusercontent.com/65472401/209227246-20be86a7-be8a-4d5b-ade7-43eac33ce42f.mp4

Caulm commented 1 year ago

I've tried it with multiple accounts, but all of them resulted in the same outcome. I also tried using the SessionToken, but didn't get it to work.

I think I may be doing something wrong. I have attached a video below that shows how I am using it.

First, I start the program, it launches Chromium, gets to the login screen, but then nothing happens. If I try to log in myself, nothing further happens. But when I then restart the program, it is already logged in due to the previous attempt, but then gives me an error message.

After that, I try using the SessionToken. First, I log in to the same Chromium browser and then copy the SessionToken, paste it into the program, but it still gets stuck at the login-screen and then gives me an error.

The exception occurs at "JsonConvert.DeserializeObject(data)" at which point the value of the data variable is "l>".

unhandled.exception.login.mp4

Is your system language English? It seems that the non English page will get stuck when inputing email, which may be related to the localization.

You may change "Preferred languages" to English, and enable "Clear cookies and site data when you close all windows" on the Chromium settings page. This can prevent automatic login.

dave-nikolas commented 1 year ago

Thank you, the login is now working perfectly. I did not thought that playwright identifies buttons etc. with localized text. But, i've run the code, and it still gave me Newtonsoft.Json.JsonReaderException: "Unexpected character encountered while parsing value: l. Path '', line 0, position 0." i have to test that again, when im home.

PawanOsman commented 1 year ago

create a breakpoint at this line and run it in debug mode, then tell us the value of "response" it can tell us what is the issue

image

dave-nikolas commented 1 year ago

Sure, this is the value of "response":

<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Just a moment...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="robots" content="noindex,nofollow">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="/cdn-cgi/styles/challenges.css" rel="stylesheet">

</head>
<body class="no-js">
    <div class="main-wrapper" role="main">
    <div class="main-content">
        <h1 class="zone-name-title h1">
            <img class="heading-favicon" src="/favicon.ico"
                 onerror="this.onerror=null;this.parentNode.removeChild(this)">
            chat.openai.com
        </h1>
        <h2 class="h2" id="challenge-running">
            Checking if the site connection is secure
        </h2>
        <noscript>
            <div id="challenge-error-title">
                <div class="h2">
                    <span class="icon-wrapper">
                        <div class="heading-icon warning-icon"></div>
                    </span>
                    <span id="challenge-error-text">
                        Enable JavaScript and cookies to continue
                    </span>
                </div>
            </div>
        </noscript>
        <div id="trk_jschal_js" style="display:none;background-image:url('/cdn-cgi/images/trace/managed/nojs/transparent.gif?ray=77e0ff2c9d452675')"></div>
        <div id="challenge-body-text" class="core-msg spacer">
            chat.openai.com needs to review the security of your connection before proceeding.
        </div>
        <form id="challenge-form" action="/backend-api/conversation?__cf_chl_f_tk=fXKcRFzzwPRB2ZtOpeIKG7nrHOi26s__BGSVBaqAMKg-1671797454-0-gaNycGzNGT0" method="POST" enctype="application/x-www-form-urlencoded">
            <input type="hidden" name="md" value="fmXbMDTfJaTt7G40Gb.Nj_vgWlPXuGtLq2s30D10jb4-1671797454-0-Ab82jo4ap4sPRTa-xiOWLk3NRuSo-16WNkRJOstc3PtY2ItR0faWqcsirfRZP1IftMzXuP2kgYj9KVch66qnWojWUWuNXG5VlSbjUWSwehk4QJm1IaDAC4tt9ogl0G9RG7DaPK0e2jL_YU3-zeFRk-Jai3h3kk3BTrRg4oQd8WjzypwX8itMkBV8Lfdr_vLaRv5rrJZF6AMNin_lbabSOE2IUAbUL88Jjk2wYFEJI-9GPy-bT4vmqsGCAcbmavsuNtAHd320YtxKGSTFlC1v8o0sZk-eDecOw_CJzUR4DohBpwTZDxTZgYmWgqWDLhLWgt9OrHV_GlmByXdtsQJK91sT8VfB3Ya1-McEuGQP5NyesARSEuOgapJfgHND0tSsq9_Pmh7TxD79Gw90HBQfSc73gm9WBh53zXh_giBw1o2sjHXXNR5DHpoHOLCiNCrZOB3dCSxl7tLzMLsqcKi68yF_BRjsHyAz4t4lTHiy-Z2vYphk9LoQTjfKfWGEfO7I6XrJPR8gV9U6mHKeSC_KgmXHWKsHwR2_jaTQ7T0W-xlpycoo5m6SE0LHf5oVn8i0gGKGejmMuHS2RUN4fZfR8kAI4MGBMtnpwTH8ViKCjFH1wW5Id6vll1TMrwOYrvLZWtw0SKLiwii9ogaoOq9HiD_2bUaq-aRrLqGexdiS0YDNCStMFNxyUc5bkMdjTt2VGQ">
            <input type="hidden" name="r" value="ifDmVkOeibg_pfenR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div>
</div>
<script>
    (function(){
        window._cf_chl_opt={
            cvId: '2',
            cType: 'managed',
            cNounce: '91455',
            cRay: '77e0ff2c9d452675',
            cHash: '0d8473986f86078',
            cUPMDTk: "\/backend-api\/conversation?__cf_chl_tk=fXKcRFzzwPRB2ZtOpeIKG7nrHOi26s__BGSVBaqAMKg-1671797454-0-gaNycGzNGT0",
            cFPWv: 'g',
            cTTimeMs: '1000',
            cTplV: 4,
            cTplB: 'cf',
            cRq: {
                ru: 'aHR0cHM6Ly9jaGF0Lm9wZW5haS5jb20vY2hhdC9iYWNrZW5kL2FwaS9jb252ZXJzYXRpb24=',
                ra: 'TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzEwOC4wLjAuMCBTYWZhcmkvNTM3LjM2',
                rm: 'UE9TVA==',
                d: 'SgpObwXliyTYVczNjLadsPthvb8zHRhPZEcMXWiSehe1R9aRyYTL6/SFtIX5qlCTRjXGWOl+uA1Qzm6qm9HwFTpZ9fXtOe5MkeN5p6XUmpSM+dJRO1jno+zyEsTyZrovug+bLwGRffWwrVQ0fraOEtu4RTxIaaviyU3+Lwap99H2O1LAGvPYnTieP0ye36nn3KnTJ08mekLlrX4TdKf0W/0L5MtFdUU66ZhL2avftdIafUX4YpS6dBmqy7/CWyXUC4tioZq18Ckpgk6DLYebbMxrgSlMeYVb+6eZPRqkj1p/EJJcNFmlBDxmqWVTFB804eV3hzmEFYreoJM/XK5YxW9q/OQ3+DdpLB+e+muJR+QXdUjc8y5MXd6Uw7jICALsqFjGFDpel9IUvpbUE88TxrleaItTjhe4/80DgBF6JE8kiy0lUZTq1UwYf7hfpsKy3i8DgwJ5dUKLrfPylsErBb537ORcF/vdrjXr5pCtlDCAutFD+KDc5ZDXLsjKNIIzhK+aszHVoyAG1AmF1V04Zg3dX6UQWLIPZ5nfLa6yPxFP5ZJfKTFX3XMrK4GC+aaOH+avIl0uld/69b3zla1LLeV1RGsbEuwuh55YjMz7dxvIBK2ylx249g8iHV/Vp8OZIbGH/DK1BibrVedOBYg8ml/CUFLsGhlagLkp3Ir8QNg=',
                t: 'MTY3MTc5NzQ1NC44MjAwMDA=',
                m: 'kDC3tiZubEPF1u0Vh4NLZD8cm7YaYAvoH1N3PuTyPSo=',
                i1: 'MwgMsPNxX/aIa4luO3gDsw==',
                i2: '7EnlHU6eEfY0jG3hTde7yw==',
                zh: 'iuyN59AGNgeBFFEOPj72EN+xtBfXXvoCyd1dJnIVFAc=',
                uh: 'JkAkY486s8b7quQvdaIQRGNNNpmu+ejtUZNcz6o7wFM=',
                hh: 'foaWmAUHGGlVCZaNUJIHhxzxFNzSPNnVe6rJjiQw728=',
            }
        };
        var trkjs = document.createElement('img');
        trkjs.setAttribute('src', '/cdn-cgi/images/trace/managed/js/transparent.gif?ray=77e0ff2c9d452675');
        trkjs.setAttribute('style', 'display: none');
        document.body.appendChild(trkjs);
        var cpo = document.createElement('script');
        cpo.src = '/cdn-cgi/challenge-platform/h/g/orchestrate/managed/v1?ray=77e0ff2c9d452675';
        window._cf_chl_opt.cOgUHash = location.hash === '' && location.href.indexOf('#') !== -1 ? '#' : location.hash;
        window._cf_chl_opt.cOgUQuery = location.search === '' && location.href.slice(0, -window._cf_chl_opt.cOgUHash.length).indexOf('?') !== -1 ? '?' : location.search;
        if (window.history && window.history.replaceState) {
            var ogU = location.pathname + window._cf_chl_opt.cOgUQuery + window._cf_chl_opt.cOgUHash;
            history.replaceState(null, null, "\/backend-api\/conversation?__cf_chl_rt_tk=fXKcRFzzwPRB2ZtOpeIKG7nrHOi26s__BGSVBaqAMKg-1671797454-0-gaNycGzNGT0" + window._cf_chl_opt.cOgUHash);
            cpo.onload = function() {
                history.replaceState(null, null, ogU);
            };
        }
        document.getElementsByTagName('head')[0].appendChild(cpo);
    }());
</script>

    <div class="footer" role="contentinfo">
        <div class="footer-inner">
            <div class="clearfix diagnostic-wrapper">
                <div class="ray-id">Ray ID: <code>77e0ff2c9d452675</code></div>
            </div>
            <div class="text-center">Performance &amp; security by <a rel="noopener noreferrer" href="https://www.cloudflare.com?utm_source=challenge&utm_campaign=m" target="_blank">Cloudflare</a></div>
        </div>
    </div>
</body>
</html>
PawanOsman commented 1 year ago

can you try to check your IP both from your normal browser and from the controlled chromium browser? it must be the same,

looks like your IP from the chromium browser is different from the other requests made from the c# HTTP client, maybe you use proxy at windows settings or something that change the IP inside the browser

dave-nikolas commented 1 year ago

The IPs of both browsers are the same. I just disabled IPv6 for testing, so only IPv4 can be used, but that leads to a another Exception. System.Net.Http.HttpRequestException: "Response status code does not indicate success: 403 (Forbidden)."

I've also tried using a custom proxy, to see, if that changes anything, but it doesn't.

NVIDIA_Share_IGi9DdNVZS

dave-nikolas commented 1 year ago

The IPs of both browsers are the same. I just disabled IPv6 for testing, so only IPv4 can be used, but that leads to a another Exception. System.Net.Http.HttpRequestException: "Response status code does not indicate success: 403 (Forbidden)."

I've also tried using a custom proxy, to see, if that changes anything, but it doesn't.

NVIDIA_Share_IGi9DdNVZS

Okay, i don't know what it was, but i don't get this error anymore. Only the one from before Newtonsoft.Json.JsonReaderException: "Unexpected character encountered while parsing value: l. Path '', line 0, position 0.".

PawanOsman commented 1 year ago

The IPs of both browsers are the same. I just disabled IPv6 for testing, so only IPv4 can be used, but that leads to a another Exception. System.Net.Http.HttpRequestException: "Response status code does not indicate success: 403 (Forbidden)." I've also tried using a custom proxy, to see, if that changes anything, but it doesn't. NVIDIA_Share_IGi9DdNVZS

Okay, i don't know what it was, but i don't get this error anymore. Only the one from before Newtonsoft.Json.JsonReaderException: "Unexpected character encountered while parsing value: l. Path '', line 0, position 0.".

maybe the issue is your network, because I can't reproduce the issue, anyways I will add a safe-mode in the next update when you turned on safe mode all requests will go throw the browser window, it will be slower but I think it fixes your issue

dave-nikolas commented 1 year ago

The safe mode could fix my problem, but I'd like to mention one thing. I just asked a friend if he could also run the program. He created a new project and took the program from me, then installed ChatGPT.Net via Nuget and then installed playwright.ps1 via PowerShell.

He then ran the program through Visual Studio, and got the same error as me. I don't think it should have an influence, but for him, the system language is also German like mine, but only Chromium is set to English so that playwright works properly. And the Operating System is Windows 11.

PawanOsman commented 1 year ago

what is the isp you are using? Are you and your friend using the same ISP or a different one?

dave-nikolas commented 1 year ago

I'm using 1&1, he is using T-Mobile (Deutsche Telekom) and I also asked another friend to run the code, which also got the same error, he uses PŸUR.

dave-nikolas commented 1 year ago

I think it works now, but I don't know if it is permanently fixed. I changed the system language to English and then reset the Chromium settings.

I think it must still have had something to do with the language, but I'm not sure exactly how. I had already changed the system language to English before, and it didn't make a difference. I also changed the language in Chromium, but that didn't work either.

It has started working when I reset Chromium and the language was automatically set to English because of my system language. I don't know if it's just a coincidence, but it's working now.

But, thank you for all the help.

dave-nikolas commented 1 year ago

Nevermind, it seems like it's spontaneously not working again.

Addition: I think now, it has nothing to do with the code, it seems to just be the message limit from ChatGPT. "Too many requests in 1 hour. Try again later."

Caulm commented 1 year ago

Changing the system language doesn't work for me either. I changed the system language to English, which had been previously Chinese, the system region to the United States, and the "language used by non Unicode programs" to English. And my global proxy IP is in the United States. They all matched. But I still received HttpRequestException 403 (Forbidden). I skiped this exception, and then received the JsonReaderException same as mentioned above.

I notice that there will be repeated cloudflare verification for many times (about 4-5) before the browser opens the login page. But I can pass it at once in a normal browser.

PawanOsman commented 1 year ago

The new version has been released, and a new method has been implemented, you can test it and see if you have any issues with the new method 😁

Caulm commented 1 year ago

Sorry for the late reply. In the new version, I can successfully log in and ask questions. Thank you!