dtinth / ThreadGPT

Alternative frontend to ChatGPT (gpt-3.5-turbo / gpt-4) with a thread-based interface
https://threadgpt.vercel.app
80 stars 23 forks source link

allow tweaking message #9

Closed kiznick closed 1 year ago

kiznick commented 1 year ago

This PR for #4

Now Tweak message is working but I don't know how to find parent node This is my solution 1) add key "parent" to db (it will make old data can't tweak) 2) loop to all record, For example I have to find T3-1's parent

 - root
   - T1
      - T1-1
      - T1-2
      - T1-3
   - T2
      - T2-1
   - T3
      - T3-1
      - T3-2

I have to loop in root to check all threat name, if not found I need to loop in every root's child to find T3-1

Do you have any other suggestions or which method should I use?

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
thread-gpt ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 11, 2023 at 6:49AM (UTC)
dtinth commented 1 year ago

@kiznick IMO the thread doesn’t need to know its parent. Here’s how I might implement the feature:

Note that when tweaking a message, it’s supposed to create a copy in the parent.

However, note that once a message is created, it cannot be changed. So it may be enough to just copy the base message into the parent’s CreateForm.

kiznick commented 1 year ago

Now, I can add Tweak message to parent, thanks to @dtinth, but idk why new message not appear until refresh

dtinth commented 1 year ago

Thanks for the implementation krub! 🙏 The addition of defaultValue and defaultRole to the form is very helpful.

To answer your question, when the parent is changed, the parent needs to call query.refetch() to reload the new data from IndexedDB. (It requires coordination with parent component.)

I went ahead and made a few further changes on top:

Thanks for contributing krub!