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

add option to omit sending msg history with each openei completion #35

Closed
wants to merge 3 commits into from

Conversation

k3it
Copy link
Contributor

@k3it k3it commented Mar 3, 2023

@n3d1117
Copy link
Owner

n3d1117 commented Mar 4, 2023

Hi @k3it thanks for your contribution.

Indeed it looks like sending history also cosumes tokens.

However I don't see the point of the OMIT_MSG_HISTORY parameter you added. It's like resetting the chat on every message, losing all previous context. Would someone really use it? It may be cheaper but it's no longer a conversation.

Here's what the docs say:

Including the conversation history helps when user instructions refer to prior messages. [...] Because the models have no memory of past requests, all relevant information must be supplied via the conversation. If a conversation cannot fit within the model’s token limit, it will need to be shortened in some way.

On the other hand, I see the benefit in truncating the history. While I like your idea of removing elements from the top, I was wondering if we could use a separate ChatGPT instance to summarize and shorten it after its size reaches a cutoff value. Need to think about this. You can try and give it a shot if you have the time! I'll keep this PR open in the meantime

EDIT: Something like this here would be cool:

+ if len(self.sessions[chat_id]) > CUTOFF_SIZE:
+    summary  = /* somehow summarize the conversation in self.sessions[chat_id] */
+    self.reset_chat_history(chat_id)
+    self.__add_to_history(chat_id, role="assistant", content=summary)

self.__add_to_history(chat_id, role="user", content=query)

@k3it
Copy link
Contributor Author

k3it commented Mar 4, 2023

@n3d1117 I agree OMIT_MSG_HISTORY causes a severe short term amnesia in the bot and he becomes hard to deal with. Good idea about trying the summary approach. Also I wonder telegram group topics can work to keep multiple histories. this could mimic GPT web gui where we can have several parallel conversations with the bot.

@n3d1117
Copy link
Owner

n3d1117 commented Mar 5, 2023

Automatic summary generation added in 946f6a4. Closing this!

@n3d1117 n3d1117 closed this Mar 5, 2023
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

Successfully merging this pull request may close these issues.

Prompt token consumption grows until /reset
2 participants