demo SSE READ SSE README.md
sse.mp4
demo.mp4
import "github.com/isxuelinme/poe_unofficial_api/core"
go mod tidy
function getChatId(botName) {
let channel = localStorage.getItem("poe-tchannel-channel")
let paramsForGetChatId = window.__NEXT_DATA__.buildId
let fetchUrl = "https://poe.com/_next/data/" + paramsForGetChatId + "/"+botName+".json?handle="+botName
fetch(fetchUrl)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not okay');
}
return response.text();
})
.then(data => {
jsonData = JSON.parse(data)
let output = "POE_BOT_NAME = " + botName + "\n"+ "POE_BOT_MODEL = " + jsonData.pageProps.payload.chatOfBotDisplayName.defaultBotObject.model + "\n"+ "POE_CHANNEL = " + channel + "\n" + "POE_CHAT_ID = " + jsonData.pageProps.payload.chatOfBotDisplayName.chatId
console.log(output)
})
.catch(error => {
console.error('Error fetching data:', error);
});
}(getChatId("Sage"))
Copy the value of POE_CHANNEL and POE_CHAT_ID after running the above code. The output will look like this:
POE_BOT_NAME = Sage
POE_BOT_MODEL = capybara
POE_CHANNEL = poe-chan51-8888-hqqqqzuksgonnzdwnitj
POE_CHAT_ID = 530922
POE_COOKIE = <your cookie>
POE_BOT_NAME = <bot name>
POE_BOT_MODEL = <bot model>
POE_CHANNEL = <bot channel>
POE_CHAT_ID = <bot chat id >
RUN_MODE = SSE
BACKEND_PORT = <backend port if not set default is 8090>
HTTP_PROXY = http://<host>:<port>
package main
import "github.com/isxuelinme/poe_unofficial_api/core"
func main() {
core.SetLogMode(core.LOG_ERROR)
MutLtiUser := core.NewMutLtiUserGpt(core.GptTypePoeUnofficial)
ask := &core.AskRequest{
UserId: 1, //your local user id
Question: "hi~ bro",
CallbackFuncName: "", //useless. Like JSONP or event name
// when message Coming from GPT, it will call this function
AskResponseCallBack: func(askRequest *core.AskRequest, response *core.CallbackMessageResponse) {
fmt.Printf("\r answer: %s", message.Data.Text)
},
}
//ask question
MutLtiUser.Talk(ask)
select {}
}
It's easy to use,However, you can use AskResponseCallBack to implement websocket or more protocol by yourself. learn more READ SSE IMPLEMENT
ask := &core.AskRequest{
UserId: 1,
Question: "hi~ bro",
CallbackFuncName: "",
AskResponseCallBack: func (askRequest *core.AskRequest, response *core.CallbackMessageResponse) {
<your business logiical code>
},
}
It has implemented multi-user, but it is not friendly to business and especially noobs, just for dev/test. So you have to read the code by yourself.
If you really have difficulty deploying or are not in the discord group, you can contact WeChat wangjian19830605
I am also implementing webUI by React, if you want try it plz wait a few hours or days