Skip to content

Instantly share code, notes, and snippets.

@simonw
Created November 24, 2024 18:01
Show Gist options
  • Save simonw/f78a2ebd2e06b821192ec919639959e6 to your computer and use it in GitHub Desktop.
Save simonw/f78a2ebd2e06b821192ec919639959e6 to your computer and use it in GitHub Desktop.
% uvx --from open-interpreter interpreter

●                                                                                             

Welcome to Open Interpreter.                                                                  

──────────────────────────────────────────────────────────────────────────────────────────────

▌ OpenAI API key not found                                                                  

To use gpt-4o (recommended) please provide an OpenAI API key.                                 

To use another language model, run interpreter --local or consult the documentation at        
docs.openinterpreter.com.                                                                     

──────────────────────────────────────────────────────────────────────────────────────────────

OpenAI API key: ***************************************************


Tip: To save this key for later, run one of the following and then restart your terminal.     
MacOS: echo 'export OPENAI_API_KEY=your_api_key' >> ~/.zshrc                                  
Linux: echo 'export OPENAI_API_KEY=your_api_key' >> ~/.bashrc                                 
Windows: setx OPENAI_API_KEY your_api_key                                                     

──────────────────────────────────────────────────────────────────────────────────────────────

▌ Model set to gpt-4o                                                                       


──────────────────────────────────────────────────────────────────────────────────────────────

▌ We're training an open-source language model.                                             

Want to contribute? Run interpreter --model i to use our free, hosted model. Conversations    
with this i model will be used for training.                                                  


Open Interpreter will require approval before running code.                                   

Use interpreter -y to bypass this.                                                            

Press CTRL-C to exit.                                                                                                                                                         
                                                                                              
> find largest files on my desktop
                                                                                              
  To find the largest files on your desktop, I will develop a plan with the necessary steps   
  and then proceed to execute the required code step by step.                                 
                                                                                              
                                             Plan                                             
                                                                                              
   1 Find the Desktop Path: Determine the path to the Desktop directory for the current       
     user.                                                                                    
   2 List Files on Desktop: Traverse the Desktop to find all files and directories.           
   3 Calculate Sizes: Find the size of each file.                                             
   4 Sort by Size: Sort the files based on size to identify the largest ones.                 
   5 Display Results: Show the top largest files.                                             
                                                                                              
  Let's begin with the first step to find the path to the Desktop directory.                  
                                                                                              

                                                                                              
  import os                                                                                   
                                                                                              
  desktop_path = os.path.join(os.path.expanduser('~'), 'Desktop')                             
  desktop_path                                                                                
                                                                                              

  Would you like to run this code? (y/n)

  y

                                                                                              
  import os                                                                                   
                                                                                              
  desktop_path = os.path.join(os.path.expanduser('~'), 'Desktop')                             
  desktop_path                                                                                
                                                                                              
                                                                                              
  '/Users/simon/Desktop'                                                                      
                                                                                              
                                                                                              
  The path to your Desktop is /Users/simon/Desktop. Next, I'll list all the files and         
  directories on your Desktop and calculate their sizes. Let's proceed with that.             
                                                                                              

                                                                                              
  import os                                                                                   
                                                                                              
  # Get the size of the file                                                                  
  file_sizes = {}                                                                             
                                                                                              
  desktop_path = '/Users/simon/Desktop'                                                       
                                                                                              
  for root, dirs, files in os.walk(desktop_path):                                             
      for name in files:                                                                      
          file_path = os.path.join(root, name)                                                
          # Get the size and store it in the dictionary                                       
          file_sizes[file_path] = os.path.getsize(file_path)                                  
                                                                                              
  # Sort files by size in descending order                                                    
  sorted_files = sorted(file_sizes.items(), key=lambda item: item[1], reverse=True)           
                                                                                              
  # Get the largest 5 files                                                                   
  largest_files = sorted_files[:5]                                                            
  largest_files                                                                               
                                                                                              

  Would you like to run this code? (y/n)

  y

                                                                                              
  import os                                                                                   
                                                                                              
  # Get the size of the file                                                                  
  file_sizes = {}                                                                             
                                                                                              
  desktop_path = '/Users/simon/Desktop'                                                       
                                                                                              
  for root, dirs, files in os.walk(desktop_path):                                             
      for name in files:                                                                      
          file_path = os.path.join(root, name)                                                
          # Get the size and store it in the dictionary                                       
          file_sizes[file_path] = os.path.getsize(file_path)                                  
                                                                                              
  # Sort files by size in descending order                                                    
  sorted_files = sorted(file_sizes.items(), key=lambda item: item[1], reverse=True)           
                                                                                              
  # Get the largest 5 files                                                                   
  largest_files = sorted_files[:5]                                                            
  largest_files                                                                               
                                                                                              
                                                                                              
  [('/Users/simon/Desktop/Archive/Screen Recording 2024-04-28 at 10.37.20\u202fAM.mov',       
    4063162333),                                                                              
   ('/Users/simon/Desktop/Archive/simon-Gergely-Orosz-podcast.mp4', 1179622482),              
   ('/Users/simon/Desktop/Archive/Descript Recording 2023-12-01 09.58.25.696/screen.mp4',     
    1014406246),                                                                              
   ('/Users/simon/Desktop/Archive/Screen Recording 2024-04-28 at 11.03.15\u202fAM.mov',       
    355885342),                                                                               
   ('/Users/simon/Desktop/Archive/Screen Recording 2024-06-19 at 8.37.57\u202fPM.mov',        
    289760967)]                                                                               
                                                                                              
                                                                                              
  Here are the largest files on your Desktop:                                                 
                                                                                              
   1 Screen Recording 2024-04-28 at 10.37.20 AM.mov - 4.06 GB                                 
   2 Gergely-Orosz-podcast.mp4 - 1.18 GB                                                      
   3 Descript Recording 2023-12-01 09.58.25.696/screen.mp4 - 1.01 GB                          
   4 Screen Recording 2024-04-28 at 11.03.15 AM.mov - 355.89 MB                               
   5 Screen Recording 2024-06-19 at 8.37.57 PM.mov - 289.76 MB                                
                                                                                              
  If you need more information or further assistance, feel free to ask!                       
                                                                                              
> 
@simonw
Copy link
Author

simonw commented Nov 24, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment