xhcoding / emacs-aichat

AI Chat in Emacs, including OpenAI and Bing Chat
60 stars 10 forks source link

error UnauthorizedRequest:Cannot retrieve user status. #21

Closed Ypot closed 1 year ago

Ypot commented 1 year ago

A few hours ago it was working, now it is not. I don't know how I broke it.

Content of the AICHAT-DEBUG:

====== chathub opened ======
Receive handshake response: {}
Send request:
{"arguments":[{"source":"cib","optionsSets":["nlu_direct_response_filter","deepleo","disable_emoji_spoken_text","responsible_ai_policy_2235","enablemm","enbcdxpgpsr2","dllatex","dv3sugg","gencontentv3","galileo"],"allowedMessageTypes":["Chat","InternalSearchQuery","InternalSearchResult","InternalLoaderMessage","GenerateContentQuery","Disengaged"],"sliceIds":["winmuid1tf","contctxp2tf","ssoverlap50","sspltop5","sswebtop1","audrngon","audseq","nopreloadsscf","winmsgcf","creatgoglc","creatorv2t","wintone1cf","0415bficon","414suggs0","scctl","407pgparser","0329resps0","185latex","udscahrfon","udstrblm4","403recansgnds0","403tvlgnds0"],"spokenTextMode:":"None","isStartOfSession":false,"message":{"author":"user","inputMethod":"Keyboard","text":"Hola Mundo","messageType":"Chat"},"conversationSignature":"mlUmb1iFG6f0M+rbM9cODO+M6cRZu6BZJNd8V81Mr7E=","participant":{"id":"38D34D1E8C6263BB2F785E5C8D49627D"},"conversationId":"51D|BingProd|870031BD5382168A6BFD83C66BC13A9DF432FCF6E828CC59EAB81479AAB56A3A"}],"invocationId":"5","target":"chat","type":4}

Recv text:
{"type":2,"invocationId":"5","item":{"firstNewMessageIndex":null,"defaultChatName":null,"conversationId":"51D|BingProd|870031BD5382168A6BFD83C66BC13A9DF432FCF6E828CC59EAB81479AAB56A3A","requestId":"45799ca4-5c1c-4368-87c7-ab024ec02262","telemetry":{"startTime":"2023-07-02T15:22:48.4633152Z"},"result":{"value":"UnauthorizedRequest","message":"Cannot retrieve user status.","error":"UnauthorizedRequest","renewCert":true,"serviceVersion":"20230630.99"}}}{"type":3,"invocationId":"5"}
buffer:
{"type":2,"invocationId":"5","item":{"firstNewMessageIndex":null,"defaultChatName":null,"conversationId":"51D|BingProd|870031BD5382168A6BFD83C66BC13A9DF432FCF6E828CC59EAB81479AAB56A3A","requestId":"45799ca4-5c1c-4368-87c7-ab024ec02262","telemetry":{"startTime":"2023-07-02T15:22:48.4633152Z"},"result":{"value":"UnauthorizedRequest","message":"Cannot retrieve user status.","error":"UnauthorizedRequest","renewCert":true,"serviceVersion":"20230630.99"}}}{"type":3,"invocationId":"5"}
object:
((type . 2) (invocationId . 5) (item (firstNewMessageIndex) (defaultChatName) (conversationId . 51D|BingProd|870031BD5382168A6BFD83C66BC13A9DF432FCF6E828CC59EAB81479AAB56A3A) (requestId . 45799ca4-5c1c-4368-87c7-ab024ec02262) (telemetry (startTime . 2023-07-02T15:22:48.4633152Z)) (result (value . UnauthorizedRequest) (message . Cannot retrieve user status.) (error . UnauthorizedRequest) (renewCert . t) (serviceVersion . 20230630.99))))
object:
((type . 3) (invocationId . 5))
xhcoding commented 1 year ago

I have not encountered a similar error. Please try restarting the conversation to see if it works properly.

Ypot commented 1 year ago

Right, now it's working :-)

Is there anything that I should hide in the AICHAT-DEBUG?

liar666 commented 1 year ago

I get this everytime now :(

====== chathub opened ======
Receive handshake response: {}
Send request:
{"arguments":[{"source":"cib","optionsSets":["nlu_direct_response_filter","deepleo","disable_emoji_spoken_text","responsible_ai_policy_2235","enablemm","iycapbing","iyxapbing","refpromptv1","enuaug","dv3sugg","autosave","iyoloxap","iyoloneutral","galileo","saharagenconv5"],"allowedMessageTypes":["Chat","Disengaged"],"sliceIds":["winmuid3tf","anssupltmrd1","imgchatgptv2","bingsr3-v1","revpayaad","winstmsg2tf","602refusal","621alllocs0","621docxfmtho","330uaug","0626snptrcs0","424dagslnv1s0"],"spokenTextMode:":"None","isStartOfSession":false,"message":{"author":"user","inputMethod":"Keyboard","text":" This is a test\n","messageType":"Chat"},"conversationSignature":"gddKqUJ31X+9/A8ihOvAJ5Gv7K6HNZDLgf8gNfsXZo4=","participant":{"id":"2C897AD06F3D6744316B69836E4A6670"},"conversationId":"51D|BingProd|C4D5B62A716C8EF113E3527B42BC4604CEB5183BB115CAF3276785DB69EFDEEB"}],"invocationId":"6","target":"chat","type":4}

Recv text:
{"type":2,"invocationId":"6","item":{"firstNewMessageIndex":null,"defaultChatName":null,"conversationId":"51D|BingProd|C4D5B62A716C8EF113E3527B42BC4604CEB5183BB115CAF3276785DB69EFDEEB","requestId":"729d9265-2550-4623-bc51-0672c5f62f14","telemetry":{"startTime":"2023-07-19T15:13:29.9975633Z"},"result":{"value":"UnauthorizedRequest","message":"Cannot retrieve user status.","error":"UnauthorizedRequest","renewCert":true,"serviceVersion":"20230718.153"}}}{"type":3,"invocationId":"6"}
buffer:
{"type":2,"invocationId":"6","item":{"firstNewMessageIndex":null,"defaultChatName":null,"conversationId":"51D|BingProd|C4D5B62A716C8EF113E3527B42BC4604CEB5183BB115CAF3276785DB69EFDEEB","requestId":"729d9265-2550-4623-bc51-0672c5f62f14","telemetry":{"startTime":"2023-07-19T15:13:29.9975633Z"},"result":{"value":"UnauthorizedRequest","message":"Cannot retrieve user status.","error":"UnauthorizedRequest","renewCert":true,"serviceVersion":"20230718.153"}}}{"type":3,"invocationId":"6"}
object:
((type . 2) (invocationId . 6) (item (firstNewMessageIndex) (defaultChatName) (conversationId . 51D|BingProd|C4D5B62A716C8EF113E3527B42BC4604CEB5183BB115CAF3276785DB69EFDEEB) (requestId . 729d9265-2550-4623-bc51-0672c5f62f14) (telemetry (startTime . 2023-07-19T15:13:29.9975633Z)) (result (value . UnauthorizedRequest) (message . Cannot retrieve user status.) (error . UnauthorizedRequest) (renewCert . t) (serviceVersion . 20230718.153))))
object:
((type . 3) (invocationId . 6))
Recv text:
Ypot commented 1 year ago

I get this everytime now :(

====== chathub opened ======
Receive handshake response: {}�
Send request:
{"arguments":[{"source":"cib","optionsSets":["nlu_direct_response_filter","deepleo","disable_emoji_spoken_text","responsible_ai_policy_2235","enablemm","iycapbing","iyxapbing","refpromptv1","enuaug","dv3sugg","autosave","iyoloxap","iyoloneutral","galileo","saharagenconv5"],"allowedMessageTypes":["Chat","Disengaged"],"sliceIds":["winmuid3tf","anssupltmrd1","imgchatgptv2","bingsr3-v1","revpayaad","winstmsg2tf","602refusal","621alllocs0","621docxfmtho","330uaug","0626snptrcs0","424dagslnv1s0"],"spokenTextMode:":"None","isStartOfSession":false,"message":{"author":"user","inputMethod":"Keyboard","text":" This is a test\n","messageType":"Chat"},"conversationSignature":"gddKqUJ31X+9/A8ihOvAJ5Gv7K6HNZDLgf8gNfsXZo4=","participant":{"id":"2C897AD06F3D6744316B69836E4A6670"},"conversationId":"51D|BingProd|C4D5B62A716C8EF113E3527B42BC4604CEB5183BB115CAF3276785DB69EFDEEB"}],"invocationId":"6","target":"chat","type":4}�

Recv text:
{"type":2,"invocationId":"6","item":{"firstNewMessageIndex":null,"defaultChatName":null,"conversationId":"51D|BingProd|C4D5B62A716C8EF113E3527B42BC4604CEB5183BB115CAF3276785DB69EFDEEB","requestId":"729d9265-2550-4623-bc51-0672c5f62f14","telemetry":{"startTime":"2023-07-19T15:13:29.9975633Z"},"result":{"value":"UnauthorizedRequest","message":"Cannot retrieve user status.","error":"UnauthorizedRequest","renewCert":true,"serviceVersion":"20230718.153"}}}�{"type":3,"invocationId":"6"}�
buffer:
{"type":2,"invocationId":"6","item":{"firstNewMessageIndex":null,"defaultChatName":null,"conversationId":"51D|BingProd|C4D5B62A716C8EF113E3527B42BC4604CEB5183BB115CAF3276785DB69EFDEEB","requestId":"729d9265-2550-4623-bc51-0672c5f62f14","telemetry":{"startTime":"2023-07-19T15:13:29.9975633Z"},"result":{"value":"UnauthorizedRequest","message":"Cannot retrieve user status.","error":"UnauthorizedRequest","renewCert":true,"serviceVersion":"20230718.153"}}}�{"type":3,"invocationId":"6"}�
object:
((type . 2) (invocationId . 6) (item (firstNewMessageIndex) (defaultChatName) (conversationId . 51D|BingProd|C4D5B62A716C8EF113E3527B42BC4604CEB5183BB115CAF3276785DB69EFDEEB) (requestId . 729d9265-2550-4623-bc51-0672c5f62f14) (telemetry (startTime . 2023-07-19T15:13:29.9975633Z)) (result (value . UnauthorizedRequest) (message . Cannot retrieve user status.) (error . UnauthorizedRequest) (renewCert . t) (serviceVersion . 20230718.153))))
object:
((type . 3) (invocationId . 6))
Recv text:

I asked the same question to bing aichat many times, and it stopped working. Maybe our APIs are banned.

liar666 commented 1 year ago

I just create a new MS account, logged-in, exported the cookie and I get the same error... So I don't think itt's related to our requests.

xhcoding commented 1 year ago

I just create a new MS account, logged-in, exported the cookie and I get the same error... So I don't think itt's related to our requests.

Can you provide a detailed description of the steps to reproduce, and attach all the debug logs?

liar666 commented 1 year ago

= Context I'm using DoomEmacs

= Configuration

(use-package! aichat
  :bind
    ("C-S-a" . aichat-bingai-assistant)
    ("C-S-c" . aichat-bingai-chat)
  :config
    (require 'aichat-bingai)
    (setq aichat-bingai-cookies-file "~/.doom/packages/cookies.json")
)

= Steps to reproduce

= Results

curl filter data: HTTP/2 200 cache-control: private content-length: 264 content-type: application/json; charset=utf-8 p3p: CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND" access-control-allow-credentials: true access-control-allow-headers: x-ms-client-request-id, x-ms-useragent access-control-allow-methods: GET access-control-allow-origin: https://www.bing.com x-eventid: 64bb03a94d4b4bfc950c100cba99147c accept-ch: Sec-CH-UA-Bitness, Sec-CH-UA-Arch, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Platform, Sec-CH-UA, UA-Bitness, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform-Version, UA-Platform, UA useragentreductionoptout: A7kgTC5xdZ2WIVGZEfb1hUoNuvjzOZX3VIV/BA6C18kQOOF50Q0D3oWoAm49k3BQImkujKILc7JmPysWk3CSjwUAAACMeyJvcmlnaW4iOiJodHRwczovL3d3dy5iaW5nLmNvbTo0NDMiLCJmZWF0dXJlIjoiU2VuZEZ1bGxVc2VyQWdlbnRBZnRlclJlZHVjdGlvbiIsImV4cGlyeSI6MTY4NDg4NjM5OSwiaXNTdWJkb21haW4iOnRydWUsImlzVGhpcmRQYXJ0eSI6dHJ1ZX0= content-security-policy-report-only: script-src https: 'strict-dynamic' 'report-sample' 'nonce-ky1QDM5r+TX/Ge5zxE3GYpb5XpZ/FRarpKkHu7jBRGU='; base-uri 'self';report-to csp-endpoint report-to: {"group":"csp-endpoint","max_age":86400,"endpoints":[{"url":"https://aefd.nelreports.net/api/report?cat=bingcsp"}]} x-ceto-ref: 64bb03a94d4b4bfc950c100cba99147c|2023-07-21T22:16:09.645Z x-msedge-ref: Ref A: A06BBA0BC01C48FA84C8AB96512194F2 Ref B: VIEEDGE1020 Ref C: 2023-07-21T22:16:09Z date: Fri, 21 Jul 2023 22:16:09 GMT set-cookie: SUID=M; domain=.bing.com; expires=Sat, 22-Jul-2023 10:16:09 GMT; path=/; secure; HttpOnly; SameSite=None set-cookie: MUID=3BA9978944D460C72D9484DC45AC61BF; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; secure; SameSite=None set-cookie: MUIDB=3BA9978944D460C72D9484DC45AC61BF; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; HttpOnly set-cookie: _EDGE_S=F=1&SID=27FCCCE250566A3E1B5EDFB7512E6BE1; domain=.bing.com; path=/; HttpOnly set-cookie: _EDGE_V=1; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; HttpOnly set-cookie: USRLOC=HS=1; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; secure; HttpOnly; SameSite=None set-cookie: SRCHD=AF=NOFORM; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; secure; SameSite=None set-cookie: SRCHUID=V=2&GUID=6A6B16397A17421488A60B1F0EAB3568&dmnchg=1; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; secure; SameSite=None set-cookie: SRCHUSR=DOB=20230721; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; secure; SameSite=None set-cookie: SRCHHPGUSR=SRCHLANG=zh-Hans; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; secure; SameSite=None set-cookie: _SS=SID=27FCCCE250566A3E1B5EDFB7512E6BE1; domain=.bing.com; path=/; secure; SameSite=None alt-svc: h3=":443"; ma=93600 x-cdn-traceid: 0.34ee7b5c.1689977769.535d7f1

{"conversationId":"51D|BingProd|61D30A8AB494265A3BF22A1DA79244A0C975708DD8B0B76D8EA73DDFFC9EB414","clientId":"3BA9978944D460C72D9484DC45AC61BF","conversationSignature":"RybXPG8zk0WfcUSWgUFgkim7e/Egeim9hhs5LD\u002B7hfU=","result":{"value":"Success","message":null}} curl process sentinel: finished

status: (200) headers: (() (x-cdn-traceid . 0.34ee7b5c.1689977769.535d7f1) (alt-svc . h3=":443"; ma=93600) (set-cookie . _SS=SID=27FCCCE250566A3E1B5EDFB7512E6BE1; domain=.bing.com; path=/; secure; SameSite=None) (set-cookie . SRCHHPGUSR=SRCHLANG=zh-Hans; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; secure; SameSite=None) (set-cookie . SRCHUSR=DOB=20230721; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; secure; SameSite=None) (set-cookie . SRCHUID=V=2&GUID=6A6B16397A17421488A60B1F0EAB3568&dmnchg=1; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; secure; SameSite=None) (set-cookie . SRCHD=AF=NOFORM; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; secure; SameSite=None) (set-cookie . USRLOC=HS=1; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; secure; HttpOnly; SameSite=None) (set-cookie . _EDGE_V=1; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; HttpOnly) (set-cookie . _EDGE_S=F=1&SID=27FCCCE250566A3E1B5EDFB7512E6BE1; domain=.bing.com; path=/; HttpOnly) (set-cookie . MUIDB=3BA9978944D460C72D9484DC45AC61BF; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; HttpOnly) (set-cookie . MUID=3BA9978944D460C72D9484DC45AC61BF; domain=.bing.com; expires=Wed, 14-Aug-2024 22:16:09 GMT; path=/; secure; SameSite=None) (set-cookie . SUID=M; domain=.bing.com; expires=Sat, 22-Jul-2023 10:16:09 GMT; path=/; secure; HttpOnly; SameSite=None) (date . Fri, 21 Jul 2023 22:16:09 GMT) (x-msedge-ref . Ref A) (x-ceto-ref . 64bb03a94d4b4bfc950c100cba99147c|2023-07-21T22:16:09.645Z) (report-to . {"group":"csp-endpoint","max_age":86400,"endpoints":[{"url":"https://aefd.nelreports.net/api/report?cat=bingcsp"}]}) (content-security-policy-report-only . script-src https) (useragentreductionoptout . A7kgTC5xdZ2WIVGZEfb1hUoNuvjzOZX3VIV/BA6C18kQOOF50Q0D3oWoAm49k3BQImkujKILc7JmPysWk3CSjwUAAACMeyJvcmlnaW4iOiJodHRwczovL3d3dy5iaW5nLmNvbTo0NDMiLCJmZWF0dXJlIjoiU2VuZEZ1bGxVc2VyQWdlbnRBZnRlclJlZHVjdGlvbiIsImV4cGlyeSI6MTY4NDg4NjM5OSwiaXNTdWJkb21haW4iOnRydWUsImlzVGhpcmRQYXJ0eSI6dHJ1ZX0=) (accept-ch . Sec-CH-UA-Bitness, Sec-CH-UA-Arch, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Platform, Sec-CH-UA, UA-Bitness, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform-Version, UA-Platform, UA) (x-eventid . 64bb03a94d4b4bfc950c100cba99147c) (access-control-allow-origin . https://www.bing.com) (access-control-allow-methods . GET) (access-control-allow-headers . x-ms-client-request-id, x-ms-useragent) (access-control-allow-credentials . true) (p3p . CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND") (content-type . application/json; charset=utf-8) (content-length . 264) (cache-control . private)) body: {"conversationId":"51D|BingProd|61D30A8AB494265A3BF22A1DA79244A0C975708DD8B0B76D8EA73DDFFC9EB414","clientId":"3BA9978944D460C72D9484DC45AC61BF","conversationSignature":"RybXPG8zk0WfcUSWgUFgkim7e/Egeim9hhs5LD\u002B7hfU=","result":{"value":"Success","message":null}}

====== chathub opened ====== Receive handshake response: {} Send request: {"arguments":[{"source":"cib","optionsSets":["nlu_direct_response_filter","deepleo","disable_emoji_spoken_text","responsible_ai_policy_2235","enablemm","iycapbing","iyxapbing","refpromptv1","enuaug","dv3sugg","autosave","iyoloxap","iyoloneutral","galileo","saharagenconv5"],"allowedMessageTypes":["Chat","Disengaged"],"sliceIds":["winmuid3tf","anssupltmrd1","imgchatgptv2","bingsr3-v1","revpayaad","winstmsg2tf","602refusal","621alllocs0","621docxfmtho","330uaug","0626snptrcs0","424dagslnv1s0"],"spokenTextMode:":"None","isStartOfSession":true,"message":{"author":"user","inputMethod":"Keyboard","text":"This is a test\n","messageType":"Chat"},"conversationSignature":"RybXPG8zk0WfcUSWgUFgkim7e/Egeim9hhs5LD+7hfU=","participant":{"id":"3BA9978944D460C72D9484DC45AC61BF"},"conversationId":"51D|BingProd|61D30A8AB494265A3BF22A1DA79244A0C975708DD8B0B76D8EA73DDFFC9EB414"}],"invocationId":"0","target":"chat","type":4}

Recv text: {"type":2,"invocationId":"0","item":{"firstNewMessageIndex":null,"defaultChatName":null,"conversationId":"51D|BingProd|61D30A8AB494265A3BF22A1DA79244A0C975708DD8B0B76D8EA73DDFFC9EB414","requestId":"d7d55226-4380-4583-8767-37c66e9d6d55","telemetry":{"startTime":"2023-07-21T22:16:10.1100848Z"},"result":{"value":"UnauthorizedRequest","message":"Cannot retrieve user status.","error":"UnauthorizedRequest","renewCert":true,"serviceVersion":"20230721.32"}}}{"type":3,"invocationId":"0"} buffer: {"type":2,"invocationId":"0","item":{"firstNewMessageIndex":null,"defaultChatName":null,"conversationId":"51D|BingProd|61D30A8AB494265A3BF22A1DA79244A0C975708DD8B0B76D8EA73DDFFC9EB414","requestId":"d7d55226-4380-4583-8767-37c66e9d6d55","telemetry":{"startTime":"2023-07-21T22:16:10.1100848Z"},"result":{"value":"UnauthorizedRequest","message":"Cannot retrieve user status.","error":"UnauthorizedRequest","renewCert":true,"serviceVersion":"20230721.32"}}}{"type":3,"invocationId":"0"} object: ((type . 2) (invocationId . 0) (item (firstNewMessageIndex) (defaultChatName) (conversationId . 51D|BingProd|61D30A8AB494265A3BF22A1DA79244A0C975708DD8B0B76D8EA73DDFFC9EB414) (requestId . d7d55226-4380-4583-8767-37c66e9d6d55) (telemetry (startTime . 2023-07-21T22:16:10.1100848Z)) (result (value . UnauthorizedRequest) (message . Cannot retrieve user status.) (error . UnauthorizedRequest) (renewCert . t) (serviceVersion . 20230721.32)))) object: ((type . 3) (invocationId . 0)) Recv text: {"type":6} buffer: {"type":6} object: ((type . 6)) Recv text: {"type":6} buffer: {"type":6} object: ((type . 6))



[PS: I hope there is no sensitive info in this log :( ]
liar666 commented 1 year ago

FYI, during my many tests, I have seen very breifly another error message saying more or less that I had to "login first" to be able to use the service.

xhcoding commented 1 year ago

From the logs, it appears that the cookie is not set. You can run (aichat-bingai--get-cookies-from-file aichat-bingai-cookies-file) in emacs to see if the cookie can be output correctly.

Sensitive information that may appear in the log is your cookie, but there's no need to worry. After the issue is resolved, you can simply refresh your cookie by logging in again.

liar666 commented 1 year ago

Hi,

Thanks for the quick response.

The code you gave results in following error:

Debugger entered--Lisp error: (void-function aichat-bingai--get-cookies-from-file)
  (aichat-bingai--get-cookies-from-file aichat-bingai-cookies-file)
  (progn (aichat-bingai--get-cookies-from-file aichat-bingai-cookies-file))
  eval((progn (aichat-bingai--get-cookies-from-file aichat-bingai-cookies-file)) t)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  (eros--eval-overlay (eval-last-sexp eval-last-sexp-arg-internal) (point))
  eros-eval-last-sexp(nil)
  funcall-interactively(eros-eval-last-sexp nil)
  call-interactively(eros-eval-last-sexp nil nil)
  command-execute(eros-eval-last-sexp)

However trying again to call BingAI resulted in another set of errors which will probably help find the problem:

/bin/bash: line 1: python: command not found
Please install browser_cookie3 by ‘pip3 install browser_cookie3‘

Normally my DoomEmacs is configured to use a specific venv at boot and browser_cookie3 is installed in this venv and for the user. So I focused on the error from first line. Indeed, I don't have any python command, only a bash alias to python3, that does not seem loaded by Emacs.

When I run pyvenv-activate in DoomEmacs to activate my environment or when I create an OS symlink from /usr/bin/python3 to /usr/bin/python then asking again to call BingAI restults in a Popup asking for KDEWallet's passphrase.

And since I didn't know I had KDEWallet installed (I'm using XFCE) I have no idea what the passphrase might be :( Thus I simply backup'ed ~/.local/share/kwalletd/kdewallet.kwl

I still get the error message Cannot retrieve user status., but I might be on the right track....

liar666 commented 1 year ago

Update: Now I can query the KWallet without error, but I still don't seem to get rid of the error Cannot retrieve user status

$ kwallet-query -l kdewallet
$ echo $?
0
xhcoding commented 1 year ago

If you are using a cookie file, try executing (aichat-get-cookies-from-file aichat-bingai-cookies-file)

If you are using browser_cookies3, execute (promise-wait 10 (aichat-get-cookies-from-shell ".bing.com" "edge")).

"edge" can be replaced with the name of the browser you logged into bing.com with, you can refer to aichat-browser-namefor specific information.

Normally, the acquired cookie value will be outputted.

liar666 commented 1 year ago

Hi,

I'm starting to get totally lost...

Here is some feedback on what I did

= Configuration file

I was using (use-package! aichat .... *:config* (setq aichat-bingai-cookies-file "~/.doom/packages/cookies.json") ). The variable didn't seem to be set when I started DoomEmacs or executed these lines again and again.

I switched to :init and the variable seems set when I start DoomEmacs

= But....

Running (aichat-get-cookies-from-file aichat-bingai-cookies-file) in the scratch buffer just returns nil

Thus, the variable does not seem to be accessed correctly ?!?

= And...

Running (aichat-get-cookies-from-file "~/.doom.d/packages/cookies.json") returns ((nil nil nil nil nil t))

Which is strange... Why is it different ?!?

Also, I have:

$ cat .doom.d/packages/cookies.json 
[{
    "Host raw": "https://.bing.com/",
    "Name raw": "MUID",
    "Path raw": "/",
    "Content raw": "...",
    "Expires": "...",
    "Expires raw": "...",
    "Send for": "Encrypted connections only",
    "Send for raw": "true",
    "HTTP only raw": "false",
    "SameSite raw": "no_restriction",
    "This domain only": "Valid for subdomains",
    "This domain only raw": "false",
    "Store raw": "firefox-container-3",
    "First Party Domain": ""
}]

Thus it should be extracting something....

I've also extracted all the bing related cookies in another file and tested again. I get a lot more lists in the output, but still all with nils

= browser_cookie3

Just in case, I executed: (promise-wait 10 (aichat-get-cookies-from-shell ".bing.com" "edge")) and got:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/guillaume.muller/.local/lib/python3.10/site-packages/browser_cookie3/__init__.py", line 1061, in edge
    return Edge(cookie_file, domain_name, key_file).load()
  File "/home/guillaume.muller/.local/lib/python3.10/site-packages/browser_cookie3/__init__.py", line 733, in __init__
    super().__init__(browser='Edge', cookie_file=cookie_file, domain_name=domain_name, key_file=key_file, **args)
  File "/home/guillaume.muller/.local/lib/python3.10/site-packages/browser_cookie3/__init__.py", line 381, in __init__
    self.__add_key_and_cookie_file(**kwargs)
  File "/home/guillaume.muller/.local/lib/python3.10/site-packages/browser_cookie3/__init__.py", line 433, in __add_key_and_cookie_file
    raise BrowserCookieError('Failed to find {} cookie'.format(self.browser))
browser_cookie3.BrowserCookieError: Failed to find Edge cookie

which, after analysis, is normal since I don't use Edge, but Firefox with a UserAgent trick :)

Then I executed: (promise-wait 10 (aichat-get-cookies-from-shell ".bing.com" "firefox")) and got better information printed:

#s(promise-class 0 1 (:fullfilled (("ANON" "A=...&E=1c99&W=1" "..." ".bing.com" "/" t) ("BCP" "AD=0&AL=0&SM=0" "..." ".bing.com" "/" t) ("CSRFCookie" "..." nil ".bing.com" "/" nil) ("KievRPSSecAuth" "..." "..." ".bing.com" "/" t) ("MUID" "..." "..." ".bing.com" "/" t) ("NAP" "V=1.9&E=1c3f&C=...&W=1" "..." ".bing.com" "/" t) ("PPLState" "1" "..." ".bing.com" "/" t) ("SRCHD" "AF=NOFORM" "..." ".bing.com" "/" t) ("SRCHHPGUSR" "SRCHLANG=en&BRW=XW&BRH=M&CW=1916&CH=889&SCW=1916&SCH=4251&DPR=1.0&UTC=120&DM...

= Also

There's a moment, I saw Your network access properties do not allow that or a similar message when calling aichat-bingai-assistant right before the typical Cannot retrieve user status when calling it again... Could not find what it was referring to.

xhcoding commented 1 year ago

Your cookie file format is incorrect, and you can refer to the correct format at https://github.com/xhcoding/emacs-aichat/blob/main/test/cookies.json

You can set aichat-browsr-name to 'firefox

liar666 commented 1 year ago

Hi again,

Thanks again for your quick answers.

Sorry, as I'm not using Edge I couldn't use the cookie extraction method you propose in your README. I used "Cookies Quick Manager" for Firefox. I didn't know it could generate an invalid JSON format (isn't it standardized? (*) )... What's strange is that the cookie.json file I generated seemed to be working until recently. Probably, the auth failed but the BingAI API defaulted to working without being authenticated?

I found that the "cookie editor extension" you recommend for Edge also existed for FF. I did all the steps again, but I still get the same errors (cf. below). Whereas this time running (aichat-get-cookies-from-file "~/.doom.d/packages/cookies.json") returns some values.

I've tried to set both aichat-browsr-name and aichat-browser-name to 'firefox, but I still get the same Cannot retrieve user status error. However, the very first time I got the following error first:

Error: (error (error (error Create conversation failed: {"result":{"value":"UnauthorizedRequest","message":"Sorry, you need to login first to access this service."}})))

For some reason, when I get another error before Cannot retrieve user status, I cannot reproduce it afterwards, even after killing all instances of emacs and restarting it with \emacs...). I there any possibilities that some process and/or connection remains open even after killing emacs?

Installing Edge just to get a cookie seemed overkill, but I think I'll resort to it...

(*) during my tests, I realized there is a "netscape" way of storing the cookies, which look very similar to the output of Python::browser_cookie3. Wouldn't that format be more standard/portable?

xhcoding commented 1 year ago

In fact, BingAI can be used without logging in, but it is highly uncertain and depends on the region of your IP. Please refer to https://github.com/acheong08/EdgeGPT#authentication for more information.

In the latest commit, if the correct cookie is not obtained, I will throw an error. If you still cannot use it properly, you can try sending the cookie.json file to my email: xhcoding@foxmail.com, and I will take a look to see where the problem is.

liar666 commented 1 year ago

Hi,

Thanks a lot for all the work & help.

Here is what I execute and the results:

(require 'aichat)
# => aichat
(require 'aichat-bingai)
# => aichat-bingai

(aichat-get-cookies-from-file aichat-bingai-cookies-file)
# => nil
(aichat-get-cookies-from-file "/home/user/.doom.d/packages/cookies.json")
# Print a long list ... cookie seems loaded OK 
(aichat-get-cookies-from-file "~/.doom.d/packages/cookies.json")
# Print a long list ... cookie seems loaded OK

(promise-wait 10 (aichat-get-cookies-from-shell ".bing.com" "firefox"))
# Print a long list ... cookie seems loaded OK

(setq aichat-browser-name 'firefox)
# => firefox

Can you write a poem
# When I select this line and call "aichat-bingai-assistant"  get your new error:
# Error: (error (error (error (error Can not get correct cookie for login!))))

I'll send you the cookies.json because I'm really out of ideas here...

xhcoding commented 1 year ago

I tested the cookie.json file you sent and it is working fine. You need to set the aichat-bingai-cookies-file to the file path of cookie.json.

The cookie.json file must include the _U field.

liar666 commented 1 year ago

Still does not work here...

In the process of creating a "minimal (non) working DoomEmacs example", I was again asked to enter the KWalletpassword. I tried my best to remove any reference to this annoying piece of software:

But still, this minimal example is unable to get the cookie when I call aichat-bingai-assistant, whereas it gets it when I call (aichat-get-cookies-from-file "/home/user/.doom.d/packages/cookies.json").

I'm really lost....

In case someone is interested in trying to understand the problem the MNWE is attached. (cookie.json should be put in `.doom.d/packages/) dotdoom.zip

xhcoding commented 1 year ago

I'm not sure why kwallet is used. You can use emacs -Q to only require emacs-aichat for testing.

(add-to-list 'load-path "/path/to/emacs-aichat")
(require 'aichat-bingai)
(setq aichat-bingai-cookies-file "~/.doom.d/packages/cookie.json")
(aichat-bingai-chat)
liar666 commented 1 year ago

Hi,

I had to add the dependencies. I finally executed:

(add-to-list 'load-path "~/.emacs.d/.local/straight/build-28.1/iter2")
(add-to-list 'load-path "~/.emacs.d/.local/straight/build-28.1/promise")
(add-to-list 'load-path "~/.emacs.d/.local/straight/build-28.1/async-await")
(add-to-list 'load-path "~/.emacs.d/.local/straight/build-28.1/websocket")

(add-to-list 'load-path "~/.emacs.d/.local/straight/build-28.1/aichat")

(require 'aichat-bingai)
(setq aichat-bingai-cookies-file "~/.doom.d/packages/cookie.json")
(aichat-bingai-chat)

It gave me error: Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 2) 0)

So I tried with the command I'm more familiar with: (aichat-bingai-assistant "write another poem") and it worked....

liar666 commented 1 year ago

OM(F)G!!!!!

I'm so soooooorrrrry ... After a couple more hours of struggling, I found the problem!!!

If you look at my comment https://github.com/xhcoding/emacs-aichat/issues/21#issuecomment-1648551112 , I had configured (setq aichat-bingai-cookies-file "~/.doom/packages/cookie.json"), without the .d to .doom.d !!!!

I'm sooooooooooooooo stupid.... Sorry for the waste of time!!!!