From f4a9f2ca90cd026804f3a87ca52afc87a5966bc8 Mon Sep 17 00:00:00 2001 From: jinno Date: Sat, 27 Apr 2024 10:45:07 +0900 Subject: [PATCH] Add llm_drop_params setting to avoid AnthropicException litellm.drop_params=True can avoid this error. Error in chat: AnthropicException - anthropic does not support parameters --- docs/settings/all-settings.mdx | 22 ++++++++++++++++++- interpreter/core/core.py | 4 +++- interpreter/core/llm/llm.py | 2 ++ .../profiles/defaults/default.yaml | 1 + .../profiles/defaults/fast.yaml | 1 + .../start_terminal_interface.py | 7 ++++++ 6 files changed, 35 insertions(+), 2 deletions(-) diff --git a/docs/settings/all-settings.mdx b/docs/settings/all-settings.mdx index 93d6e1013b..99a5430b30 100644 --- a/docs/settings/all-settings.mdx +++ b/docs/settings/all-settings.mdx @@ -297,7 +297,6 @@ llm: For HTML: This will be run STATELESSLY. You may NEVER write '' or `` or anything like that. It is CRITICAL TO NEVER WRITE PLACEHOLDERS. Placeholders will BREAK it. You must write the FULL HTML CODE EVERY TIME. Therefore you cannot write HTML piecemeal—write all the HTML, CSS, and possibly Javascript **in one step, in one code block**. The user will help you review it visually. If the user submits a filepath, you will also see the image. The filepath and user image will both be in the user's message. If you use `plt.show()`, the resulting image will be sent to you. However, if you use `PIL.Image.show()`, the resulting image will NOT be sent to you. - ``` @@ -694,3 +693,24 @@ computer.emit_images: 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 +``` + + diff --git a/interpreter/core/core.py b/interpreter/core/core.py index 3a98f78b31..dc1d41a3eb 100644 --- a/interpreter/core/core.py +++ b/interpreter/core/core.py @@ -73,7 +73,8 @@ def __init__( skills_path=None, import_skills=False, multi_line=False, - contribute_conversation=False + contribute_conversation=False, + llm_drop_params=False, ): # State self.messages = [] if messages is None else messages @@ -92,6 +93,7 @@ def __init__( self.in_terminal_interface = in_terminal_interface self.multi_line = multi_line self.contribute_conversation = contribute_conversation + self.llm_drop_params = llm_drop_params # Loop messages self.force_task_completion = force_task_completion diff --git a/interpreter/core/llm/llm.py b/interpreter/core/llm/llm.py index 04512131a8..46d553fead 100644 --- a/interpreter/core/llm/llm.py +++ b/interpreter/core/llm/llm.py @@ -202,6 +202,8 @@ def run(self, messages): litellm.max_budget = self.max_budget if self.interpreter.verbose: litellm.set_verbose = True + if self.interpreter.llm_drop_params: + litellm.drop_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 3151f24036..9ae9b4a668 100644 --- a/interpreter/terminal_interface/profiles/defaults/default.yaml +++ b/interpreter/terminal_interface/profiles/defaults/default.yaml @@ -20,6 +20,7 @@ llm: # 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 ``` # 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 061bd87267..74f863f839 100644 --- a/interpreter/terminal_interface/profiles/defaults/fast.yaml +++ b/interpreter/terminal_interface/profiles/defaults/fast.yaml @@ -16,6 +16,7 @@ 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 ``` # 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 6873b7ff08..79abaf326f 100644 --- a/interpreter/terminal_interface/start_terminal_interface.py +++ b/interpreter/terminal_interface/start_terminal_interface.py @@ -192,6 +192,13 @@ 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",