chatgpt-api: res.id lost in version^5.0.6, we can not track the conversation.
Verify latest release
- I verified that the issue exists in the latest
chatgptrelease
Verify webapp is working
- I verify that the ChatGPT webapp is working properly for this account.
Environment details
version@5.0.6
Describe the Bug
res.id lost in version^5.0.6, we can not track the conversation. the response is :
{
errCode: 0,
msg: '',
data: { text: 'Hello! How can I assist you today?' }
}
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 17 (3 by maintainers)
res.id is still not work. what does res.id and res.parentMessageId means?
Whether I use the reply.parentMessageId or reply.id as the next request’s parentMessageId, chatgpt can always dont know what I asked past, this is a bug.
It also doesn’t work for me, It looks like the request that’s getting sent to the ChatGPT API is correct (it contains the whole conversation history) but the bot always insists that it doesn’t remember what was going on before. Anyone else having this kind of issue?
Problem Solved
The problem is solved, because my code is not perfect, so there is an error above the API request, this error causes the code of Next.js to be recompiled, so ChatGPTAPI is also reinitialized, naturally it will forget the conversation, if you encounter similar problems, please troubleshoot two aspects:
Thanks @maciej-trebacz for the reminder.
may be using the offical API is the best way now: https://platform.openai.com/docs/guides/chat
In my case, the problem was that I was initializing a new instance of the ChatGPTAPI class every time through a factory. As a result, every time I initialized it, my keyv instance, which stores message history, was reset. Initializing keyv outside of my factory and passing the instance through messageStore in the constructor of ChatGPTAPI helped me.
@maciej-trebacz @BigBroFinch may be due to the differences in the ChatGPT webapp’s behavior versus the behavior of the Chat completions API. I’d love to try and improve support here, though.
Can you paste some example conversations (
messagesJSON by enablingdebugmode) where you’re seeing unexpected outputs? That will help me try and reproduce the issue and give better advice or make changes to the lib.Thanks!