lluminary 0.1.1 → 0.1.3
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/lib/lluminary/config.rb +6 -1
- data/lib/lluminary/models/base.rb +235 -0
- data/lib/lluminary/models/bedrock/amazon_nova_pro_v1.rb +19 -0
- data/lib/lluminary/models/bedrock/anthropic_claude_instant_v1.rb +17 -0
- data/lib/lluminary/models/bedrock/base.rb +29 -0
- data/lib/lluminary/models/openai/gpt35_turbo.rb +20 -0
- data/lib/lluminary/provider_error.rb +2 -1
- data/lib/lluminary/providers/base.rb +20 -3
- data/lib/lluminary/providers/bedrock.rb +52 -32
- data/lib/lluminary/providers/openai.rb +41 -24
- data/lib/lluminary/providers/test.rb +14 -13
- data/lib/lluminary/result.rb +5 -2
- data/lib/lluminary/schema.rb +59 -15
- data/lib/lluminary/schema_model.rb +67 -10
- data/lib/lluminary/task.rb +58 -99
- data/lib/lluminary/validation_error.rb +2 -1
- data/lib/lluminary/version.rb +3 -2
- data/lib/lluminary.rb +25 -7
- data/spec/examples/analyze_text_spec.rb +7 -4
- data/spec/examples/color_analyzer_spec.rb +22 -22
- data/spec/examples/content_analyzer_spec.rb +27 -44
- data/spec/examples/historical_event_analyzer_spec.rb +18 -15
- data/spec/examples/meal_suggester_spec.rb +64 -0
- data/spec/examples/price_analyzer_spec.rb +22 -28
- data/spec/examples/quote_task_spec.rb +9 -8
- data/spec/examples/sentiment_analysis_spec.rb +13 -10
- data/spec/examples/summarize_text_spec.rb +7 -4
- data/spec/lluminary/config_spec.rb +28 -26
- data/spec/lluminary/models/base_spec.rb +581 -0
- data/spec/lluminary/models/bedrock/amazon_nova_pro_v1_spec.rb +30 -0
- data/spec/lluminary/models/bedrock/anthropic_claude_instant_v1_spec.rb +21 -0
- data/spec/lluminary/models/openai/gpt35_turbo_spec.rb +22 -0
- data/spec/lluminary/providers/bedrock_spec.rb +86 -57
- data/spec/lluminary/providers/openai_spec.rb +58 -34
- data/spec/lluminary/providers/test_spec.rb +46 -16
- data/spec/lluminary/result_spec.rb +17 -10
- data/spec/lluminary/schema_model_spec.rb +108 -22
- data/spec/lluminary/schema_spec.rb +241 -107
- data/spec/lluminary/task_spec.rb +118 -584
- data/spec/spec_helper.rb +8 -2
- metadata +73 -22
- data/lib/lluminary/field_description.rb +0 -148
- data/spec/lluminary/field_description_spec.rb +0 -36
- data/spec/lluminary/providers/base_spec.rb +0 -17
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lluminary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Hughes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 5.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: aws-sdk-bedrock
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.0'
|
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: '
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: aws-sdk-bedrockruntime
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,19 +53,47 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: ruby-openai
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3
|
61
|
+
version: '6.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '6.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dotenv
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.8'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '2.8'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.10'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.10'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rake
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +108,20 @@ dependencies:
|
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '13.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.12'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.12'
|
83
125
|
- !ruby/object:Gem::Dependency
|
84
126
|
name: rubocop
|
85
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,36 +137,38 @@ dependencies:
|
|
95
137
|
- !ruby/object:Gem::Version
|
96
138
|
version: '1.50'
|
97
139
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
140
|
+
name: syntax_tree
|
99
141
|
requirement: !ruby/object:Gem::Requirement
|
100
142
|
requirements:
|
101
143
|
- - "~>"
|
102
144
|
- !ruby/object:Gem::Version
|
103
|
-
version: '2
|
145
|
+
version: '6.2'
|
104
146
|
type: :development
|
105
147
|
prerelease: false
|
106
148
|
version_requirements: !ruby/object:Gem::Requirement
|
107
149
|
requirements:
|
108
150
|
- - "~>"
|
109
151
|
- !ruby/object:Gem::Version
|
110
|
-
version: '2
|
152
|
+
version: '6.2'
|
111
153
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
154
|
+
name: awesome_print
|
113
155
|
requirement: !ruby/object:Gem::Requirement
|
114
156
|
requirements:
|
115
157
|
- - "~>"
|
116
158
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
159
|
+
version: '1.9'
|
118
160
|
type: :development
|
119
161
|
prerelease: false
|
120
162
|
version_requirements: !ruby/object:Gem::Requirement
|
121
163
|
requirements:
|
122
164
|
- - "~>"
|
123
165
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
125
|
-
description: Lluminary is a framework for building applications that leverage Large
|
166
|
+
version: '1.9'
|
167
|
+
description: 'Lluminary is a framework for building applications that leverage Large
|
126
168
|
Language Models. It provides a structured way to define tasks, manage prompts, and
|
127
169
|
handle LLM interactions.
|
170
|
+
|
171
|
+
'
|
128
172
|
email:
|
129
173
|
- doug@doughughes.net
|
130
174
|
executables: []
|
@@ -133,7 +177,11 @@ extra_rdoc_files: []
|
|
133
177
|
files:
|
134
178
|
- lib/lluminary.rb
|
135
179
|
- lib/lluminary/config.rb
|
136
|
-
- lib/lluminary/
|
180
|
+
- lib/lluminary/models/base.rb
|
181
|
+
- lib/lluminary/models/bedrock/amazon_nova_pro_v1.rb
|
182
|
+
- lib/lluminary/models/bedrock/anthropic_claude_instant_v1.rb
|
183
|
+
- lib/lluminary/models/bedrock/base.rb
|
184
|
+
- lib/lluminary/models/openai/gpt35_turbo.rb
|
137
185
|
- lib/lluminary/provider_error.rb
|
138
186
|
- lib/lluminary/providers/base.rb
|
139
187
|
- lib/lluminary/providers/bedrock.rb
|
@@ -149,13 +197,16 @@ files:
|
|
149
197
|
- spec/examples/color_analyzer_spec.rb
|
150
198
|
- spec/examples/content_analyzer_spec.rb
|
151
199
|
- spec/examples/historical_event_analyzer_spec.rb
|
200
|
+
- spec/examples/meal_suggester_spec.rb
|
152
201
|
- spec/examples/price_analyzer_spec.rb
|
153
202
|
- spec/examples/quote_task_spec.rb
|
154
203
|
- spec/examples/sentiment_analysis_spec.rb
|
155
204
|
- spec/examples/summarize_text_spec.rb
|
156
205
|
- spec/lluminary/config_spec.rb
|
157
|
-
- spec/lluminary/
|
158
|
-
- spec/lluminary/
|
206
|
+
- spec/lluminary/models/base_spec.rb
|
207
|
+
- spec/lluminary/models/bedrock/amazon_nova_pro_v1_spec.rb
|
208
|
+
- spec/lluminary/models/bedrock/anthropic_claude_instant_v1_spec.rb
|
209
|
+
- spec/lluminary/models/openai/gpt35_turbo_spec.rb
|
159
210
|
- spec/lluminary/providers/bedrock_spec.rb
|
160
211
|
- spec/lluminary/providers/openai_spec.rb
|
161
212
|
- spec/lluminary/providers/test_spec.rb
|
@@ -1,148 +0,0 @@
|
|
1
|
-
module Lluminary
|
2
|
-
class FieldDescription
|
3
|
-
def initialize(name, field)
|
4
|
-
@name = name
|
5
|
-
@type = field[:type]
|
6
|
-
@description = field[:description]
|
7
|
-
@validations = field[:validations] || []
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_s
|
11
|
-
parts = []
|
12
|
-
parts << "#{@name} (#{type_description})"
|
13
|
-
parts << ": #{@description}" if @description
|
14
|
-
parts << " (#{validation_descriptions.join(', ')})" if validation_descriptions.any?
|
15
|
-
parts.join
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_schema_s
|
19
|
-
parts = []
|
20
|
-
parts << "#{@name} (#{type_description})"
|
21
|
-
parts << ": #{@description}" if @description
|
22
|
-
parts << "\nValidation: #{validation_descriptions.join(', ')}" if validation_descriptions.any?
|
23
|
-
parts << "\nExample: #{example_value}"
|
24
|
-
parts.join
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def type_description
|
30
|
-
case @type
|
31
|
-
when :datetime
|
32
|
-
"datetime in ISO8601 format"
|
33
|
-
else
|
34
|
-
@type.to_s
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def validation_descriptions
|
39
|
-
@validations.map do |_, options|
|
40
|
-
case options.keys.first
|
41
|
-
when :absence
|
42
|
-
"must be absent"
|
43
|
-
when :comparison
|
44
|
-
comparison_descriptions(options[:comparison])
|
45
|
-
when :exclusion
|
46
|
-
"must not be one of: #{options[:exclusion][:in].join(', ')}"
|
47
|
-
when :format
|
48
|
-
"must match format: #{options[:format][:with]}"
|
49
|
-
when :inclusion
|
50
|
-
"must be one of: #{options[:inclusion][:in].join(', ')}"
|
51
|
-
when :length
|
52
|
-
length_descriptions(options[:length])
|
53
|
-
when :numericality
|
54
|
-
numericality_descriptions(options[:numericality])
|
55
|
-
when :presence
|
56
|
-
"must be present"
|
57
|
-
end
|
58
|
-
end.compact
|
59
|
-
end
|
60
|
-
|
61
|
-
def comparison_descriptions(options)
|
62
|
-
descriptions = []
|
63
|
-
if options[:greater_than]
|
64
|
-
descriptions << "must be greater than #{options[:greater_than]}"
|
65
|
-
end
|
66
|
-
if options[:greater_than_or_equal_to]
|
67
|
-
descriptions << "must be greater than or equal to #{options[:greater_than_or_equal_to]}"
|
68
|
-
end
|
69
|
-
if options[:equal_to]
|
70
|
-
descriptions << "must be equal to #{options[:equal_to]}"
|
71
|
-
end
|
72
|
-
if options[:less_than]
|
73
|
-
descriptions << "must be less than #{options[:less_than]}"
|
74
|
-
end
|
75
|
-
if options[:less_than_or_equal_to]
|
76
|
-
descriptions << "must be less than or equal to #{options[:less_than_or_equal_to]}"
|
77
|
-
end
|
78
|
-
if options[:other_than]
|
79
|
-
descriptions << "must be other than #{options[:other_than]}"
|
80
|
-
end
|
81
|
-
descriptions.join(", ")
|
82
|
-
end
|
83
|
-
|
84
|
-
def length_descriptions(options)
|
85
|
-
descriptions = []
|
86
|
-
if options[:minimum]
|
87
|
-
descriptions << "must be at least #{options[:minimum]} characters"
|
88
|
-
end
|
89
|
-
if options[:maximum]
|
90
|
-
descriptions << "must be at most #{options[:maximum]} characters"
|
91
|
-
end
|
92
|
-
if options[:is]
|
93
|
-
descriptions << "must be exactly #{options[:is]} characters"
|
94
|
-
end
|
95
|
-
if options[:in]
|
96
|
-
descriptions << "must be between #{options[:in].min} and #{options[:in].max} characters"
|
97
|
-
end
|
98
|
-
descriptions.join(", ")
|
99
|
-
end
|
100
|
-
|
101
|
-
def numericality_descriptions(options)
|
102
|
-
descriptions = []
|
103
|
-
if options[:greater_than]
|
104
|
-
descriptions << "must be greater than #{options[:greater_than]}"
|
105
|
-
end
|
106
|
-
if options[:greater_than_or_equal_to]
|
107
|
-
descriptions << "must be greater than or equal to #{options[:greater_than_or_equal_to]}"
|
108
|
-
end
|
109
|
-
if options[:equal_to]
|
110
|
-
descriptions << "must be equal to #{options[:equal_to]}"
|
111
|
-
end
|
112
|
-
if options[:less_than]
|
113
|
-
descriptions << "must be less than #{options[:less_than]}"
|
114
|
-
end
|
115
|
-
if options[:less_than_or_equal_to]
|
116
|
-
descriptions << "must be less than or equal to #{options[:less_than_or_equal_to]}"
|
117
|
-
end
|
118
|
-
if options[:other_than]
|
119
|
-
descriptions << "must be other than #{options[:other_than]}"
|
120
|
-
end
|
121
|
-
if options[:in]
|
122
|
-
descriptions << "must be in: #{options[:in].to_a.join(', ')}"
|
123
|
-
end
|
124
|
-
if options[:odd]
|
125
|
-
descriptions << "must be odd"
|
126
|
-
end
|
127
|
-
if options[:even]
|
128
|
-
descriptions << "must be even"
|
129
|
-
end
|
130
|
-
descriptions.join(", ")
|
131
|
-
end
|
132
|
-
|
133
|
-
def example_value
|
134
|
-
case @type
|
135
|
-
when :string
|
136
|
-
"\"your #{@name} here\""
|
137
|
-
when :integer
|
138
|
-
"0"
|
139
|
-
when :datetime
|
140
|
-
"\"2024-01-01T12:00:00+00:00\""
|
141
|
-
when :boolean
|
142
|
-
"true"
|
143
|
-
when :float
|
144
|
-
"0.0"
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Lluminary::FieldDescription do
|
4
|
-
describe '#to_s' do
|
5
|
-
it 'generates a description for a string field' do
|
6
|
-
field = {
|
7
|
-
type: :string,
|
8
|
-
description: 'A test field'
|
9
|
-
}
|
10
|
-
description = described_class.new('test_field', field)
|
11
|
-
expect(description.to_s).to eq('test_field (string): A test field')
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'generates a description for a field without a description' do
|
15
|
-
field = {
|
16
|
-
type: :integer
|
17
|
-
}
|
18
|
-
description = described_class.new('count', field)
|
19
|
-
expect(description.to_s).to eq('count (integer)')
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'includes validation descriptions when present' do
|
23
|
-
field = {
|
24
|
-
type: :string,
|
25
|
-
description: 'A test field',
|
26
|
-
validations: [
|
27
|
-
[{}, { length: { minimum: 5, maximum: 10 } }],
|
28
|
-
[{}, { format: { with: '/^[A-Z]+$/' } }]
|
29
|
-
]
|
30
|
-
}
|
31
|
-
description = described_class.new('test_field', field)
|
32
|
-
expected = 'test_field (string): A test field (must be at least 5 characters, must be at most 10 characters, must match format: /^[A-Z]+$/)'
|
33
|
-
expect(description.to_s).to eq(expected)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'lluminary'
|
2
|
-
|
3
|
-
RSpec.describe Lluminary::Providers::Base do
|
4
|
-
describe '#initialize' do
|
5
|
-
it 'accepts configuration options' do
|
6
|
-
config = { api_key: 'test_key', model: 'test_model' }
|
7
|
-
provider = described_class.new(**config)
|
8
|
-
expect(provider.config).to eq(config)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#call' do
|
13
|
-
it 'raises NotImplementedError' do
|
14
|
-
expect { described_class.new.call('test', double('Task')) }.to raise_error(NotImplementedError)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|