openai_101 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) 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 +11 -11
  9. data/README.md +41 -65
  10. data/lib/openai_101/version.rb +1 -1
  11. data/lib/openai_101.rb +0 -11
  12. data/package-lock.json +2225 -1386
  13. data/package.json +2 -5
  14. metadata +11 -89
  15. data/bin/automate-chatgpt.js +0 -60
  16. data/bin/automate-midjourney.js +0 -75
  17. data/bin/convert_webp_to_png.rb +0 -86
  18. data/bin/gpt_context_gatherer.rb +0 -63
  19. data/course/course.md +0 -64
  20. data/course/images/beautiful-llm-models.png +0 -0
  21. data/course/images/prompts/beautiful-llm-models.txt +0 -1
  22. data/course/images/prompts/series-2-appydave-gpt-summit.txt +0 -1
  23. data/course/images/series-2-appydave-gpt-summit.png +0 -0
  24. data/gpt-context/openai-documentation.md +0 -498
  25. data/gpt-context/ruby-openai-documenation.md +0 -747
  26. data/gpt-context/theme-prompts.csv +0 -21
  27. data/lib/openai_101/config/openai.rb +0 -15
  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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d33410818e89daeeb9011d5a75ed0063fb91fe86c6d5f7a3ab792fc2017d45c0
4
- data.tar.gz: 6ffeba5c3a534647b3fa05835086cf5fdc481c296962795f60880b26415a2626
3
+ metadata.gz: 736a2e322937831de006aa62307bd82605fc2cb77d9e6558ae6899b637ec5c02
4
+ data.tar.gz: b6ff2b19719ea9314efc81579c29fe1f157cc26535ed74a0e99b45e9acc81707
5
5
  SHA512:
6
- metadata.gz: a3403d3d15af8f001c6056c1d120ab3f683854cef5d2cec1275d88a4edfb96a4342bb6cd836d86b9451d571e4324e9b9313d9be56f11c1c582b52204d932fb03
7
- data.tar.gz: c624cd17e5603d40c30e13a7753243a3882dd3f1e592e84935eb1b9b46b3edb7be715af15d198f95c6af9241a4d49fa064828f0477625d2b2a51efeae5de179a
6
+ metadata.gz: 1140a2e1d2076876595ffa2e79d3195248e027b0599a9937ce2d2ca1b717324c5f1b409bfe2dcdb1b66c5cce167989a4d7c8440715886e22ab2e3e9a3dd2cc84
7
+ data.tar.gz: 6d81917562203fa94a619f3f00eac01ba3c4d9a8ecea46a70e6ac761b8439241bebaedd776ce0dd262ed0f2f642e8499c1d920690549890eb2f03c59440b4175
data/.builders/_.rb ADDED
@@ -0,0 +1 @@
1
+ # require_relative './path/here'
data/.builders/boot.rb ADDED
@@ -0,0 +1,39 @@
1
+ # Boot Sequence
2
+
3
+ include KLog::Logging
4
+
5
+ CONFIG_KEY = :openai_101
6
+
7
+ log.kv 'working folder', Dir.pwd
8
+
9
+ KConfig.configure do |config|
10
+ config.handlebars.defaults.add_all_defaults
11
+ end
12
+
13
+ def k_builder
14
+ @k_builder ||= KBuilder::BaseBuilder.init(KConfig.configuration(CONFIG_KEY))
15
+ end
16
+
17
+ KConfig.configure(CONFIG_KEY) do |config|
18
+ builder_folder = Dir.pwd
19
+ base_folder = File.expand_path('../', builder_folder)
20
+ global_template = File.expand_path('~/dev/kgems/k_templates/templates')
21
+
22
+ config.template_folders.add(:global_template , global_template)
23
+ config.template_folders.add(:template , File.expand_path('.templates', Dir.pwd))
24
+
25
+ config.target_folders.add(:app , base_folder)
26
+ config.target_folders.add(:builder , builder_folder)
27
+ end
28
+
29
+ KConfig.configuration(CONFIG_KEY).debug
30
+
31
+ area = KManager.add_area(CONFIG_KEY)
32
+ resource_manager = area.resource_manager
33
+ resource_manager
34
+ .fileset
35
+ .glob('*.rb', exclude: ['boot.rb'])
36
+ .glob('generators/**/*.rb')
37
+ resource_manager.add_resources
38
+
39
+ KManager.boot
@@ -0,0 +1,135 @@
1
+ KManager.action :bootstrap do
2
+ action do
3
+ application_name = :openai_101
4
+
5
+ # Ruby Gem Bootstrap
6
+ director = KDirector::Dsls::RubyGemDsl
7
+ .init(k_builder,
8
+ on_exist: :skip, # %i[skip write compare]
9
+ on_action: :queue # %i[queue execute]
10
+ )
11
+ .data(
12
+ ruby_version: '3.0',
13
+ application: application_name,
14
+ application_description: 'OpenAI 101 working through the API endpoints',
15
+ application_lib_path: application_name.to_s, # need a specialized handlebars helper to turn this into a path, e.g ps-common => ps/common
16
+ application_lib_namespace: 'Openai101',
17
+ namespaces: ['Openai101'],
18
+ author: 'David Cruwys',
19
+ author_email: 'david@ideasmen.com.au',
20
+ initial_semver: '0.0.1',
21
+ main_story: 'As a Developer, I want to understand openai/chatgpt APIs, so that I can build AI applications effectively',
22
+ copyright_date: '2024',
23
+ website: 'http://appydave.com/gems/openai_101'
24
+ )
25
+ .github(
26
+ active: false,
27
+ repo_name: application_name,
28
+ organization: 'appydave'
29
+ ) do
30
+ create_repository
31
+ # delete_repository
32
+ # list_repositories
33
+ open_repository
34
+ # run_command('git init')
35
+ end
36
+ .blueprint(
37
+ active: false,
38
+ name: :bin_hook,
39
+ description: 'initialize repository',
40
+ on_exist: :write) do
41
+
42
+ cd(:app)
43
+
44
+ run_template_script('bin/runonce/git-setup.sh', dom: dom)
45
+
46
+ add('.githooks/commit-msg').run_command('chmod +x .githooks/commit-msg')
47
+ add('.githooks/pre-commit').run_command('chmod +x .githooks/pre-commit')
48
+
49
+ add('.gitignore')
50
+
51
+ run_command('git config core.hooksPath .githooks') # enable sharable githooks (developer needs to turn this on before editing rep)
52
+
53
+ run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
54
+ run_command("gh repo edit -d \"#{dom[:application_description]}\"")
55
+ end
56
+ .package_json(
57
+ active: false,
58
+ name: :package_json,
59
+ description: 'Set up the package.json file for semantic versioning'
60
+ ) do
61
+ self
62
+ .add('package.json', dom: dom)
63
+ .play_actions
64
+
65
+ self
66
+ .add_script('release', 'semantic-release')
67
+ .sort
68
+ .development
69
+ .npm_add_group('semver-ruby')
70
+
71
+ run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
72
+ end
73
+ .blueprint(
74
+ active: false,
75
+ name: :opinionated,
76
+ description: 'opinionated GEM files',
77
+ on_exist: :write) do
78
+
79
+ cd(:app)
80
+
81
+ add('bin/setup')
82
+ add('bin/console')
83
+
84
+ applet_path = typed_dom.namespaces.map { |ns| ns.downcase }.join('/')
85
+
86
+ add("lib/#{applet_path}.rb" , template_file: 'lib/applet_name.rb' , dom: dom)
87
+ add("lib/#{applet_path}/version.rb" , template_file: 'lib/applet_name/version.rb' , dom: dom)
88
+
89
+ add('spec/spec_helper.rb')
90
+ add("spec/#{applet_path}_spec.rb" , template_file: 'spec/applet_name_spec.rb', dom: dom)
91
+
92
+ add("#{typed_dom.application}.gemspec" , template_file: 'applet_name.gemspec', dom: dom)
93
+ add('Gemfile', dom: dom)
94
+ add('Guardfile', dom: dom)
95
+ add('Rakefile', dom: dom)
96
+ add('.rspec', dom: dom)
97
+ add('.rubocop.yml', dom: dom)
98
+ add('README.md', dom: dom)
99
+ add('CODE_OF_CONDUCT.md', dom: dom)
100
+ add('LICENSE.txt', dom: dom)
101
+
102
+ run_command("rubocop -a")
103
+
104
+ run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
105
+ end
106
+ .blueprint(
107
+ active: true,
108
+ name: :ci_cd,
109
+ description: 'github actions (CI/CD)',
110
+ on_exist: :write) do
111
+
112
+ cd(:app)
113
+
114
+ # run_command("gh secret set SLACK_WEBHOOK --body \"$SLACK_REPO_WEBHOOK\"")
115
+ run_command("gh secret set GEM_HOST_API_KEY --body \"$GEM_HOST_API_KEY\"")
116
+
117
+ add('.github/workflows/main.yml')
118
+ add('.releaserc.json')
119
+
120
+ run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
121
+ end
122
+
123
+ director.play_actions
124
+ # director.builder.logit
125
+ end
126
+ end
127
+
128
+ KManager.opts.app_name = 'openai_101'
129
+ KManager.opts.sleep = 2
130
+ KManager.opts.reboot_on_kill = 0
131
+ KManager.opts.reboot_sleep = 4
132
+ KManager.opts.exception_style = :short
133
+ KManager.opts.show.time_taken = true
134
+ KManager.opts.show.finished = true
135
+ KManager.opts.show.finished_message = 'FINISHED :)'
data/.releaserc.json CHANGED
@@ -36,5 +36,5 @@
36
36
  ],
37
37
  "@semantic-release/github"
38
38
  ],
39
- "repositoryUrl": "git@github.com:klueless-io/openai_101.git"
39
+ "repositoryUrl": "git@github.com:appydave/openai_101.git"
40
40
  }
data/.rubocop.yml CHANGED
@@ -7,14 +7,13 @@ require:
7
7
  - rubocop-rake
8
8
 
9
9
  AllCops:
10
- TargetRubyVersion: 3.2
10
+ TargetRubyVersion: 3.0
11
11
  DisplayCopNames: true
12
12
  ExtraDetails: true
13
13
  NewCops: enable
14
14
  Exclude:
15
15
  - ".builders/**/*"
16
16
  - "spec/samples/**/*"
17
- - "spec/openai_101/tools/**/*"
18
17
 
19
18
  Metrics/BlockLength:
20
19
  Exclude:
@@ -40,22 +39,8 @@ Metrics/BlockLength:
40
39
  - shared_examples_for
41
40
  - transaction
42
41
 
43
- Metrics/AbcSize:
44
- Max: 25
45
- Exclude:
46
- - "lib/openai_101/tools/edl_to_chapters.rb"
47
- - "lib/openai_101/tools/clean_ruby_errors.rb"
48
-
49
- Metrics/CyclomaticComplexity:
50
- Exclude:
51
- - "lib/openai_101/tools/clean_ruby_errors.rb"
52
-
53
42
  Metrics/MethodLength:
54
- Exclude:
55
- - "lib/openai_101/tools/edl_to_chapters.rb"
56
- - "lib/openai_101/tools/clean_ruby_errors.rb"
57
- - "lib/openai_101/tools/sanitize_all_webp_files"
58
- - "lib/openai_101/tools/webp_to_png.rb"
43
+ Max: 25
59
44
 
60
45
  Layout/LineLength:
61
46
  Max: 200
@@ -110,14 +95,12 @@ Layout/SpaceBeforeComma:
110
95
  RSpec/NestedGroups:
111
96
  Max: 5
112
97
 
113
- RSpec/FilePath:
114
- Exclude:
115
- - "**/spec/**/*"
98
+ RSpec/SpecFilePathFormat:
99
+ Enabled: true
100
+
101
+ RSpec/SpecFilePathSuffix:
102
+ Enabled: true
116
103
 
117
104
  RSpec/NamedSubject:
118
105
  Exclude:
119
106
  - "**/spec/**/*"
120
-
121
- RSpec/DescribeClass:
122
- Exclude:
123
- - 'spec/openai_101/config/openai_spec.rb'
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.2.2
1
+ ruby 3.3.3
data/CHANGELOG.md CHANGED
@@ -1,19 +1,19 @@
1
- ## [0.0.2](https://github.com/klueless-io/openai_101/compare/v0.0.1...v0.0.2) (2024-02-08)
1
+ # [0.2.0](https://github.com/appydave/openai_101/compare/v0.1.0...v0.2.0) (2024-06-19)
2
2
 
3
3
 
4
- ### Bug Fixes
4
+ ### Features
5
5
 
6
- * namespace issue ([cbcbeb8](https://github.com/klueless-io/openai_101/commit/cbcbeb80c204954a1cfb6db4102e9acaa6844a52))
7
- * ruby 2.7 & 3.2 ([0af05e1](https://github.com/klueless-io/openai_101/commit/0af05e1e0e99bf08ebc4e7396bd55d10005d25e8))
8
- * ruby 3.2 only ([d9c463a](https://github.com/klueless-io/openai_101/commit/d9c463a2775efd19d88e4d73402392fbe8c42d01))
9
- * semantic release 19 ([c123a3f](https://github.com/klueless-io/openai_101/commit/c123a3f9cfa85dfa96769e38ea9f98b84cf94156))
10
- * semantic release 19 ([e5251b1](https://github.com/klueless-io/openai_101/commit/e5251b1a8ac102533fb9253f8ffb1676c86e385d))
11
- * semantic release 21 ([62ba587](https://github.com/klueless-io/openai_101/commit/62ba5870dabfe24c150943cdcd62e1a24c53a885))
12
- * update ruby version ([142cff3](https://github.com/klueless-io/openai_101/commit/142cff346b41aac6e8b6083f970a03c1681c23ad))
13
- * update ruby version ([f378f52](https://github.com/klueless-io/openai_101/commit/f378f520a8578372834ec57bdf6b2f4b16be813c))
6
+ * moved repo to appydave organization ([dd59698](https://github.com/appydave/openai_101/commit/dd596981dc69723a1c59b53db845f29d616f0540))
7
+
8
+ # [0.1.0](https://github.com/appydave/openai_101/compare/v0.0.1...v0.1.0) (2024-06-19)
9
+
10
+
11
+ ### Features
12
+
13
+ * moved repo to appydave organization ([3b01048](https://github.com/appydave/openai_101/commit/3b01048e2e0f381a6ab5bc0a7cfb4cedd83da88f))
14
14
 
15
15
  ## [Unreleased]
16
16
 
17
- ## [0.1.0] - 2024-02-09
17
+ ## [0.1.0] - 2024-06-19
18
18
 
19
19
  - Initial release
data/README.md CHANGED
@@ -1,22 +1,6 @@
1
- DAVID: Check this out, should add it into the openAI course:
2
-
3
- https://www.loom.com/share/117eb552f1974f3d8e28463e9f1809e1
4
-
5
- Based on:
6
-
7
- https://innovate-aiml-data-apj.virtual.awsevents.com/media/10.%20Codenator%3A%20Enhancing%20user%20productivity%20through%20AI-powered%20code%20generation%20and%20secure%20execution/1_0kzrwmxu/330865472
8
-
9
-
10
-
11
1
  # Openai 101
12
2
 
13
- > OpenAI 101 Series on using OpenAI ChatGPT, DALL·E, and other OpenAI endpoints
14
-
15
- **Focus Story**
16
-
17
- As a software developer, I want to understand OpenAI endpoints and capabilities, so that I can use ChatGPT effectively
18
-
19
-
3
+ > OpenAI 101 working through the API endpoints
20
4
 
21
5
  ## Installation
22
6
 
@@ -38,84 +22,76 @@ Or install it yourself as:
38
22
  gem install openai_101
39
23
  ```
40
24
 
41
- ## JavaScript Dependencies Installation
25
+ ## Stories
42
26
 
43
- This optional step is only required if you plan to use the JavaScript tools included in this gem from the command line.
27
+ ### Main Story
44
28
 
45
- [Javascript Tools]
29
+ As a Developer, I want to understand openai/chatgpt APIs, so that I can build AI applications effectively
46
30
 
47
- This gem includes tools written in JavaScript, requiring Node.js and associated packages. After installing the gem, navigate to the gem's root directory and run:
31
+ See all [stories](./STORIES.md)
48
32
 
49
- ```bash
50
- npm install
51
- ```
52
33
 
53
- ## Resources
34
+ ## Usage
54
35
 
55
- - [Course Outline](./COURSE.md)
56
- - [OpenAI Documentation](gpt-context/openai-documentation.md) is used as reference material for code generation prompts, this information has been summarized from source documentation
57
- - [Ruby OpenAI Documentation](gpt-context/ruby-openai-documenation.md) is used as reference material for code generation prompts and shows examples of how to use the Ruby OpenAI gem
36
+ See all [usage examples](./USAGE.md)
58
37
 
59
38
 
60
- See all [stories](./STORIES.md)
61
39
 
62
40
  ## Development
63
41
 
64
42
  Checkout the repo
65
43
 
66
44
  ```bash
67
- git clone https://github.com/klueless-io/openai_101
45
+ git clone https://github.com/appydave/openai_101
68
46
  ```
69
47
 
70
48
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
71
49
 
72
50
  You can also run `bin/console` for an interactive prompt that will allow you to experiment.
73
51
 
74
- ## Command line tools
75
-
76
- ### Bulk MidJourney Image Generation
77
-
78
- Automates MidJourney prompts on Discord.
79
-
80
- `automate-images-midjourney`
81
-
82
- This tool will read prompts from a file and then paste them into the MidJourney Discord channel in an unattented manner. This is useful for automating the process of generating images from prompts in bulk. NOTE: You start the script and then you place the cursor in the Discord channel and the script will do the rest.
83
-
84
- ### Bulk ChatGPT Image Generation
85
-
86
- Automates image prompts in ChatGPT.
87
-
88
- `automate-images-chatgpt`
89
-
90
- This tool will read prompts from a file and then paste them into the current focused ChatGPT window in unattented mode. This is useful for automating the process of generating images from prompts in bulk using the DALE-3 feature in ChatGPT Plus. NOTE: You start the script and then you place the cursor in the ChatGPT window and the script will do the rest.
52
+ ```bash
53
+ bin/console
91
54
 
92
- ### WEBP to PNG Converter:
55
+ Aaa::Bbb::Program.execute()
56
+ # => ""
57
+ ```
93
58
 
94
- Converts WEBP images to PNG, manages prompts.
59
+ `openai_101` is setup with Guard, run `guard`, this will watch development file changes and run tests automatically, if successful, it will then run rubocop for style quality.
95
60
 
96
- `web3_to_png`
61
+ To release a new version, update the version number in `version.rb`, build the gem and push the `.gem` file to [rubygems.org](https://rubygems.org).
97
62
 
98
- ### EDL to Chapters
63
+ ```bash
64
+ rake publish
65
+ rake clean
66
+ ```
99
67
 
100
- Converts EDL time codes to chapters in YouTube video description.
68
+ ## Git helpers used by this project
101
69
 
102
- `edl_to_chapters`
70
+ Add the follow helpers to your `alias` file
103
71
 
104
- Usage on Mac
105
72
  ```bash
106
- # make the script executable
107
- chmod +x bin/convert_webp_to_png.rb
108
-
109
- # run the script
110
- ./bin/convert_webp_to_png.rb -s path/to/source -t path/to/target -f target_filename -p optional_prefix
111
-
112
- # Example
113
- ./bin/convert_webp_to_png.rb -p series-2 -f woman-grey-tabby-cat -s /Users/davidcruwys/Sync/smart-downloads/download-images
114
- -t /Volumes/Expansion/Sync/tube-channels/a-cast/cast-active/a35-automate-image-generation/assets
73
+ function kcommit()
74
+ {
75
+ echo 'git add .'
76
+ git add .
77
+ echo "git commit -m "$1""
78
+ git commit -m "$1"
79
+ echo 'git pull'
80
+ git pull
81
+ echo 'git push'
82
+ git push
83
+ sleep 3
84
+ run_id="$(gh run list --limit 1 | grep -Eo "[0-9]{9,11}")"
85
+ gh run watch $run_id --exit-status && echo "run completed and successful" && git pull && git tag | sort -V | tail -1
86
+ }
87
+ function kchore () { kcommit "chore: $1" }
88
+ function kdocs () { kcommit "docs: $1" }
89
+ function kfix () { kcommit "fix: $1" }
90
+ function kfeat () { kcommit "feat: $1" }
91
+ function ktest () { kcommit "test: $1" }
92
+ function krefactor () { kcommit "refactor: $1" }
115
93
  ```
116
94
 
117
- This tool automates the conversion of WEBP images to PNG format, stores associated prompts, manages source backups, and cleans up after processing.
118
-
119
95
  ## Contributing
120
96
 
121
97
  Bug reports and pull requests are welcome on GitHub at https://github.com/klueless-io/openai_101. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Openai101
4
- VERSION = '1.0.0'
4
+ VERSION = '1.2.0'
5
5
  end
data/lib/openai_101.rb CHANGED
@@ -1,21 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'clipboard'
4
- require 'openai'
5
3
  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'
13
4
 
14
5
  module Openai101
15
6
  # raise Openai101::Error, 'Sample message'
16
7
  Error = Class.new(StandardError)
17
-
18
- # Your code goes here...
19
8
  end
20
9
 
21
10
  if ENV.fetch('KLUE_DEBUG', 'false').downcase == 'true'