From a19ebac7fd87a93064ec6e8ab027f8044041e6f3 Mon Sep 17 00:00:00 2001 From: jinno Date: Sat, 1 Jun 2024 21:32:55 +0900 Subject: [PATCH] fix: Add llm_modify_params to avoid AnthropicException --- docs/settings/all-settings.mdx | 43 ++++++++++++++++++- interpreter/core/core.py | 2 + interpreter/core/llm/llm.py | 2 + .../profiles/defaults/default.yaml | 3 +- .../profiles/defaults/fast.yaml | 3 +- .../start_terminal_interface.py | 21 ++++++--- 6 files changed, 64 insertions(+), 10 deletions(-) diff --git a/docs/settings/all-settings.mdx b/docs/settings/all-settings.mdx index a8aa9f66b4..347e6d31e8 100644 --- a/docs/settings/all-settings.mdx +++ b/docs/settings/all-settings.mdx @@ -805,4 +805,45 @@ computer.import_computer_api: True ``` -```` + +### LLM Drop Params + +Inform llm to drop unknown params like "functions". +It supports to easy debug of llm errors. + + + +```bash Terminal +interpreter --llm_drop_params +``` + +```python Python +interpreter.llm_drop_params = True +``` + +```yaml Profile +llm_drop_params: true +``` + + + +### LLM Modify Params + +Inform llm to modify params or messages. +It supports to easy debug of llm errors. + + + +```bash Terminal +interpreter --llm_modify_params +``` + +```python Python +interpreter.llm_modify_params = True +``` + +```yaml Profile +llm_modify_params: true +``` + + diff --git a/interpreter/core/core.py b/interpreter/core/core.py index 977348c8bf..34a306768d 100644 --- a/interpreter/core/core.py +++ b/interpreter/core/core.py @@ -80,6 +80,7 @@ def __init__( multi_line=False, contribute_conversation=False, llm_drop_params=False, + llm_modify_params=False, ): # State self.messages = [] if messages is None else messages @@ -99,6 +100,7 @@ def __init__( self.multi_line = multi_line self.contribute_conversation = contribute_conversation self.llm_drop_params = llm_drop_params + self.llm_modify_params = llm_modify_params # Loop messages self.loop = loop diff --git a/interpreter/core/llm/llm.py b/interpreter/core/llm/llm.py index 55c75a4876..5a3a944010 100644 --- a/interpreter/core/llm/llm.py +++ b/interpreter/core/llm/llm.py @@ -261,6 +261,8 @@ def run(self, messages): litellm.set_verbose = True if self.interpreter.llm_drop_params: litellm.drop_params = True + if self.interpreter.llm_modify_params: + litellm.modify_params = True if self.interpreter.debug: print("\n\n\nOPENAI COMPATIBLE MESSAGES\n\n\n") diff --git a/interpreter/terminal_interface/profiles/defaults/default.yaml b/interpreter/terminal_interface/profiles/defaults/default.yaml index ae9aadcb07..0b1e585cec 100644 --- a/interpreter/terminal_interface/profiles/defaults/default.yaml +++ b/interpreter/terminal_interface/profiles/defaults/default.yaml @@ -24,7 +24,8 @@ computer: # offline: False # If True, will disable some online features like checking for updates # verbose: False # If True, will print detailed logs # multi_line: False # If True, you can input multiple lines starting and ending with ``` -# llm_drop_params: False # If True, litellm.drop_params=True, Drop any unmapped params ``` +# llm_drop_params: False # If True, litellm.drop_params=True, Drop any unmapped params +# llm_modify_params: False # If True, litellm.drop_params=True, Modify params or messages # Documentation # All options: https://docs.openinterpreter.com/settings diff --git a/interpreter/terminal_interface/profiles/defaults/fast.yaml b/interpreter/terminal_interface/profiles/defaults/fast.yaml index 716017f0fa..ebc2d2e091 100644 --- a/interpreter/terminal_interface/profiles/defaults/fast.yaml +++ b/interpreter/terminal_interface/profiles/defaults/fast.yaml @@ -20,7 +20,8 @@ custom_instructions: "The user has set you to FAST mode. **No talk, just code.** # offline: False # If True, will disable some online features like checking for updates # verbose: False # If True, will print detailed logs # multi_line: False # If True, you can input multiple lines starting and ending with ``` -# llm_drop_params: False # If True, litellm.drop_params=True, Drop any unmapped params ``` +# llm_drop_params: False # If True, litellm.drop_params=True, Drop any unmapped params +# llm_modify_params: False # If True, litellm.drop_params=True, Modify params or messages # All options: https://docs.openinterpreter.com/settings diff --git a/interpreter/terminal_interface/start_terminal_interface.py b/interpreter/terminal_interface/start_terminal_interface.py index 4e733aad97..14ba20ff15 100644 --- a/interpreter/terminal_interface/start_terminal_interface.py +++ b/interpreter/terminal_interface/start_terminal_interface.py @@ -194,13 +194,6 @@ def start_terminal_interface(interpreter): "type": bool, "attribute": {"object": interpreter, "attr_name": "multi_line"}, }, - { - "name": "llm_drop_params", - "nickname": "ldp", - "help_text": "set litellm.drop_params=True, Drop any unmapped params", - "type": bool, - "attribute": {"object": interpreter, "attr_name": "llm_drop_params"}, - }, { "name": "local", "nickname": "l", @@ -272,6 +265,20 @@ def start_terminal_interface(interpreter): "attr_name": "contribute_conversation", }, }, + { + "name": "llm_drop_params", + "nickname": "ldp", + "help_text": "set litellm.drop_params=True, Drop any unmapped params", + "type": bool, + "attribute": {"object": interpreter, "attr_name": "llm_drop_params"}, + }, + { + "name": "llm_modify_params", + "nickname": "lmp", + "help_text": "set litellm.modify_params=True, Modify params or messages", + "type": bool, + "attribute": {"object": interpreter, "attr_name": "llm_modify_params"}, + }, ] # Check for deprecated flags before parsing arguments