Skip to content
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

JSONDecodeError when attempting to get data from the web #240

Open
contractorwolf opened this issue Apr 14, 2024 · 1 comment
Open

JSONDecodeError when attempting to get data from the web #240

contractorwolf opened this issue Apr 14, 2024 · 1 comment

Comments

@contractorwolf
Copy link

Describe the bug
I have the latest version of the server and am running the build-it-yourself device but it seems to have a LOT of trouble trying to grab new data from the web. It can answer basic historical questions and stuff that i would expect chatGPT to have already built into the model. But when i try to get new data, by asking questions like: "what is the weather going to be like tomorrow in charlotte, nc? it seems to have issues. If i am looking at the console on the machine that is running the server it seems to hit this error over and over until it runs out of tokens:

  JSONDecodeError                           Traceback (most recent call last)                                                      
  Cell In[71], line 6                                                                                                              
        4 pass                                                                                                                     
        5 print('##active_line3##')                                                                                                
  ----> 6 search_results = computer.browser.search('Ankylosaurus')                                                                 
        7 print('##active_line4##')                                                                                                
        8 search_results                                                                                                           
                                                                                                                                   
  File ~/miniconda3/envs/01/lib/python3.10/site-packages/interpreter/core/computer/browser/browser.py:16, in Browser.search(self,  
  query)                                                                                                                           
        9 """                                                                                                                      
       10 Searches the web for the specified query and returns the results.                                                        
       11 """                                                                                                                      
       12 response = requests.get(                                                                                                 
       13     f'{self.computer.api_base.strip("/")}/browser/search',                                                               
       14     params={"query": query},                                                                                             
       15 )                                                                                                                        
  ---> 16 return response.json()["result"]                                                                                         
                                                                                                                                   
  File ~/miniconda3/envs/01/lib/python3.10/site-packages/requests/models.py:975, in Response.json(self, **kwargs)                  
      971     return complexjson.loads(self.text, **kwargs)                                                                        
      972 except JSONDecodeError as e:                                                                                             
      973     # Catch JSON-related errors and raise as requests.JSONDecodeError                                                    
      974     # This aliases json.JSONDecodeError and simplejson.JSONDecodeError                                                   
  --> 975     raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)                                                                   
                                                                                                                                   
  JSONDecodeError: Expecting value: line 2 column 1 (char 1)  

It seems to try a bunch of ways to get the information but always has issues and eventually gives up and apologizes.

Expected behavior
I would expect it to be able to retrieve data from the web

Screenshots
Screenshot 2024-04-14 at 5 23 07 PM

Desktop (please complete the following information):

  • OS: Mac (M1 Mackbook Pro)
  • Python Version: 3.10
@fspacheco
Copy link

I have the same problem: computer.api_base points to https://api.openinterpreter.com/v0/ that is broken. For the moment, I added an alternative search using Google in interpreter/core/computer/browser/browser.py

import requests


class Browser:
    def __init__(self, computer):
        self.computer = computer

    def search(self, query):
        """
        Searches the web for the specified query and returns the results.
        """
        try:
            response = requests.get(
                f'{self.computer.api_base.strip("/")}/browser/search',
                params={"query": query},
            )
            return response.json()["result"]
        except:
            try:
                print("Error in OI API. Trying with Google search")
                import googlesearch
                import json
                response = googlesearch.search(query, tld="com", num=1, stop=1, pause=1)
                for r in response:
                    json_response = json.dumps({'result':r})
                return json_response
            except:
                print("Error in Google search")

ch33nchan added a commit to ch33nchan/01 that referenced this issue Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants