openai_101 1.0.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/_.rb +1 -0
  3. data/.builders/boot.rb +39 -0
  4. data/.builders/generators/01-bootstrap.rb +135 -0
  5. data/.releaserc.json +1 -1
  6. data/.rubocop.yml +7 -24
  7. data/.tool-versions +1 -1
  8. data/CHANGELOG.md +18 -11
  9. data/README.md +41 -65
  10. data/lib/openai101/sample.rb +10 -0
  11. data/lib/{openai_101 → openai101}/version.rb +1 -1
  12. data/lib/openai_101.rb +7 -9
  13. data/package-lock.json +2225 -1386
  14. data/package.json +2 -5
  15. metadata +18 -52
  16. data/bin/automate-chatgpt.js +0 -60
  17. data/bin/automate-midjourney.js +0 -75
  18. data/bin/convert_webp_to_png.rb +0 -86
  19. data/bin/gpt_context_gatherer.rb +0 -63
  20. data/course/course.md +0 -64
  21. data/course/images/beautiful-llm-models.png +0 -0
  22. data/course/images/prompts/beautiful-llm-models.txt +0 -1
  23. data/course/images/prompts/series-2-appydave-gpt-summit.txt +0 -1
  24. data/course/images/series-2-appydave-gpt-summit.png +0 -0
  25. data/gpt-context/openai-documentation.md +0 -498
  26. data/gpt-context/ruby-openai-documenation.md +0 -747
  27. data/gpt-context/theme-prompts.csv +0 -21
  28. data/lib/openai_101/tools/automate-images-chatgpt.js +0 -60
  29. data/lib/openai_101/tools/automate-images-midjourney.js +0 -75
  30. data/lib/openai_101/tools/bulk_image_bot/base_automator.js +0 -53
  31. data/lib/openai_101/tools/bulk_image_bot/chatgpt_automator.js +0 -27
  32. data/lib/openai_101/tools/bulk_image_bot/midjourney_automator.js +0 -49
  33. data/lib/openai_101/tools/clean_ruby_errors.rb +0 -274
  34. data/lib/openai_101/tools/edl_to_chapters.rb +0 -56
  35. data/lib/openai_101/tools/file_content_gatherer.rb +0 -36
  36. data/lib/openai_101/tools/webp_to_png.rb +0 -124
  37. /data/lib/{openai_101 → openai101}/config/openai.rb +0 -0
data/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "openai_101",
3
- "version": "1.0.0",
4
- "description": "OpenAI 101 Series on using OpenAI ChatGPT, DALL·E, and other OpenAI endpoints",
3
+ "version": "1.2.1",
4
+ "description": "OpenAI 101 working through the API endpoints",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
7
7
  },
8
- "dependencies": {},
9
8
  "devDependencies": {
10
- "commander": "^10.0.1",
11
- "robotjs": "^0.6.0",
12
9
  "@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
13
10
  "@semantic-release/changelog": "^6.0.3",
14
11
  "@semantic-release/git": "^10.0.1",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openai_101
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-23 00:00:00.000000000 Z
11
+ date: 2024-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2'
33
+ version: '3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2'
40
+ version: '3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: k_log
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,42 +52,30 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: mini_magick
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '4'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '4'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: ruby-openai
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: '6'
61
+ version: '7'
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '6'
83
- description: " OpenAI 101 Series on using OpenAI ChatGPT, DALL·E, and other OpenAI
84
- endpoints\n"
68
+ version: '7'
69
+ description: " OpenAI 101 working through the API endpoints\n"
85
70
  email:
86
71
  - david@ideasmen.com.au
87
72
  executables: []
88
73
  extensions: []
89
74
  extra_rdoc_files: []
90
75
  files:
76
+ - ".builders/_.rb"
77
+ - ".builders/boot.rb"
78
+ - ".builders/generators/01-bootstrap.rb"
91
79
  - ".releaserc.json"
92
80
  - ".rspec"
93
81
  - ".rubocop.yml"
@@ -99,32 +87,12 @@ files:
99
87
  - LICENSE.txt
100
88
  - README.md
101
89
  - Rakefile
102
- - bin/automate-chatgpt.js
103
- - bin/automate-midjourney.js
104
90
  - bin/console
105
- - bin/convert_webp_to_png.rb
106
- - bin/gpt_context_gatherer.rb
107
91
  - bin/setup
108
- - course/course.md
109
- - course/images/beautiful-llm-models.png
110
- - course/images/prompts/beautiful-llm-models.txt
111
- - course/images/prompts/series-2-appydave-gpt-summit.txt
112
- - course/images/series-2-appydave-gpt-summit.png
113
- - gpt-context/openai-documentation.md
114
- - gpt-context/ruby-openai-documenation.md
115
- - gpt-context/theme-prompts.csv
92
+ - lib/openai101/config/openai.rb
93
+ - lib/openai101/sample.rb
94
+ - lib/openai101/version.rb
116
95
  - lib/openai_101.rb
117
- - lib/openai_101/config/openai.rb
118
- - lib/openai_101/tools/automate-images-chatgpt.js
119
- - lib/openai_101/tools/automate-images-midjourney.js
120
- - lib/openai_101/tools/bulk_image_bot/base_automator.js
121
- - lib/openai_101/tools/bulk_image_bot/chatgpt_automator.js
122
- - lib/openai_101/tools/bulk_image_bot/midjourney_automator.js
123
- - lib/openai_101/tools/clean_ruby_errors.rb
124
- - lib/openai_101/tools/edl_to_chapters.rb
125
- - lib/openai_101/tools/file_content_gatherer.rb
126
- - lib/openai_101/tools/webp_to_png.rb
127
- - lib/openai_101/version.rb
128
96
  - package-lock.json
129
97
  - package.json
130
98
  - sig/openai_101.rbs
@@ -133,12 +101,10 @@ licenses:
133
101
  - MIT
134
102
  metadata:
135
103
  homepage_uri: http://appydave.com/gems/openai_101
136
- source_code_uri: https://github.com/klueless-io/openai_101
137
- changelog_uri: https://github.com/klueless-io/openai_101/blob/main/CHANGELOG.md
104
+ source_code_uri: https://github.com/appydave/openai_101
105
+ changelog_uri: https://github.com/appydave/openai_101/blob/main/CHANGELOG.md
138
106
  rubygems_mfa_required: 'true'
139
- post_install_message: Remember to run 'npm install' in the gem directory to install
140
- JavaScript dependencies. These are optional command line tools that can be helpful
141
- but not required
107
+ post_install_message:
142
108
  rdoc_options: []
143
109
  require_paths:
144
110
  - lib
@@ -146,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
112
  requirements:
147
113
  - - ">="
148
114
  - !ruby/object:Gem::Version
149
- version: '3.2'
115
+ version: '3.0'
150
116
  required_rubygems_version: !ruby/object:Gem::Requirement
151
117
  requirements:
152
118
  - - ">="
@@ -156,5 +122,5 @@ requirements: []
156
122
  rubygems_version: 3.3.5
157
123
  signing_key:
158
124
  specification_version: 4
159
- summary: OpenAI 101 Series on using OpenAI ChatGPT, DALL·E, and other OpenAI endpoints
125
+ summary: OpenAI 101 working through the API endpoints
160
126
  test_files: []
@@ -1,60 +0,0 @@
1
- const { Command } = require('commander');
2
- const fs = require('fs');
3
- const robot = require("robotjs");
4
-
5
- const program = new Command();
6
-
7
- program
8
- .option('-f, --file <filename>', 'The file to read prompts from', 'prompts.txt')
9
- .option('-o, --completed-file <filename>', 'The file to write completed prompts to', 'completed.txt')
10
- .option('-i, --interval <seconds>', 'The interval in seconds between prompts', 80)
11
- .option('-m, --max-images <number>', 'The maximum number of images to process', 20);
12
-
13
- program.parse(process.argv);
14
-
15
- function read_prompts_from_file(file, maxImages) {
16
- const prompts = fs.readFileSync(file, 'utf-8').split('\n').filter(Boolean);
17
- return prompts.slice(0, maxImages);
18
- }
19
-
20
- function remove_prompt_from_file(file, prompt) {
21
- const prompts = fs.readFileSync(file, 'utf-8').split('\n').filter(Boolean);
22
- const index = prompts.indexOf(prompt);
23
- if (index !== -1) {
24
- prompts.splice(index, 1);
25
- fs.writeFileSync(file, prompts.join('\n'));
26
- }
27
- }
28
-
29
- function append_prompt_to_file(file, prompt) {
30
- fs.appendFileSync(file, `${prompt}\n`);
31
- }
32
-
33
- function wait(ms) {
34
- return new Promise(resolve => setTimeout(resolve, ms));
35
- }
36
-
37
- async function send_prompt_to_chat(prompt) {
38
- const formattedPrompt = `create image: ${prompt}`;
39
- robot.typeString(formattedPrompt);
40
- robot.keyTap('enter');
41
- }
42
-
43
- async function start() {
44
- console.log('Starting Image Creation Automation');
45
- console.log('Please open the ChatGPT interface where you intend to use this script.');
46
- console.log('Automation will begin in 10 seconds.');
47
- await wait(10000);
48
-
49
- const prompts = read_prompts_from_file(program.opts().file, parseInt(program.opts().maxImages));
50
- for (let prompt of prompts) {
51
- console.log(`Sending prompt "${prompt}"...`);
52
- await send_prompt_to_chat(prompt);
53
- await wait(program.opts().interval * 1000);
54
- remove_prompt_from_file(program.opts().file, prompt);
55
- append_prompt_to_file(program.opts().completedFile, prompt);
56
- }
57
- console.log('Automation complete.');
58
- }
59
-
60
- start();
@@ -1,75 +0,0 @@
1
- const { Command } = require('commander');
2
- const fs = require('fs');
3
- const robot = require("robotjs");
4
-
5
- const program = new Command();
6
-
7
- program
8
- .option('-f, --file <filename>', 'The file to read prompts from', 'prompts.txt')
9
- .option('-o, --completed-file <filename>', 'The file to write completed prompts to', 'completed.txt')
10
- .option('-i, --interval <seconds>', 'The interval in seconds between prompts', 4)
11
- .option('-p, --prompts-per-session <prompts>', 'The number of prompts to process in a session', 7)
12
- .option('-w, --wait-between-sessions <seconds>', 'The number of seconds to wait between sessions', 180);
13
-
14
- program.parse(process.argv);
15
-
16
- function read_next_prompt_from_file(file) {
17
- const prompts = fs.readFileSync(file, 'utf-8').split('\n').filter(Boolean);
18
- return prompts.shift();
19
- }
20
-
21
- function remove_prompt_from_file(file, prompt) {
22
- const lockfile = `${file}.lock`;
23
- fs.writeFileSync(lockfile, '', { flag: 'wx' });
24
- const prompts = fs.readFileSync(file, 'utf-8').split('\n').filter(Boolean);
25
- const index = prompts.indexOf(prompt);
26
- prompts.splice(index, 1);
27
- fs.writeFileSync(file, prompts.join('\n'));
28
- fs.unlinkSync(lockfile);
29
- }
30
-
31
- function append_prompt_to_file(file, prompt) {
32
- const lockfile = `${file}.lock`;
33
- fs.writeFileSync(lockfile, '', { flag: 'wx' });
34
- fs.appendFileSync(file, `${prompt}\n`);
35
- fs.unlinkSync(lockfile);
36
- }
37
-
38
- function wait(ms) {
39
- const end = Date.now() + ms;
40
- while (Date.now() < end) {
41
- // Wait
42
- }
43
- }
44
-
45
- function send_prompt_to_discord(prompt) {
46
- const formattedPrompt = `/imagine prompt: ${prompt}`;
47
- robot.typeString(formattedPrompt);
48
- robot.keyTap('enter');
49
- }
50
-
51
- function start() {
52
- console.log('Starting MidJourney Automation');
53
- console.log('Please open Discord and navigate to the MidJourney channel.');
54
- console.log('Automation will begin in 10 seconds.');
55
- wait(10 * 1000);
56
-
57
- let index = 0;
58
- let prompt = read_next_prompt_from_file(program.opts().file);
59
- while (prompt) {
60
- console.log(`Sending prompt "${prompt}"...`);
61
- send_prompt_to_discord(prompt);
62
- wait(program.opts().interval * 1000);
63
- remove_prompt_from_file(program.opts().file, prompt);
64
- append_prompt_to_file(program.opts().completedFile, prompt);
65
- index++;
66
- if (index % program.opts().promptsPerSession === 0) {
67
- console.log(`Pausing for ${program.opts().waitBetweenSessions} seconds.`);
68
- wait(program.opts().waitBetweenSessions * 1000);
69
- }
70
- prompt = read_next_prompt_from_file(program.opts().file);
71
- }
72
- console.log('Automation complete.');
73
- }
74
-
75
- start();
@@ -1,86 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'pry'
5
- require 'optparse'
6
- require_relative '../lib/openai_101/tools/webp_to_png'
7
-
8
- options = {
9
- prefix: nil,
10
- debug: false,
11
- dry_run: false
12
- }
13
-
14
- OptionParser.new do |opts|
15
- opts.banner = 'Usage: convert_webp_to_png.rb [options]'
16
-
17
- opts.on('-s', '--source=SOURCE', 'Source directory containing WEBP files') do |source|
18
- options[:source_folder] = source
19
- end
20
-
21
- opts.on('-t', '--target=TARGET', 'Target directory for PNG files') do |target|
22
- options[:target_folder] = target
23
- end
24
-
25
- opts.on('-f', '--filename=FILENAME', 'Specific target filename for the PNG output') do |filename|
26
- options[:target_filename] = filename
27
- end
28
-
29
- opts.on('-p', '--prefix=PREFIX', 'Optional prefix for the target filename') do |prefix|
30
- options[:prefix] = prefix
31
- end
32
-
33
- opts.on('-d', '--debug', 'Enable debug mode') do
34
- options[:debug] = true
35
- end
36
-
37
- opts.on('--dry-run', 'Simulate the conversion process without making any changes') do
38
- options[:dry_run] = true
39
- end
40
-
41
- opts.on('-h', '--help', 'Prints this help') do
42
- puts opts
43
- exit
44
- end
45
- end.parse!
46
-
47
- unless options[:target_filename]
48
- puts 'A target filename is required.'
49
- exit
50
- end
51
-
52
- converter = Openai101::Tools::WebpToPng.new(
53
- source_folder: options[:source_folder],
54
- target_folder: options[:target_folder],
55
- target_filename: options[:target_filename],
56
- prefix: options[:prefix]
57
- )
58
-
59
- if options[:debug]
60
- puts "Source folder : #{converter.source_folder}"
61
- puts "Target folder : #{converter.target_folder}"
62
- puts "Target filename : #{converter.target_filename}"
63
- puts "Source filename : #{converter.source_filename}"
64
- puts "Prefix : #{converter.prefix}"
65
- puts "Target prompt : #{converter.prompt}"
66
- puts "Target PNG file : #{converter.target_png_file}"
67
- puts "Target Prompt file : #{converter.target_prompt_file}"
68
- end
69
-
70
- if options[:dry_run]
71
- puts 'Dry run enabled - no changes will be made.'
72
- exit
73
- end
74
-
75
- converter.sanitize_all_webp_files
76
-
77
- if converter.source?
78
- converter
79
- .convert
80
- .store_prompt
81
- .backup_source
82
- .delete_source
83
- puts 'Conversion and processing complete.'
84
- else
85
- puts "\e[31mNo source file found\e[0m"
86
- end
@@ -1,63 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- # Usage:
5
- # ./bin/gpt_context_gatherer.rb -d -i 'lib/openai_101/tools/**/*.rb'
6
- # ./bin/gpt_context_gatherer.rb -d -i 'lib/openai_101/tools/**/*' -e 'node_modules/**/*' -e 'package-lock.json' -e 'lib/openai_101/tools/prompts/*.txt'
7
- #
8
- # Get GPT Context Gatherer code
9
- # ./bin/gpt_context_gatherer.rb -i 'bin/**/*gather*.rb' -i 'lib/openai_101/tools/**/*gather*.rb'
10
- require 'optparse'
11
- require 'clipboard'
12
- require_relative '../lib/openai_101/tools/file_content_gatherer'
13
-
14
- options = {
15
- include_patterns: [],
16
- exclude_patterns: [],
17
- debug: false
18
- }
19
-
20
- OptionParser.new do |opts|
21
- opts.banner = 'Usage: gather_content.rb [options]'
22
-
23
- opts.on('-i', '--include PATTERN', 'Pattern or file to include (can be used multiple times)') do |pattern|
24
- options[:include_patterns] << pattern
25
- end
26
-
27
- opts.on('-e', '--exclude PATTERN', 'Pattern or file to exclude (can be used multiple times)') do |pattern|
28
- options[:exclude_patterns] << pattern
29
- end
30
-
31
- opts.on('-d', '--debug', 'Enable debug mode') do
32
- options[:debug] = true
33
- end
34
-
35
- opts.on_tail('-h', '--help', 'Show this message') do
36
- puts opts
37
- puts "\nExamples:"
38
- puts " #{File.basename($PROGRAM_NAME)} -i 'lib/**/*.rb' -e 'lib/excluded/**/*.rb' -d"
39
- puts " #{File.basename($PROGRAM_NAME)} --include 'src/**/*.js' --exclude 'src/vendor/**/*.js'"
40
-
41
- puts ''
42
- puts ' # Get GPT Context Gatherer code that is found in any folder (bin, lib & spec)'
43
- puts " #{File.basename($PROGRAM_NAME)} -i '**/*gather*.rb'"
44
- exit
45
- end
46
- end.parse!
47
-
48
- pp options if options[:debug]
49
-
50
- gatherer = Openai101::Tools::FileContentGatherer.new(
51
- include_patterns: options[:include_patterns],
52
- exclude_patterns: options[:exclude_patterns]
53
- )
54
-
55
- content = gatherer.build
56
-
57
- if options[:debug]
58
- puts '-' * 80
59
- puts content
60
- puts '-' * 80
61
- end
62
-
63
- Clipboard.copy(content)
data/course/course.md DELETED
@@ -1,64 +0,0 @@
1
- # OpenAI 101
2
-
3
- > OpenAI 101 Series on using OpenAI ChatGPT, DALL·E, and other OpenAI endpoints
4
-
5
- As a software developer, I want to understand OpenAI endpoints and capabilities, so that I can use ChatGPT effectively
6
-
7
- ## Overview
8
-
9
- Compreshensive guide to using OpenAI endpoints and capabilities, in this section we will look at the building blocks for this series and what we plan to cover.
10
-
11
- - [Built On](#built-on)
12
- - [Hello World](#achieving-hello-world-status)
13
- - Configure OpenAI API
14
-
15
-
16
- ## Built On
17
-
18
- - Ruby Gem (Library)
19
- - Dependencies
20
- - `dotenv` for environment variables
21
- - `ruby-openai` for OpenAI API
22
- - Tools
23
- - `convert_webp_to_png` for converting ChatGPT images from WebP to PNG
24
- - `automate-images-chatgpt` for running bulk image creation in ChatGPT/DALL·E
25
- - `automate-images-midjourney` for running bulk image creation in MidJourney
26
- - `edl_to_chapters` for converting EDL time codes to chapters in YouTube video description
27
-
28
- - GPT Context Documents
29
- - OpenAI documentation
30
- - Ruby OpenAI documentation
31
-
32
- ## Achieving Hello World Status
33
-
34
- - Configure OpenAI API
35
- - Create an account
36
- - Create an API key
37
- - Add API key to `.env` file
38
- - Load `.env` file
39
- - Use API key to authenticate with OpenAI API
40
- - Make first simple prompt request
41
- - text completion
42
- - Models are Sexy
43
- - Model list
44
-
45
- ## What we will cover infographic
46
-
47
- TODO: Add infographic
48
-
49
- Notes:
50
-
51
- - List of endpoints
52
- - List of usecases
53
- - 2nd Brain
54
- - GPT Context used for code generation
55
- - Code Generation
56
- - Text to Image
57
- - Image to Text (Vision)
58
- - Text to Speech
59
- - Speech to Text
60
- - Samples in 4 languages (GPT as a Polyglot Developer)
61
- - Ruby
62
- - Python
63
- - JavaScript
64
- - REST API (cURL)
Binary file
@@ -1 +0,0 @@
1
- A mystical illustration depicting three beautiful women representing large language models, set in an environment inspired by Pocahontas. Each woman
@@ -1 +0,0 @@
1
- An_image_of_a_computer_nerd__characterized_by_glasses_and_casual_tech-themed_attire__standing_confidently_on_a_stage._The_backdrop_is_a_large_screen_d