appydave-tools 0.9.5 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/bin/prompt_tools.rb +36 -0
- data/bin/youtube_manager.rb +5 -45
- data/lib/appydave/tools/cli_actions/_doc.md +5 -0
- data/lib/appydave/tools/cli_actions/base_action.rb +50 -0
- data/lib/appydave/tools/cli_actions/get_video_action.rb +41 -0
- data/lib/appydave/tools/cli_actions/prompt_completion_action.rb +80 -0
- data/lib/appydave/tools/cli_actions/update_video_action.rb +46 -0
- data/lib/appydave/tools/types/array_type.rb +2 -0
- data/lib/appydave/tools/types/hash_type.rb +2 -0
- data/lib/appydave/tools/version.rb +1 -1
- data/lib/appydave/tools/youtube_manager/_doc.md +3 -1
- data/lib/appydave/tools/youtube_manager/get_video.rb +2 -0
- data/lib/appydave/tools.rb +6 -2
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2f8626d0968a1fb7485288c9e2faec7dfab9bc1d389f7834f76748116794ad4
|
4
|
+
data.tar.gz: f750a6e6132df67ebafefce2f94435a7801efc2ce374f94448d8c8b4d51c6255
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ec7c54c22a51070b33f66fd6fad9c60977f1e75c55fdc31e858545d1a79d5d74418a054d7fa538e99c2297831b41a3c20d6465ec4a311f806b02781a1a5925d
|
7
|
+
data.tar.gz: edaa750eed5eaf3ec55fca13fbeae3c703c9cf6845730bf6c00b3dafbe30f69b53891997041f5766a2ce837c4fa039303161df7035711d1f3c1dba66ca802ab3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [0.9.5](https://github.com/klueless-io/appydave-tools/compare/v0.9.4...v0.9.5) (2024-06-13)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* implement update video command ([c46473d](https://github.com/klueless-io/appydave-tools/commit/c46473dc550e34c041418adfd52444014e094917))
|
7
|
+
|
1
8
|
## [0.9.4](https://github.com/klueless-io/appydave-tools/compare/v0.9.3...v0.9.4) (2024-06-12)
|
2
9
|
|
3
10
|
|
data/bin/prompt_tools.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
|
5
|
+
|
6
|
+
require 'appydave/tools'
|
7
|
+
|
8
|
+
# Process command line arguments for Prompt operations
|
9
|
+
class PromptToolsCLI
|
10
|
+
def initialize
|
11
|
+
@commands = {
|
12
|
+
'completion' => Appydave::Tools::CliActions::PromptCompletionAction.new
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
command, *args = ARGV
|
18
|
+
if @commands.key?(command)
|
19
|
+
@commands[command].action(args)
|
20
|
+
else
|
21
|
+
puts "Unknown command: #{command}"
|
22
|
+
print_help
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def print_help
|
29
|
+
puts 'Usage: prompt_tools.rb [command] [options]'
|
30
|
+
puts 'Commands:'
|
31
|
+
puts ' completion Run a completion prompt against the model'
|
32
|
+
puts "Run 'prompt.rb [command] --help' for more information on a command."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
PromptToolsCLI.new.run
|
data/bin/youtube_manager.rb
CHANGED
@@ -11,15 +11,15 @@ class YouTubeVideoManagerCLI
|
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@commands = {
|
14
|
-
'get' =>
|
15
|
-
'update' =>
|
14
|
+
'get' => Appydave::Tools::CliActions::GetVideoAction.new,
|
15
|
+
'update' => Appydave::Tools::CliActions::UpdateVideoAction.new
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
19
|
def run
|
20
20
|
command, *args = ARGV
|
21
21
|
if @commands.key?(command)
|
22
|
-
@commands[command].
|
22
|
+
@commands[command].action(args)
|
23
23
|
else
|
24
24
|
puts "Unknown command: #{command}"
|
25
25
|
print_help
|
@@ -28,27 +28,8 @@ class YouTubeVideoManagerCLI
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
def fetch_video_details(args)
|
32
|
-
options = parse_options(args, 'get')
|
33
|
-
get_video = Appydave::Tools::YouTubeManager::GetVideo.new
|
34
|
-
get_video.get(options[:video_id])
|
35
|
-
|
36
|
-
if get_video.video?
|
37
|
-
# json = JSON.pretty_generate(details)
|
38
|
-
# puts json
|
39
|
-
|
40
|
-
report = Appydave::Tools::YouTubeManager::Reports::VideoDetailsReport.new
|
41
|
-
report.print(get_video.data)
|
42
|
-
|
43
|
-
# report = Appydave::Tools::YouTubeManager::Reports::VideoContentReport.new
|
44
|
-
# report.print(manager.data)
|
45
|
-
else
|
46
|
-
log.error "Video not found! Maybe it's private or deleted. ID: #{options[:video_id]}"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
31
|
def update_video_details(args)
|
51
|
-
options =
|
32
|
+
options = update_video_options(args)
|
52
33
|
|
53
34
|
get_video = Appydave::Tools::YouTubeManager::GetVideo.new
|
54
35
|
get_video.get(options[:video_id])
|
@@ -63,28 +44,7 @@ class YouTubeVideoManagerCLI
|
|
63
44
|
update_video.save
|
64
45
|
end
|
65
46
|
|
66
|
-
def
|
67
|
-
options = { video_id: nil }
|
68
|
-
OptionParser.new do |opts|
|
69
|
-
opts.banner = "Usage: youtube_video_manager.rb #{command} [options]"
|
70
|
-
|
71
|
-
opts.on('-v', '--video-id ID', 'YouTube Video ID') { |v| options[:video_id] = v }
|
72
|
-
|
73
|
-
opts.on_tail('-h', '--help', 'Show this message') do
|
74
|
-
puts opts
|
75
|
-
exit
|
76
|
-
end
|
77
|
-
end.parse!(args)
|
78
|
-
|
79
|
-
unless options[:video_id]
|
80
|
-
puts 'Missing required options. Use -h for help.'
|
81
|
-
exit
|
82
|
-
end
|
83
|
-
|
84
|
-
options
|
85
|
-
end
|
86
|
-
|
87
|
-
def parse_update_options(args)
|
47
|
+
def update_video_options(args)
|
88
48
|
options = { video_id: nil }
|
89
49
|
OptionParser.new do |opts|
|
90
50
|
opts.banner = 'Usage: youtube_video_manager.rb update [options]'
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appydave
|
4
|
+
module Tools
|
5
|
+
module CliActions
|
6
|
+
# Base class for CLI actions
|
7
|
+
class BaseAction
|
8
|
+
def action(args)
|
9
|
+
options = parse_options(args)
|
10
|
+
execute(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def parse_options(args)
|
16
|
+
options = {}
|
17
|
+
OptionParser.new do |opts|
|
18
|
+
opts.banner = "Usage: #{command_usage}"
|
19
|
+
|
20
|
+
define_options(opts, options)
|
21
|
+
|
22
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
23
|
+
puts opts
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end.parse!(args)
|
27
|
+
|
28
|
+
validate_options(options)
|
29
|
+
options
|
30
|
+
end
|
31
|
+
|
32
|
+
def command_usage
|
33
|
+
"#{self.class.name.split('::').last.downcase} [options]"
|
34
|
+
end
|
35
|
+
|
36
|
+
def define_options(opts, options)
|
37
|
+
# To be implemented by subclasses
|
38
|
+
end
|
39
|
+
|
40
|
+
def validate_options(options)
|
41
|
+
# To be implemented by subclasses
|
42
|
+
end
|
43
|
+
|
44
|
+
def execute(options)
|
45
|
+
# To be implemented by subclasses
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appydave
|
4
|
+
module Tools
|
5
|
+
module CliActions
|
6
|
+
# CLI Action to get a YouTube video details
|
7
|
+
class GetVideoAction < BaseAction
|
8
|
+
protected
|
9
|
+
|
10
|
+
def define_options(opts, options)
|
11
|
+
opts.on('-v', '--video-id ID', 'YouTube Video ID') { |v| options[:video_id] = v }
|
12
|
+
end
|
13
|
+
|
14
|
+
def validate_options(options)
|
15
|
+
return if options[:video_id]
|
16
|
+
|
17
|
+
puts 'Missing required options: --video-id. Use -h for help.'
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
def execute(options)
|
22
|
+
get_video = Appydave::Tools::YouTubeManager::GetVideo.new
|
23
|
+
get_video.get(options[:video_id])
|
24
|
+
|
25
|
+
if get_video.video?
|
26
|
+
# json = JSON.pretty_generate(details)
|
27
|
+
# puts json
|
28
|
+
|
29
|
+
report = Appydave::Tools::YouTubeManager::Reports::VideoDetailsReport.new
|
30
|
+
report.print(get_video.data)
|
31
|
+
|
32
|
+
# report = Appydave::Tools::YouTubeManager::Reports::VideoContentReport.new
|
33
|
+
# report.print(manager.data)
|
34
|
+
else
|
35
|
+
puts "Video not found! Maybe it's private or deleted. ID: #{options[:video_id]}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'openai'
|
4
|
+
|
5
|
+
module Appydave
|
6
|
+
module Tools
|
7
|
+
module CliActions
|
8
|
+
# Action to run a completion prompt against the model
|
9
|
+
class PromptCompletionAction < BaseAction
|
10
|
+
DEFAULT_MODEL = 'gpt-4o'
|
11
|
+
DEFAULT_PLATFORM = 'openai'
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def define_options(opts, options)
|
16
|
+
opts.on('-p', '--prompt PROMPT', 'The prompt text') { |v| options[:prompt] = v }
|
17
|
+
opts.on('-f', '--file FILE', 'The prompt file') { |v| options[:file] = v }
|
18
|
+
opts.on('-o', '--output FILE', 'Output file') { |v| options[:output] = v }
|
19
|
+
opts.on('-c', '--clipboard', 'Copy result to clipboard') { |v| options[:clipboard] = v }
|
20
|
+
opts.on('-m', '--model MODEL', "Model to use (default: #{DEFAULT_MODEL})") { |v| options[:model] = v }
|
21
|
+
opts.on('-k', '--key-value PAIR', 'Key-value pairs for interpolation (format: key1=value1,key2=value2)') { |v| options[:key_value] = v }
|
22
|
+
end
|
23
|
+
|
24
|
+
def validate_options(options)
|
25
|
+
unless options[:prompt] || options[:file]
|
26
|
+
puts 'Missing required options: --prompt or --file. Use -h for help.'
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
if options[:key_value]
|
31
|
+
key_value_pairs = options[:key_value].split(',').to_h { |pair| pair.split('=') }
|
32
|
+
options[:key_value] = key_value_pairs
|
33
|
+
else
|
34
|
+
options[:key_value] = {}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute(options)
|
39
|
+
prompt_text = options[:prompt] || File.read(options[:file])
|
40
|
+
model = options[:model] || DEFAULT_MODEL
|
41
|
+
key_value_pairs = options[:key_value] || {}
|
42
|
+
|
43
|
+
# Interpolate key-value pairs into the prompt
|
44
|
+
key_value_pairs.each do |key, value|
|
45
|
+
prompt_text.gsub!("{#{key}}", value)
|
46
|
+
end
|
47
|
+
|
48
|
+
puts "Prompt: #{prompt_text}"
|
49
|
+
puts "Model: #{model}"
|
50
|
+
puts "Key-Value Pairs: #{key_value_pairs}"
|
51
|
+
|
52
|
+
# USE Library class to run this type of code
|
53
|
+
# client = OpenAI::Client.new(api_key: ENV['OPENAI_API_KEY'])
|
54
|
+
# response = client.completions(
|
55
|
+
# engine: model,
|
56
|
+
# parameters: {
|
57
|
+
# prompt: prompt_text,
|
58
|
+
# max_tokens: 100
|
59
|
+
# }
|
60
|
+
# )
|
61
|
+
|
62
|
+
# result = response['choices'].first['text'].strip
|
63
|
+
|
64
|
+
# if options[:output]
|
65
|
+
# File.write(options[:output], result)
|
66
|
+
# puts "Output written to #{options[:output]}"
|
67
|
+
# end
|
68
|
+
|
69
|
+
# if options[:clipboard]
|
70
|
+
# Clipboard.copy(result)
|
71
|
+
# puts 'Output copied to clipboard'
|
72
|
+
# end
|
73
|
+
|
74
|
+
puts 'Result:'
|
75
|
+
# puts result unless options[:output]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appydave
|
4
|
+
module Tools
|
5
|
+
module CliActions
|
6
|
+
# Action to update a YouTube video metadata (title, description, tags, category)
|
7
|
+
class UpdateVideoAction < BaseAction
|
8
|
+
protected
|
9
|
+
|
10
|
+
def define_options(opts, options)
|
11
|
+
opts.on('-v', '--video-id ID', 'YouTube Video ID') { |v| options[:video_id] = v }
|
12
|
+
opts.on('-t', '--title TITLE', 'Video Title') { |t| options[:title] = t }
|
13
|
+
opts.on('-d', '--description DESCRIPTION', 'Video Description') { |d| options[:description] = d }
|
14
|
+
opts.on('-g', '--tags TAGS', 'Video Tags (comma-separated)') { |g| options[:tags] = g.split(',') }
|
15
|
+
opts.on('-c', '--category-id CATEGORY_ID', 'Video Category ID') { |c| options[:category_id] = c }
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate_options(options)
|
19
|
+
return if options[:video_id]
|
20
|
+
|
21
|
+
puts 'Missing required options: --video-id. Use -h for help.'
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
|
25
|
+
def execute(options)
|
26
|
+
get_video = Appydave::Tools::YouTubeManager::GetVideo.new
|
27
|
+
get_video.get(options[:video_id])
|
28
|
+
|
29
|
+
if get_video.video?
|
30
|
+
update_video = Appydave::Tools::YouTubeManager::UpdateVideo.new(get_video.data)
|
31
|
+
|
32
|
+
update_video.title(options[:title]) if options[:title]
|
33
|
+
update_video.description(options[:description]) if options[:description]
|
34
|
+
update_video.tags(options[:tags]) if options[:tags]
|
35
|
+
update_video.category_id(options[:category_id]) if options[:category_id]
|
36
|
+
|
37
|
+
update_video.save
|
38
|
+
puts "Video updated successfully. ID: #{options[:video_id]}"
|
39
|
+
else
|
40
|
+
puts "Video not found! Maybe it's private or deleted. ID: #{options[:video_id]}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/appydave/tools.rb
CHANGED
@@ -22,8 +22,12 @@ require 'appydave/tools/types/indifferent_access_hash'
|
|
22
22
|
require 'appydave/tools/types/hash_type'
|
23
23
|
require 'appydave/tools/types/array_type'
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
require 'appydave/tools/cli_actions/base_action'
|
26
|
+
|
27
|
+
# May want to move this into the tools location
|
28
|
+
require 'appydave/tools/cli_actions/prompt_completion_action'
|
29
|
+
require 'appydave/tools/cli_actions/get_video_action'
|
30
|
+
require 'appydave/tools/cli_actions/update_video_action'
|
27
31
|
|
28
32
|
require 'appydave/tools/gpt_context/file_collector'
|
29
33
|
|
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "appydave-tools",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.10.0",
|
4
4
|
"lockfileVersion": 3,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "appydave-tools",
|
9
|
-
"version": "0.
|
9
|
+
"version": "0.10.0",
|
10
10
|
"devDependencies": {
|
11
11
|
"@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
|
12
12
|
"@semantic-release/changelog": "^6.0.3",
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appydave-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- bin/configuration.rb
|
161
161
|
- bin/console
|
162
162
|
- bin/gpt_context.rb
|
163
|
+
- bin/prompt_tools.rb
|
163
164
|
- bin/setup
|
164
165
|
- bin/subtitle_master.rb
|
165
166
|
- bin/youtube_automation.rb
|
@@ -171,6 +172,11 @@ files:
|
|
171
172
|
- lib/appydave/tools/bank_reconciliation/clean/mapper.rb
|
172
173
|
- lib/appydave/tools/bank_reconciliation/clean/read_transactions.rb
|
173
174
|
- lib/appydave/tools/bank_reconciliation/models/transaction.rb
|
175
|
+
- lib/appydave/tools/cli_actions/_doc.md
|
176
|
+
- lib/appydave/tools/cli_actions/base_action.rb
|
177
|
+
- lib/appydave/tools/cli_actions/get_video_action.rb
|
178
|
+
- lib/appydave/tools/cli_actions/prompt_completion_action.rb
|
179
|
+
- lib/appydave/tools/cli_actions/update_video_action.rb
|
174
180
|
- lib/appydave/tools/configuration/_doc.md
|
175
181
|
- lib/appydave/tools/configuration/config.rb
|
176
182
|
- lib/appydave/tools/configuration/configurable.rb
|