-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* patching for non-gpt model * removal of json_object tool name assignment * fixed issue for smaller models due to instructions prompt * fixing for ollama llama3 models * WIP: generated summary from documents split, could also create memgpt approach * WIP: need tests but user inputted summarization strategy implemented - handling context window exceeding errors * rm extra line * removed type ignores * added tests * handling n to summarize prompt * code cleanup, using click for cli asker * rm not used class * better refactor * reverted poetry lock * reverted poetry.locl * improved context window exceeding exception class
- Loading branch information
1 parent
c93b85a
commit 8118b7b
Showing
7 changed files
with
572 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/crewai/utilities/exceptions/context_window_exceeding_exception.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class LLMContextLengthExceededException(Exception): | ||
CONTEXT_LIMIT_ERRORS = [ | ||
"maximum context length", | ||
"context length exceeded", | ||
"context_length_exceeded", | ||
"context window full", | ||
"too many tokens", | ||
"input is too long", | ||
"exceeds token limit", | ||
] | ||
|
||
def __init__(self, error_message: str): | ||
self.original_error_message = error_message | ||
super().__init__(self._get_error_message(error_message)) | ||
|
||
def _is_context_limit_error(self, error_message: str) -> bool: | ||
return any( | ||
phrase.lower() in error_message.lower() | ||
for phrase in self.CONTEXT_LIMIT_ERRORS | ||
) | ||
|
||
def _get_error_message(self, error_message: str): | ||
return ( | ||
f"LLM context length exceeded. Original error: {error_message}\n" | ||
"Consider using a smaller input or implementing a text splitting strategy." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.