Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What does parentId do in the code? #175

Open
MirzaHasnat opened this issue Aug 1, 2023 · 1 comment
Open

What does parentId do in the code? #175

MirzaHasnat opened this issue Aug 1, 2023 · 1 comment

Comments

@MirzaHasnat
Copy link

After reviewing and debugging the code, I'm unable to understand the purpose of parentId, since I want to add some message manually os I'm unable to use context in the class(I created for manual adding message),

for adding message manually to the chat I'm using sendMessage() method from chatManager class.

can someone explain why parentId is used for

@MirzaHasnat MirzaHasnat changed the title What does parentId for in the code? What does parentId do in the code? Aug 1, 2023
@cogentapps
Copy link
Owner

Good question! Each message in a chat is considered a 'reply' to the one above it. The parent ID is a reference to that earlier message.

If you're wondering why this is needed:

A message can have multiple replies (multiple messages with the same parent ID) when the Regenerate or Edit features are used. In both cases, a new message object is created with the same parent ID as the original. You can think of it like a tree structure. Whenever Regenerate or Edit is used, the tree of messages branches off in new directions.

Tracking the parent IDs makes it possible to list out a single path down through the branches of that tree, for display in the UI and also passing as context to the AI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants