gpt4free
gpt4free copied to clipboard
chatforai missing fields make it impossible to run
Bug description
chatforai missing fields make it impossible to run
They have new fields that : conversationId and sign and timestamp.
If you don't pass the right value, they will return "https://chatforai.store"
根据这个代码:
if (e.conversationId !== "temp") {
const s = Date.now()
, n = e.messages?.[e.messages.length - 1]?.content || ""
, i = await generateSignature({
t: s,
m: n,
id: e.conversationId
});
r.sign = i,
r.timestamp = s
}
var sha256Exports = sha256.exports;
async function digestMessage(t) {
if (typeof crypto < "u" && crypto?.subtle?.digest) {
const e = new TextEncoder().encode(t)
, a = await crypto.subtle.digest("SHA-256", e);
return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2, "0")).join("")
} else
return sha256Exports.sha256(t).toString()
}
const generateSignature = async t=>{
const {t: e, m: a, id: r} = t
, s = `${e}:${r}:${a}:7YN8z6d6`;
return await digestMessage(s)
}
You can get the value of sign.
conversationId is ${t.id}_${Date.now()}
@xtekky if you need code, the code is
timestamp = int(time.time()*1000)
cls._conversation_id = "id_"+str(timestamp)
json_data["conversationId"] = cls._conversation_id
json_data["timestamp"] = int(time.time()*1000)
json_data["sign"] = generateSignature({"t":json_data["timestamp"],"m":messages[-1]
["content"],"id":json_data["conversationId"]})
def digestMessage(t):
if hasattr(hashlib, "sha256"):
e = t.encode()
a = hashlib.sha256(e).digest()
return "".join(format(x, "02x") for x in a)
else:
raise Exception("SHA-256 not supported")
def generateSignature(t):
e, a, r = t["t"], t["m"], t["id"]
s = f"{e}:{r}:{a}:7YN8z6d6"
return digestMessage(s)
i test it , everything is okey
They changed they Algo already 5 days ago. You are free to make a PR.
The website doesn't work anymore too. I disabled the provider in my PR.
Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.