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

New strategy for collecting messages and improvements to ReAct agent and message passing #305

Merged
merged 14 commits into from Aug 10, 2023

Conversation

raulraja
Copy link
Contributor

@raulraja raulraja commented Aug 8, 2023

This PR contains a new strategy for collecting messages by the maximum tokens for the model.

Basically, when we have to send messages to OpenAI we can get the messages from 3 places:

  • New Messages: they are the messages that we are sending. These messages always should be sent if you don't have tokens for this, we will receive an AIError exception
  • History: they are the previous messages in the conversation
  • Context: they are documents in the VectorStore, for example, if you loaded a PDF

In the new strategy, fitMessagesByTokens method, we are calculating the remaining messages, removing the tokens for the OpenAI response and the tokens for the new messages that are required.

When we have the remaining token, we are using 50% of the token for the history messages and the other 50% for the documents in the VectorStore

In future PRs, we can add the percentage for every context in the PromptConfiguration

@javipacheco javipacheco changed the title Improvements to ReAct agent and message passing New strategy for collecting messages and improvements to ReAct agent and message passing Aug 9, 2023
Copy link
Contributor

@jackcviers-contractor jackcviers-contractor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this is comments, except the fold right.

Montagon
Montagon previously approved these changes Aug 10, 2023
Copy link
Contributor

@Montagon Montagon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@raulraja raulraja merged commit b85c50e into main Aug 10, 2023
5 checks passed
@raulraja raulraja deleted the improvements-to-react-agent branch August 10, 2023 09:00
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.

None yet

4 participants