OpenInterpreter / open-interpreter

A natural language interface for computers
http://openinterpreter.com/
GNU Affero General Public License v3.0
55.38k stars 4.82k forks source link

πŸ’» Unhandled error when loading model around litellm error raising and computer search func #1454

Open 6rz6 opened 2 months ago

6rz6 commented 2 months ago

Describe the bug

Unhandled errors with litellm

when an error with a model occurs for example wrong model name, openai/API balance deplated, too long context window feed into the model using --conversations -> litellm raises errors which are unhandled and instead of asking for a different model name, adjusting the context window dynamically, or asking to update the api key/recharge balance and press any key when done so if we like we can handle it for example replace the model or api key, we get thrown violently to the terminal:

raise BadRequestError(
litellm.exceptions.APIError: litellm.APIError: APIError: OpenAIException - Error code: 413 - {'error': {'code': 'tokens_limit_reached', 'message': 'Request body too large for gpt-4o model. Max size: 8000 tokens.

raise BadRequestError(
litellm.exceptions.BadRequestError: litellm.BadRequestError: OpenAIException - Error code: 400 - {'error': {'code': 'unknown_model', 'message': 'Unknown model: 01-preview', 'details': None}}

image

Unhandled errors with computer.browser.search

I have been getting errors from the computer from time to time (usually works well):

JSONDecodeError                           Traceback (most recent call last)                                                                                                                                      
  Cell In[3], line 2                                                                                                                                                                                               
        1 print('##active_line1##')                                                                                                                                                                                
  ----> 2 computer.browser.search('set_use_memory_efficient_attention_xformers error diffusers library')                                                                                                           

  File ~/.local/share/pipx/venvs/open-interpreter/lib/python3.12/site-packages/interpreter/core/computer/browser/browser.py:35, in Browser.search(self, query)                                                     
       28 """                                                                                                                                                                                                      
       29 Searches the web for the specified query and returns the results.                                                                                                                                        
       30 """                                                                                                                                                                                                      
       31 response = requests.get(                                                                                                                                                                                 
       32     f'{self.computer.api_base.strip("/")}/browser/search',                                                                                                                                               
       33     params={"query": query},                                                                                                                                                                             
       34 )                                                                                                                                                                                                        
  ---> 35 return response.json()["result"]                                                                                                                                                                         

  File ~/.local/share/pipx/venvs/open-interpreter/lib/python3.12/site-packages/requests/models.py:978, in Response.json(self, **kwargs)                                                                            
      974     return complexjson.loads(self.text, **kwargs)                                                                                                                                                        
      975 except JSONDecodeError as e:                                                                                                                                                                             
      976     # Catch JSON-related errors and raise as requests.JSONDecodeError                                                                                                                                    
      977     # This aliases json.JSONDecodeError and simplejson.JSONDecodeError                                                                                                                                   
  --> 978     raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)                                                                                                                                                   

  JSONDecodeError: Expecting value: line 1 column 1 (char 0)  

image

Reproduce

  1. use interpreter -m XXX with any random string
  2. run interpreter with a disfunctioning api key
  3. run out of credits rendering the api key disfunctional during run time

Expected behavior

allow to see the errors/log in -v (verbose)

  1. request a correct model name
  2. request (to) correct api key
  3. allow to fallback (wishlist feature for multiple models/api keys users) / Ask to update the model OR api key (critical OR not one of them, any can by the cause of the api failure which updating can lead to continuation)

Screenshots

Screenshot from 2024-09-14 00-36-19 Screenshot from 2024-09-14 00-33-38

Open Interpreter version

0.3.12

Python version

Python 3.12.3

Operating System name and version

ubuntu24.04LTS desktop

Additional context

πŸ’» computer.browser.search issue - the conversation file is attached try_to_serach_when_i__September_13_2024_23-34-59 (Copy).json

6rz6 commented 2 months ago

πŸ“‘ The computer.browser.search issue is with the API end point https://api.openinterpreter.com/v0 which returns 404:

curl -I https://api.openinterpreter.com/v0

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                                                                                                                    
                                   Dload  Upload   Total   Spent    Left  Speed                                                                                                                                    
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0                                                                                                                                   
    0    22    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0                                                                                                                                   
  HTTP/2 404                                                                                                                                                                                                       
  content-type: application/json                                                                                                                                                                                   
  x-cloud-trace-context: 2d5911e3877377bcfb2efebc7695d7a4;o=1                                                                                                                                                      
  content-length: 22                                                                                                                                                                                               
  date: Sat, 14 Sep 2024 03:15:10 GMT                                                                                                                                                                              
  server: Google Frontend                                                                                                                                                                                          

The API endpoint https://api.openinterpreter.com/v0 returned a 404 Not Found error

image