terminalcommandnewsletter / everything-chatgpt

🔍 Explore what happens under the hood with the ChatGPT web app, its backend API calls and more. And some speculation, of course.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Misc: Where parent_message_id come from?

rendomnet opened this issue · comments

commented

Is there an existing issue for this?

  • I have searched the existing issues

Issue

In your example where parent_message_id and id values come from?

action: next
messages (Array):
|__ (Object):
|____ author (Object):
|______ role: user
|____ content (Object):
|______ content_type: text
|______ parts (Array):
|________ What is ChatGPT?
|__ id: 0c[redacted]91
|__ role: user
model: text-davinci-002-render-sha
parent_message_id: a0[redacted]7f

CONTRIBUTING.md

  • I have read the CONTRIBUTING.md
commented

It comes from the previous message in the conversation.

commented

@terminalcommandnewsletter Sorry I cant find the step where we create the conversation.

commented

See the "The process of asking ChatGPT a question" section.

commented

See the "The process of asking ChatGPT a question" section.

Yes and there is no call for creating the conversation.
In this section we already using the parent_message_id

commented

First, we make a POST request to /backend-api/conversation with a request body like this:

action: next
messages (Array):
|__ (Object):
|____ author (Object):
|______ role: user
|____ content (Object):
|______ content_type: text
|______ parts (Array):
|________ What is ChatGPT?
|__ id: 0c[redacted]91
|__ role: user
model: text-davinci-002-render-sha
parent_message_id: a0[redacted]7f

This responds with an EventStream which ends with a [DONE] signal. You can view a sample response in sample/conversation-event-stream.txt.

commented

First, we make a POST request to /backend-api/conversation with a request body like this:

action: next
messages (Array):
|__ (Object):
|____ author (Object):
|______ role: user
|____ content (Object):
|______ content_type: text
|______ parts (Array):
|________ What is ChatGPT?
|__ id: 0c[redacted]91
|__ role: user
model: text-davinci-002-render-sha
parent_message_id: a0[redacted]7f

This responds with an EventStream which ends with a [DONE] signal. You can view a sample response in sample/conversation-event-stream.txt.

Yes and where parent_message_id value come from?

commented

First, we make a POST request to /backend-api/conversation with a request body like this:

action: next
messages (Array):
|__ (Object):
|____ author (Object):
|______ role: user
|____ content (Object):
|______ content_type: text
|______ parts (Array):
|________ What is ChatGPT?
|__ id: 0c[redacted]91
|__ role: user
model: text-davinci-002-render-sha
parent_message_id: a0[redacted]7f

This responds with an EventStream which ends with a [DONE] signal. You can view a sample response in sample/conversation-event-stream.txt.

To make this request we first need to have parent_message_id and id values right?

commented

I'm currently not able to check. I'll check it once I can and get back to you.

commented

@terminalcommandnewsletter without this values post request returns error.

commented

@terminalcommandnewsletter Any updates on this?

commented

Hi! Sorry for the late response. The request (even on first message) already starts with a message ID and parent message ID.

I'm assuming this is generated on the client-side, though you can use any values as the message ID (changing the parent message ID to anything else returns an error "Hmm...something seems to have gone wrong." since that is used to link conversations) such as "13371337-1337-1337-1337-133713371337" and the server will correct it to use a different message ID (such as "f0[redacted]a0").

Hope this answers your question.

commented

This is quite interesting. When I refreshed the page and clicked on each conversation, I found 3 conversations all containing a message with an id of 13371337-1337-1337-1337-133713371337 which is just crazy 😆 (more so the multiple conversations with messages with the same ID).

Edit: Using a past message ID with this new message ID creates multiple conversations!

commented

@terminalcommandnewsletter It is peculiar that we generate these IDs on the client side as they may intersect. Additionally, it seems odd to generate the parent_message_id during the initial call. We should make sure to document this process.

commented

Agreed.

commented

Hi. Any updates on this? Why did you closed it.

commented

There's not much more information and the initial question you had was answered. If there's any related question you want to ask, feel free to comment that and I'll reopen the issue and solve.

commented

There's not much more information and the initial question you had was answered. If there's any related question you want to ask, feel free to comment that and I'll reopen the issue and solve.

After conducting my own research, I have come to the conclusion that when initiating a conversation, it is necessary to generate a message ID and a parent ID. However, I'm unsure of the exact purpose of the parent ID in the initial call. Subsequently, to obtain the conversation ID, we must make a call to the conversations endpoint and search for our specific conversation after our initial call.

commented

Yes. This is what the web app does. After the first message, it fetches the list of conversations and updates the sidebar. Then, it calls a generate title API and fetches the list again to update it.