-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Patch summarize when running with local llms #213
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3656b31
trying to patch summarize when running with local llms
cpacker 7572658
moved token magic numbers to constants, made special localllm excepti…
cpacker 8203245
missing file
cpacker 3865c5b
raise an exception on no-op summary
cpacker 38893ae
changed summarization logic to walk forwards in list until fraction o…
cpacker 4141920
added same diff to sync agent
cpacker b3ff108
Merge branch 'main' into localllm-summarize-fix
cpacker 68087fe
reverted default max tokens to 8k, cleanup + more error wrapping for …
cpacker f9b5c47
patch for web UI context limit error propogation, using best guess fo…
cpacker 08ceeb7
add webui token length exception
vivi 82b34c8
remove print
cpacker b3595ac
make no wrapper warning only pop up once
cpacker 43b62d5
cleanup
vivi c9c47db
Add errors to other wrappers
vivi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class LLMError(Exception): | ||
"""Base class for all LLM-related errors.""" | ||
|
||
pass | ||
|
||
|
||
class LLMJSONParsingError(LLMError): | ||
"""Exception raised for errors in the JSON parsing process.""" | ||
|
||
def __init__(self, message="Error parsing JSON generated by LLM"): | ||
self.message = message | ||
super().__init__(self.message) | ||
|
||
|
||
class LocalLLMError(LLMError): | ||
"""Generic catch-all error for local LLM problems""" | ||
|
||
def __init__(self, message="Encountered an error while running local LLM"): | ||
self.message = message | ||
super().__init__(self.message) | ||
|
||
|
||
class LocalLLMConnectionError(LLMError): | ||
"""Error for when local LLM cannot be reached with provided IP/port""" | ||
|
||
def __init__(self, message="Could not connect to local LLM"): | ||
self.message = message | ||
super().__init__(self.message) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import json | ||
|
||
from .wrapper_base import LLMChatCompletionWrapper | ||
from ...errors import LLMJSONParsingError | ||
|
||
|
||
class Airoboros21Wrapper(LLMChatCompletionWrapper): | ||
|
@@ -186,8 +187,11 @@ def output_to_chat_completion_response(self, raw_llm_output): | |
function_json_output = json.loads(raw_llm_output) | ||
except Exception as e: | ||
raise Exception(f"Failed to decode JSON from LLM output:\n{raw_llm_output}") | ||
function_name = function_json_output["function"] | ||
function_parameters = function_json_output["params"] | ||
try: | ||
function_name = function_json_output["function"] | ||
function_parameters = function_json_output["params"] | ||
except KeyError as e: | ||
raise LLMJSONParsingError(f"Received valid JSON from LLM, but JSON was missing fields: {str(e)}") | ||
|
||
if self.clean_func_args: | ||
function_name, function_parameters = self.clean_function_args(function_name, function_parameters) | ||
|
@@ -395,8 +399,11 @@ def output_to_chat_completion_response(self, raw_llm_output): | |
function_json_output = json.loads(raw_llm_output + "\n}") | ||
except: | ||
raise Exception(f"Failed to decode JSON from LLM output:\n{raw_llm_output}") | ||
function_name = function_json_output["function"] | ||
function_parameters = function_json_output["params"] | ||
try: | ||
function_name = function_json_output["function"] | ||
function_parameters = function_json_output["params"] | ||
except KeyError as e: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes should be put in the other wrappers too |
||
raise LLMJSONParsingError(f"Received valid JSON from LLM, but JSON was missing fields: {str(e)}") | ||
|
||
if self.clean_func_args: | ||
( | ||
|
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vivi you can test that this works by intentionally lowering LLM_MAX_TOKENS + lowering it on the web UI backend