isxuelinme / poe_unoffical_api

the POE of Quora golang implement
Apache License 2.0
88 stars 17 forks source link

core/poe.go:166 log:(string) "{\"data\": null, \"errors\": [{\"message\": \"Server Error\"}], \"extensions\": {\"is_final\": true}}" #4

Open xyc0123456789 opened 1 year ago

xyc0123456789 commented 1 year ago

I made a modification to the function PoeRequest in github.com/isxuelinme/poe_unoffical_api/core/poe.go

proxyUrl, _ := url.Parse("http://127.0.0.1:7078")
client := &http.Client{
    Transport: &http.Transport{
        Proxy: http.ProxyURL(proxyUrl),
    },
}

image

[Debug] 2023/03/18 01:14:58 answer:
(string) "{\"data\": null, \"errors\": [{\"message\": \"Server Error\"}], \"extensions\": {\"is_final\": true}}"

github.com/isxuelinme/poe_unoffical_api/core.(*PoeGPT).Talk(0xc0000a2080, {0x568550, 0xc0000a4190}, 0xc000154a80)
        D:/xxxx/vendor/github.com/isxuelinme/poe_unoffical_api/core/poe.go:166 +0xf68

Did I do something wrong somewhere?

isxuelinme commented 1 year ago

I dont know your modification detail , but maybe your .env cookie or chat id or channel has wrong if you use proxy i dont suggest you config your http proxy in golang , because the websocks also need proxy like poerequest, normally we use clash and use it tun mode about clash u can fount in github

isxuelinme commented 1 year ago

Star before asking, it's free,thax

xyc0123456789 commented 1 year ago

I just modify the function PoeRequest code from

client := &http.Client{}

to

        proxyUrl, _ := url.Parse("http://127.0.0.1:7078")
    client := &http.Client{
        Transport: &http.Transport{
            Proxy: http.ProxyURL(proxyUrl),
        },
    }

and import "net/url" with rename the origin function's local variable "url" to "urlStr"

I used clash on windows locally and opened 127.0.0.1:7078 system proxy

I have checked the .env cookie ,chat id and channel. It's correct

I found codes like os.Getenv("POE_COOKIE"), do I need to configure environment variables instead of modifying the. env file?

isxuelinme commented 1 year ago

you dont need to change any windows env variable , am sure it also run on windows ,but you can try set windows env var when the time of I am replying u , the repo run normal

isxuelinme commented 1 year ago

and must have notice you , if you run the repo on not tun mode which can proxy all network traffic , you cant use websockets so you cant run the repo normally

xyc0123456789 commented 1 year ago

Oh...I log the ChatID and I found ChatID=0 , os.Getenv("POV_CHAT_ID") ,Not "POE_CHAT_ID". It's from github.com\isxuelinme\poe_unoffical_api@v1.2.2\core

isxuelinme commented 1 year ago

I am sure it's can run on windows you dont need to manually to set the system env var but if you cant run again ,you could manual set it if still not run , you can re pull all code try again , because before few days , I have changed some code maybe you dont pull latest

xyc0123456789 commented 1 year ago

I am sure it's can run on windows you dont need to manually to set the system env var but if you cant run again ,you could manual set it if still not run , you can re pull all code try again , because before few days , I have changed some code maybe you dont pull latest

Thank you for your help ! I ran successfully!

isxuelinme commented 1 year ago

I am sure it's can run on windows you dont need to manually to set the system env var but if you cant run again ,you could manual set it if still not run , you can re pull all code try again , because before few days , I have changed some code maybe you dont pull latest

Thank you for your help ! I ran successfully!

you are welcome , using english for help another lang people, dont mind , did you manual set env on windows ?

xyc0123456789 commented 1 year ago

I am sure it's can run on windows you dont need to manually to set the system env var but if you cant run again ,you could manual set it if still not run , you can re pull all code try again , because before few days , I have changed some code maybe you dont pull latest

Thank you for your help ! I ran successfully!

you are welcome , using english for help another lang people, dont mind , did you manual set env on windows ?

no, I didn't I clone the repository and reinstall the mod , add follew code to go.mod, reVendor the example replace github.com/isxuelinme/poe_unoffical_api => path\to\poe_unoffical_api

isxuelinme commented 1 year ago

I am sure it's can run on windows you dont need to manually to set the system env var but if you cant run again ,you could manual set it if still not run , you can re pull all code try again , because before few days , I have changed some code maybe you dont pull latest

Thank you for your help ! I ran successfully!

you are welcome , using english for help another lang people, dont mind , did you manual set env on windows ?

no, I didn't I clone the repository and reinstall the mod , add follew code to go.mod, reVendor the example replace github.com/isxuelinme/poe_unoffical_api => path\to\poe_unoffical_api

good , I guess the cause from go tag and go mirror , thank you tell me .

xyc0123456789 commented 1 year ago

Another problem. the default BACKEND_PORT = 6000 will cause browser ERR_UNSAFE_PORT error.Let BACKEND_PORT = 8090 will solve the problem

isxuelinme commented 1 year ago

Another problem. the default BACKEND_PORT = 6000 will cause browser ERR_UNSAFE_PORT error.Let BACKEND_PORT = 8090 will solve the problem

sure on windows it is cant run , I will change the default port to another .

xyc0123456789 commented 1 year ago

Another problem. When I run it on ubuntu with nohup go run main.go >nohup.out 2>&1 &
go-sse:****** will full screen,It seems to be caused by the code Logger: log.New(os.Stdout, "go-sse: ", log.LstdFlags) which because sseServer = sse.NewServer(nil) options is nil

isxuelinme commented 1 year ago

use screen dont use nohup, more about screen you can ask chatgpt

xyc0123456789 commented 1 year ago

Logger: log.New(os.Stdout

It just causes something strange. The go:see***** log can't redirect to the file by the command nohup go run main.go >nohup.out 2>&1 & 1、 I open two terminal, 2、On terminal A start and stop the app 3、 then I start app with SSE on terminal B with nohup. 4、request GO server By curl on terminal A 5、 The go-sse:****** log on terminal A 6、 I start a JAVA app on terminal A. When JAVA request GO server ,go-sse:****** log will show on terminal with command tail

isxuelinme commented 1 year ago

It just causes something strange. The go:see***** log can't redirect to the file by the command nohup go run main.go >nohup.out 2>&1 & 1、 I open two terminal, 2、On terminal A start and stop the app 3、 then I start app with SSE on terminal B with nohup. 4、request GO server By curl on terminal A 5、 The go-sse:****** log on terminal A 6、 I start a JAVA app on terminal A. When JAVA request GO server ,go-sse:****** log will show on terminal with command tail

I know why the error happened , cause nohup just a stdout redirect so I dont recommand you use that , maybe you can set log.SaveFunc to satisfy your asking

isxuelinme commented 1 year ago

I will test it when I have a bit free time before it , I suggest you use screen , nohup is a old era command use command : sudo apt install screen but almost default installed

xyc0123456789 commented 1 year ago

sudo apt install screen

Thank you! I'll try it!

xyc0123456789 commented 1 year ago

There seem something wrong. When I open th peo.com , I found message from backend was sent to sage, but socket read from chatgpt.

isxuelinme commented 1 year ago

open poe.com open soga tab input something and rerun javascript got channel and chat_id reset your env file will be normal