Skip to content

Conversation

Reetkapoor
Copy link
Contributor

@Reetkapoor Reetkapoor commented Jul 22, 2025

closes: #1

What was done:

1. Persistent storage

  • Introduced two utility functions: save_conversations() and load_conversations() in core/utils.py to handle reading/writing the conversations to a JSON file (data/conversations.json).
  • Ensured directory creation (os.makedirs) if data/ doesn't exist.

2. Session State Sync:

  • Modified TalkHeal.py to load saved conversations on app start using load_conversations().
  • Ensured conversations are written to disk after every message via save_conversations() in chat_interface.py.

3. Conversational Context Handling:

  • Enhanced get_ai_response() flow to include up to 20 previous messages (10 turns) of user-bot exchanges as prompt context.
  • A helper format_memory_for_prompt() was added to structure context in a readable, role-separated format.

4. Testing

  • Functionality has been tested locally!

@Reetkapoor Reetkapoor changed the title Added persistent memory support for chat Added persistent memory support for chat #1 Jul 23, 2025
@Reetkapoor Reetkapoor changed the title Added persistent memory support for chat #1 Added persistent memory support for chat Jul 23, 2025
@eccentriccoder01
Copy link
Owner

  • There has been a latest PR merge... Please pull the latest changes and resend the PR.
  • After that, please provide your deployment link or relevant screenshots of your working PR.

Thanks for your efforts in improving TalkHeal.

@Reetkapoor
Copy link
Contributor Author

Reetkapoor commented Jul 23, 2025

All the latest changes has been pulled.

Here is the deployment link- 🔗 View Live Demo

Screenshots of conversation :

Earlier:

image

Now:

image

@eccentriccoder01
Copy link
Owner

Hey @Reetkapoor...

  • The timing isn't synced properly with the local time, as has been implemented by @Aastha-1411 in PR Fix Timestamp issue in chat interface #14.
  • The problem with this feature enhancement is that it returns whatever previous messages have been in the bot exchange, there is no user-based or at least device-based privacy.
  • The access to previous chats also overrules the convo delete feature. If I delete a previous convo, it goes away, but refreshing the page fetches it back, effectively making the delete feature useless.

What I could see from other issues is that other contributors are already working on user based authentication features. So instead of implementing that, would it be possible for you to incorporate at least a device/IP based privacy for the chats?

Also this is just a discussion/suggestion from my side, to figure out if it's actually possible. If not, then just fix the 1st and 3rd points, I'll merge the PR and we can keep the 2nd point fix for another issue.

Thanks for your time, patience and efforts in improving TalkHeal❕

@Reetkapoor
Copy link
Contributor Author

Hello, @eccentriccoder01
Thanks for the suggestions
I've updated the delete conversation option so that chats don't load back again. Also, pulled the changes made by other contributors.

You can check here, Demo

@eccentriccoder01
Copy link
Owner

@Reetkapoor That's great❕And is the message history IP or device specific now❔

@Reetkapoor
Copy link
Contributor Author

@eccentriccoder01 I explored IP-based isolation but it's not truly private, since users on the same network share the same memory. If you have a preferred approach, i'd be happy to implement it.

@eccentriccoder01
Copy link
Owner

@Reetkapoor No issues, it's perfectly fine. PR #23 has recently been merged, there's a change in one file. Pull and resolve it quickly and I'll merge your PR!

@Reetkapoor
Copy link
Contributor Author

@eccentriccoder01 Done !
You can check here- Demo

@eccentriccoder01
Copy link
Owner

Awesome work! Thanks for your patience and efforts in improving TalkHeal @Reetkapoor !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gssoc25 level 3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chatbot lacks contextual memory despite README claim
2 participants