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

Feature/limit fix: maximum context length limit #580 #581

Closed

Conversation

longyanjiang
Copy link

There is a scenario where, assuming our model supports 4096 tokens, we set _maxModelTokens to 3096 and _maxResponseTokens to 1000. Before we check prompt && !isValidPrompt, we have already assigned a value to the message variable, which means that our context will definitely exceed the _maxModelTokens limit. If _maxModelTokens exceeds by a lot, for example, up to 3880, any subsequent response in the conversation that exceeds 400 tokens will result in a context error. Therefore, when we detect this, we need to remove the first item from the context, which is the second item in the systemMessage array, and calculate whether it still exceeds the limit. We need to recursively remove items until the context length is within our set safe limit, in order to ensure that no context errors occur.

[https://github.com/https://github.com//issues/542](Make maximum context length limit )

@transitive-bullshit
Copy link
Owner

This project is undergoing a major revamp; closing out old PRs as part of the prep process.

This was a good change, but the chatgpt package is pretty outdated at this point. I recommend that you use the openai package or the openai-fetch package.

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

2 participants