appydave-tools 0.9.5 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -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/prompt_tools/models/platform_info.rb +0 -0
- data/lib/appydave/tools/types/array_type.rb +2 -0
- data/lib/appydave/tools/types/base_model.rb +13 -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 +7 -2
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +9 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1a94de7a92dafeaa54b86843c94dec8b25d108355782ba2f57eaf749a368b26
|
4
|
+
data.tar.gz: 41ad45648a7a1d3e3394092ef7a95a7ee93585d3e6435dfa1c6bb44d880c1b49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2f54c832a810f67a6230d38114f49a8877ce45f808daa90a0a1e9f11c6a1d641c69aaccbf38132edcdc628759f43642fd5f69314a586a7bb65716a7b6292dc0
|
7
|
+
data.tar.gz: 1aa6d410e0402e5d035ebd3054419e37e16f5bdee5b729940006b465607b0238ee28c4dec3c374139fd79dc9ec87377f736303ff95fd7d925ab343ed45eefa45
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# [0.10.0](https://github.com/klueless-io/appydave-tools/compare/v0.9.5...v0.10.0) (2024-06-13)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* cops ([ce8e657](https://github.com/klueless-io/appydave-tools/commit/ce8e657e4a167e7327d86782096bcf5e0a8e226e))
|
7
|
+
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
* starting the prompt tools component ([089043b](https://github.com/klueless-io/appydave-tools/commit/089043bca08dfb79a1b5f3741b55bb66f808adae))
|
12
|
+
|
13
|
+
## [0.9.5](https://github.com/klueless-io/appydave-tools/compare/v0.9.4...v0.9.5) (2024-06-13)
|
14
|
+
|
15
|
+
|
16
|
+
### Bug Fixes
|
17
|
+
|
18
|
+
* implement update video command ([c46473d](https://github.com/klueless-io/appydave-tools/commit/c46473dc550e34c041418adfd52444014e094917))
|
19
|
+
|
1
20
|
## [0.9.4](https://github.com/klueless-io/appydave-tools/compare/v0.9.3...v0.9.4) (2024-06-12)
|
2
21
|
|
3
22
|
|
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
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appydave
|
4
|
+
module Tools
|
5
|
+
module Types
|
6
|
+
# Used by the ActiveModel attributes API to cast values to hashes
|
7
|
+
class BaseModel
|
8
|
+
include ActiveModel::Model
|
9
|
+
include ActiveModel::Attributes
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/appydave/tools.rb
CHANGED
@@ -21,9 +21,14 @@ require 'appydave/tools/version'
|
|
21
21
|
require 'appydave/tools/types/indifferent_access_hash'
|
22
22
|
require 'appydave/tools/types/hash_type'
|
23
23
|
require 'appydave/tools/types/array_type'
|
24
|
+
require 'appydave/tools/types/base_model'
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
require 'appydave/tools/cli_actions/base_action'
|
27
|
+
|
28
|
+
# May want to move this into the tools location
|
29
|
+
require 'appydave/tools/cli_actions/prompt_completion_action'
|
30
|
+
require 'appydave/tools/cli_actions/get_video_action'
|
31
|
+
require 'appydave/tools/cli_actions/update_video_action'
|
27
32
|
|
28
33
|
require 'appydave/tools/gpt_context/file_collector'
|
29
34
|
|
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "appydave-tools",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.10.1",
|
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.1",
|
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.1
|
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
|
@@ -185,9 +191,11 @@ files:
|
|
185
191
|
- lib/appydave/tools/gpt_context/file_collector.rb
|
186
192
|
- lib/appydave/tools/name_manager/_doc.md
|
187
193
|
- lib/appydave/tools/name_manager/project_name.rb
|
194
|
+
- lib/appydave/tools/prompt_tools/models/platform_info.rb
|
188
195
|
- lib/appydave/tools/subtitle_master/_doc.md
|
189
196
|
- lib/appydave/tools/subtitle_master/clean.rb
|
190
197
|
- lib/appydave/tools/types/array_type.rb
|
198
|
+
- lib/appydave/tools/types/base_model.rb
|
191
199
|
- lib/appydave/tools/types/hash_type.rb
|
192
200
|
- lib/appydave/tools/types/indifferent_access_hash.rb
|
193
201
|
- lib/appydave/tools/version.rb
|