hyrum 0.0.2 → 0.1.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/CHANGELOG.md +17 -3
- data/lib/hyrum/generators/fake_generator.rb +1 -1
- data/lib/hyrum/generators/message_generator.rb +4 -2
- data/lib/hyrum/generators/openai_generator.rb +2 -2
- data/lib/hyrum/script_options.rb +15 -12
- data/lib/hyrum/version.rb +2 -2
- data/lib/hyrum.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7177d332d4a6a3e7a9527a906e39d4f141af5444aedbb3acff837b07b93f619
|
4
|
+
data.tar.gz: 9b0d67445326a57b5aa4f1bc2926cf06455609f491c75c08e65889a8d019b481
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa204a19e6e0080792381c09904cc0fcf013b05490875b4f793f4135b3cec0d605d544261266a6b00f54be2a30ddfef4d3fd44e2f8be17060f49924fabe528b3
|
7
|
+
data.tar.gz: 17ceb22c5ea1b7a3837ce9195cc4b0f8a9b4276d502e3a9b4f4450aec61f5bcb780eaf135f2d9ac92717c060a81cf1423af751ef34de54faf532850c67b024f0
|
data/CHANGELOG.md
CHANGED
@@ -5,12 +5,19 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
-
## [0.0
|
8
|
+
## [0.1.0] - 2024-12-16
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- Minor bug fixes and spec updates
|
13
|
+
- Option defaults added in help where appropriate
|
9
14
|
|
10
15
|
### Added
|
11
16
|
|
12
|
-
-
|
13
|
-
-
|
17
|
+
- New -n | --number option to specify number of messages to produce
|
18
|
+
- New ScriptOption specs
|
19
|
+
- New MessageGenerator specs
|
20
|
+
- New FakeGenerator specs
|
14
21
|
|
15
22
|
## [0.0.2] - 2024-12-06
|
16
23
|
|
@@ -22,3 +29,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
22
29
|
### Added
|
23
30
|
|
24
31
|
- New OpenAI generator specs
|
32
|
+
|
33
|
+
## [0.0.1] - 2024-12-01
|
34
|
+
|
35
|
+
### Added
|
36
|
+
|
37
|
+
- This CHANGELOG file
|
38
|
+
- Initial version of the project
|
@@ -18,9 +18,11 @@ module Hyrum
|
|
18
18
|
|
19
19
|
class MessageGenerator
|
20
20
|
def self.create(options)
|
21
|
-
|
21
|
+
unless GENERATOR_CLASSES.key?(options[:ai_service].to_sym)
|
22
|
+
raise ArgumentError, "Invalid AI service: #{options[:ai_service]}"
|
23
|
+
end
|
22
24
|
|
23
|
-
|
25
|
+
generator_class = GENERATOR_CLASSES[options[:ai_service].to_sym]
|
24
26
|
generator_class.new(options)
|
25
27
|
end
|
26
28
|
end
|
@@ -26,12 +26,12 @@ module Hyrum
|
|
26
26
|
|
27
27
|
def prompt
|
28
28
|
prompt = <<~PROMPT
|
29
|
-
Please provide
|
29
|
+
Please provide <%= number %> alternative status messages for the following message:
|
30
30
|
`<%= message %>`. The messages should be unique and informative. The messages
|
31
31
|
should be returned as json in the format: `{ "<%= key %>": ['list', 'of', 'messages']}`
|
32
32
|
The key should be `"<%= key %>"` followed by the list of messages.
|
33
33
|
PROMPT
|
34
|
-
erb_hash = { key: options[:key], message: options[:message] }
|
34
|
+
erb_hash = { key: options[:key], message: options[:message], number: options[:number] }
|
35
35
|
template = ERB.new(prompt, trim_mode: '-')
|
36
36
|
template.result_with_hash(erb_hash)
|
37
37
|
end
|
data/lib/hyrum/script_options.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'optparse'
|
4
4
|
|
5
5
|
module Hyrum
|
6
|
+
class ScriptOptionsError < StandardError; end
|
7
|
+
|
6
8
|
class ScriptOptions
|
7
9
|
MANDATORY_OPTIONS = %i[message].freeze
|
8
10
|
|
@@ -22,16 +24,11 @@ module Hyrum
|
|
22
24
|
set_dynamic_defaults
|
23
25
|
options
|
24
26
|
rescue OptionParser::InvalidOption => e
|
25
|
-
|
27
|
+
raise ScriptOptionsError.new("Invalid option: #{e.message}")
|
26
28
|
rescue OptionParser::MissingArgument => e
|
27
|
-
|
29
|
+
raise ScriptOptionsError.new("Missing argument for option: #{e.message}")
|
28
30
|
rescue OptionParser::InvalidArgument => e
|
29
|
-
|
30
|
-
ensure
|
31
|
-
if err
|
32
|
-
puts err
|
33
|
-
exit
|
34
|
-
end
|
31
|
+
raise ScriptOptionsError.new("Invalid argument for option: #{e.message}")
|
35
32
|
end
|
36
33
|
|
37
34
|
private
|
@@ -74,7 +71,7 @@ module Hyrum
|
|
74
71
|
def ai_service_options(parser)
|
75
72
|
options[:ai_service] = :fake
|
76
73
|
|
77
|
-
description = "AI service: one of #{Generators::AI_SERVICES.join(', ')}"
|
74
|
+
description = "AI service: one of #{Generators::AI_SERVICES.join(', ')} (default: fake)"
|
78
75
|
parser.on('-s SERVICE', '--service SERVICE', Generators::AI_SERVICES, description) do |service|
|
79
76
|
options[:ai_service] = service.to_sym
|
80
77
|
end
|
@@ -88,15 +85,21 @@ module Hyrum
|
|
88
85
|
def message_key_options(parser)
|
89
86
|
options[:key] = :status
|
90
87
|
|
91
|
-
parser.on('-k KEY', '--key KEY', 'Message key') do |key|
|
88
|
+
parser.on('-k KEY', '--key KEY', 'Message key (default: status)') do |key|
|
92
89
|
options[:key] = key.to_sym
|
93
90
|
end
|
94
91
|
end
|
95
92
|
|
96
93
|
def message_options(parser)
|
97
|
-
parser.on('-m MESSAGE', '--message MESSAGE', 'Status message') do |message|
|
94
|
+
parser.on('-m MESSAGE', '--message MESSAGE', 'Status message (required)') do |message|
|
98
95
|
options[:message] = message
|
99
96
|
end
|
97
|
+
|
98
|
+
options[:number] = 5
|
99
|
+
|
100
|
+
parser.on('-n NUMBER', '--number NUMBER', Integer, 'Number of messages to generate (default: 5)',) do |number|
|
101
|
+
options[:number] = number.to_i
|
102
|
+
end
|
100
103
|
end
|
101
104
|
|
102
105
|
def verbosity_options(parser)
|
@@ -111,7 +114,7 @@ module Hyrum
|
|
111
114
|
formats = Formats::FORMATS
|
112
115
|
description = 'Output format. Supported formats are:'
|
113
116
|
supported = formats.join(', ')
|
114
|
-
parser.on('-f FORMAT', '--format FORMAT', formats, description, supported) do |format|
|
117
|
+
parser.on('-f FORMAT', '--format FORMAT', formats, description, supported, "(default: text)") do |format|
|
115
118
|
options[:format] = format
|
116
119
|
end
|
117
120
|
end
|
data/lib/hyrum/version.rb
CHANGED
data/lib/hyrum.rb
CHANGED
@@ -8,7 +8,7 @@ loader.setup
|
|
8
8
|
module Hyrum
|
9
9
|
def self.run(args)
|
10
10
|
options = ScriptOptions.new(args).parse
|
11
|
-
generator_opts = options.slice(:message, :key, :ai_service, :ai_model, :verbose)
|
11
|
+
generator_opts = options.slice(:message, :key, :ai_service, :ai_model, :number, :verbose)
|
12
12
|
formatter_opts = options.slice(:format, :verbose)
|
13
13
|
|
14
14
|
puts "Options: #{options.inspect}" if options[:verbose]
|
@@ -17,6 +17,9 @@ module Hyrum
|
|
17
17
|
messages = message_generator.generate
|
18
18
|
output = formatter.format(messages)
|
19
19
|
puts output
|
20
|
+
rescue ScriptOptionsError => e
|
21
|
+
puts e.message
|
22
|
+
exit
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyrum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tracy Atteberry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-openai
|