openai_101 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.releaserc.json +1 -1
 - data/.rubocop.yml +24 -7
 - data/.tool-versions +1 -1
 - data/CHANGELOG.md +11 -4
 - data/README.md +65 -41
 - data/bin/automate-chatgpt.js +60 -0
 - data/bin/automate-midjourney.js +75 -0
 - data/bin/convert_webp_to_png.rb +86 -0
 - data/bin/gpt_context_gatherer.rb +63 -0
 - data/course/course.md +64 -0
 - data/course/images/beautiful-llm-models.png +0 -0
 - data/course/images/prompts/beautiful-llm-models.txt +1 -0
 - data/course/images/prompts/series-2-appydave-gpt-summit.txt +1 -0
 - data/course/images/series-2-appydave-gpt-summit.png +0 -0
 - data/gpt-context/openai-documentation.md +498 -0
 - data/gpt-context/ruby-openai-documenation.md +747 -0
 - data/gpt-context/theme-prompts.csv +21 -0
 - data/lib/openai_101/config/openai.rb +15 -0
 - data/lib/openai_101/tools/automate-images-chatgpt.js +60 -0
 - data/lib/openai_101/tools/automate-images-midjourney.js +75 -0
 - data/lib/openai_101/tools/bulk_image_bot/base_automator.js +53 -0
 - data/lib/openai_101/tools/bulk_image_bot/chatgpt_automator.js +27 -0
 - data/lib/openai_101/tools/bulk_image_bot/midjourney_automator.js +49 -0
 - data/lib/openai_101/tools/clean_ruby_errors.rb +274 -0
 - data/lib/openai_101/tools/edl_to_chapters.rb +56 -0
 - data/lib/openai_101/tools/file_content_gatherer.rb +36 -0
 - data/lib/openai_101/tools/webp_to_png.rb +124 -0
 - data/lib/openai_101/version.rb +1 -1
 - data/lib/openai_101.rb +11 -0
 - data/package-lock.json +1432 -2271
 - data/package.json +5 -2
 - metadata +89 -11
 - data/.builders/_.rb +0 -1
 - data/.builders/boot.rb +0 -39
 - data/.builders/generators/01-bootstrap.rb +0 -135
 
| 
         @@ -0,0 +1,124 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'mini_magick'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module Openai101
         
     | 
| 
      
 6 
     | 
    
         
            +
              module Tools
         
     | 
| 
      
 7 
     | 
    
         
            +
                # Convert WebP to PNG
         
     | 
| 
      
 8 
     | 
    
         
            +
                class WebpToPng
         
     | 
| 
      
 9 
     | 
    
         
            +
                  attr_reader :source_folder
         
     | 
| 
      
 10 
     | 
    
         
            +
                  attr_reader :target_folder
         
     | 
| 
      
 11 
     | 
    
         
            +
                  attr_reader :target_filename
         
     | 
| 
      
 12 
     | 
    
         
            +
                  attr_reader :prefix
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def initialize(target_filename:, source_folder: nil, target_folder: nil, prefix: nil)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    root = File.expand_path('../../..', __dir__)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    @source_folder = source_folder || ENV.fetch('DOWNLOAD_DIR', nil)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    @target_folder = target_folder || File.join(root, 'course/images')
         
     | 
| 
      
 18 
     | 
    
         
            +
                    @target_filename = target_filename
         
     | 
| 
      
 19 
     | 
    
         
            +
                    @prefix = prefix
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  def convert
         
     | 
| 
      
 23 
     | 
    
         
            +
                    puts "\e[31m#{source_filename}\e[0m"
         
     | 
| 
      
 24 
     | 
    
         
            +
                    image = MiniMagick::Image.open(source_filename)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    image.format 'png'
         
     | 
| 
      
 26 
     | 
    
         
            +
                    image.write target_png_file
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                    self
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  def store_prompt
         
     | 
| 
      
 32 
     | 
    
         
            +
                    File.write(target_prompt_file, prompt)
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                    self
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  def backup_source
         
     | 
| 
      
 38 
     | 
    
         
            +
                    backup_filename = File.basename(source_filename, '.webp')
         
     | 
| 
      
 39 
     | 
    
         
            +
                    backup = target_path(backup_filename, 'webp', subfolder: 'backups')
         
     | 
| 
      
 40 
     | 
    
         
            +
                    FileUtils.cp(source_filename, backup)
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                    self
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  def delete_source
         
     | 
| 
      
 46 
     | 
    
         
            +
                    File.delete(source_filename)
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    self
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                  def clear_backup
         
     | 
| 
      
 52 
     | 
    
         
            +
                    FileUtils.rm_rf(File.join(target_folder, 'backups'))
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                    self
         
     | 
| 
      
 55 
     | 
    
         
            +
                  end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                  def target_file
         
     | 
| 
      
 58 
     | 
    
         
            +
                    prefix ? "#{prefix}-#{target_filename}" : target_filename
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  def target_png_file
         
     | 
| 
      
 62 
     | 
    
         
            +
                    target_path(target_file, 'png')
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                  def target_prompt_file
         
     | 
| 
      
 66 
     | 
    
         
            +
                    target_path(target_file, 'txt', subfolder: 'prompts')
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                  def prompt
         
     | 
| 
      
 70 
     | 
    
         
            +
                    grab_prompt(File.basename(source_filename))
         
     | 
| 
      
 71 
     | 
    
         
            +
                  end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                  def source?
         
     | 
| 
      
 74 
     | 
    
         
            +
                    !source_filename.nil?
         
     | 
| 
      
 75 
     | 
    
         
            +
                  end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                  def source_filename
         
     | 
| 
      
 78 
     | 
    
         
            +
                    @source_filename ||= find_last_webp_file(source_folder)
         
     | 
| 
      
 79 
     | 
    
         
            +
                  end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                  def sanitize_all_webp_files
         
     | 
| 
      
 82 
     | 
    
         
            +
                    file_changed = false
         
     | 
| 
      
 83 
     | 
    
         
            +
                    puts '1'
         
     | 
| 
      
 84 
     | 
    
         
            +
                    Dir.glob(File.join(source_folder, '*.webp')).each do |file_path|
         
     | 
| 
      
 85 
     | 
    
         
            +
                      sanitized_filename = sanitize_filename(File.basename(file_path))
         
     | 
| 
      
 86 
     | 
    
         
            +
                      sanitized_path = File.join(File.dirname(file_path), sanitized_filename)
         
     | 
| 
      
 87 
     | 
    
         
            +
                      puts sanitized_path
         
     | 
| 
      
 88 
     | 
    
         
            +
                      if file_path != sanitized_path
         
     | 
| 
      
 89 
     | 
    
         
            +
                        FileUtils.mv(file_path, sanitized_path)
         
     | 
| 
      
 90 
     | 
    
         
            +
                        file_changed = true
         
     | 
| 
      
 91 
     | 
    
         
            +
                      end
         
     | 
| 
      
 92 
     | 
    
         
            +
                    end
         
     | 
| 
      
 93 
     | 
    
         
            +
                    sleep(3) if file_changed # Pause if any file was renamed
         
     | 
| 
      
 94 
     | 
    
         
            +
                  end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                  private
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                  def sanitize_filename(filename)
         
     | 
| 
      
 99 
     | 
    
         
            +
                    filename.gsub(/[^0-9A-Za-z.\-]/, '_')
         
     | 
| 
      
 100 
     | 
    
         
            +
                  end
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                  def target_path(filename, extension = nil, subfolder: nil, make_folder: true)
         
     | 
| 
      
 103 
     | 
    
         
            +
                    folder = subfolder ? File.join(target_folder, subfolder) : target_folder
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                    FileUtils.mkdir_p(folder) if make_folder
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
                    if extension.nil?
         
     | 
| 
      
 108 
     | 
    
         
            +
                      File.join(folder, filename)
         
     | 
| 
      
 109 
     | 
    
         
            +
                    else
         
     | 
| 
      
 110 
     | 
    
         
            +
                      File.join(folder, "#{filename}.#{extension}")
         
     | 
| 
      
 111 
     | 
    
         
            +
                    end
         
     | 
| 
      
 112 
     | 
    
         
            +
                  end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                  def find_last_webp_file(path)
         
     | 
| 
      
 115 
     | 
    
         
            +
                    Dir.glob(File.join(path, '*.webp')).max_by { |f| File.mtime(f) }
         
     | 
| 
      
 116 
     | 
    
         
            +
                  end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                  def grab_prompt(filename)
         
     | 
| 
      
 119 
     | 
    
         
            +
                    match = filename.match(/DALL_E_\d{4}-\d{2}-\d{2}_\d{2}\.\d{2}\.\d{2}_-_(.+)\.webp$/)
         
     | 
| 
      
 120 
     | 
    
         
            +
                    match[1] if match
         
     | 
| 
      
 121 
     | 
    
         
            +
                  end
         
     | 
| 
      
 122 
     | 
    
         
            +
                end
         
     | 
| 
      
 123 
     | 
    
         
            +
              end
         
     | 
| 
      
 124 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/openai_101/version.rb
    CHANGED
    
    
    
        data/lib/openai_101.rb
    CHANGED
    
    | 
         @@ -1,10 +1,21 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            require 'clipboard'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'openai'
         
     | 
| 
       3 
5 
     | 
    
         
             
            require 'openai_101/version'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'mini_magick'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            require_relative 'openai_101/config/openai'
         
     | 
| 
      
 9 
     | 
    
         
            +
            require_relative 'openai_101/tools/webp_to_png'
         
     | 
| 
      
 10 
     | 
    
         
            +
            require_relative 'openai_101/tools/edl_to_chapters'
         
     | 
| 
      
 11 
     | 
    
         
            +
            require_relative 'openai_101/tools/file_content_gatherer'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require_relative 'openai_101/tools/clean_ruby_errors'
         
     | 
| 
       4 
13 
     | 
    
         | 
| 
       5 
14 
     | 
    
         
             
            module Openai101
         
     | 
| 
       6 
15 
     | 
    
         
             
              # raise Openai101::Error, 'Sample message'
         
     | 
| 
       7 
16 
     | 
    
         
             
              Error = Class.new(StandardError)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              # Your code goes here...
         
     | 
| 
       8 
19 
     | 
    
         
             
            end
         
     | 
| 
       9 
20 
     | 
    
         | 
| 
       10 
21 
     | 
    
         
             
            if ENV.fetch('KLUE_DEBUG', 'false').downcase == 'true'
         
     |