Skip to content

Commit

Permalink
fix: Add llm_modify_params to avoid AnthropicException
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu007 committed Jun 25, 2024
1 parent f28b043 commit a19ebac
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 10 deletions.
43 changes: 42 additions & 1 deletion docs/settings/all-settings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -805,4 +805,45 @@ computer.import_computer_api: True
```

</CodeGroup>
````

### LLM Drop Params

Inform llm to drop unknown params like "functions".
It supports to easy debug of llm errors.

<CodeGroup>

```bash Terminal
interpreter --llm_drop_params
```

```python Python
interpreter.llm_drop_params = True
```

```yaml Profile
llm_drop_params: true
```

</CodeGroup>

### LLM Modify Params

Inform llm to modify params or messages.
It supports to easy debug of llm errors.

<CodeGroup>

```bash Terminal
interpreter --llm_modify_params
```

```python Python
interpreter.llm_modify_params = True
```

```yaml Profile
llm_modify_params: true
```

</CodeGroup>
2 changes: 2 additions & 0 deletions interpreter/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions interpreter/core/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion interpreter/terminal_interface/profiles/defaults/fast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 14 additions & 7 deletions interpreter/terminal_interface/start_terminal_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a19ebac

Please sign in to comment.