This repository was archived by the owner on Sep 3, 2025. It is now read-only.
Truncate GenAI prompt if this exceeds 128k tokens #5774
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements Changes
tiktokenpackage to requirementsaiohappyeyeballsfrom 2.4.4 to 2.4.6aiohttpfrom 3.11.11 to 3.11.12boto3from 1.36.13 to 1.36.19botocorefrom 1.36.13 to 1.36.19google-api-python-clientfrom 2.160.0 to 2.161.0numpyfrom 2.2.2 to 2.2.3openaifrom 1.61.0 to 1.62.0Functional Changes in
src/dispatch/ai/service.pyMAX_TOKENS = 128000constantAdded
num_tokens_from_string(message: str, model: str) -> tuple[list[int], int, tiktoken.Encoding]Added
truncate_prompt(tokenized_prompt: list[int], num_tokens: int, encoding: tiktoken.Encoding) -> strUpdated
generate_case_signal_summaryUpdated
generate_incident_summaryKey Improvements
The changes primarily focus on managing token limits in AI prompts and updating dependencies to their latest versions.