activerage 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 250d9a9b72a053184a1beb954b2246f1ad7632ee6d7fcb26885ca3989af62520
4
+ data.tar.gz: b36a58e4605afdc47755c2d9e5ec80ebbdf18111a43d0e759080533b19d814c2
5
+ SHA512:
6
+ metadata.gz: c9cec420afffc918b1ba65c869b703cc1467711140f7b5d88e13519c539ee09507c01cd0e8109c3acb60c259876e878cabd88a018e563d4dea79c6c545482a09
7
+ data.tar.gz: e95c25df4669225349f01c26b53c8901335926726735b325dfbf217807ef5ee56f5d6a71375d6be3dbeb8b224465c0619f967be890ddab4f623b8bf0970e406a
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Abdelkader Boudih
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # ActiveRage
2
+
3
+ A Rails engine for RAG (Retrieval Augmented Generation) functionality.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'activerage'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle install
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### Configuration
22
+
23
+ Create a configuration file at `config/active_rage.yml`:
24
+
25
+ ```yaml
26
+ development:
27
+ embedding_model: "text-embedding-3-small"
28
+ search_limit: 10
29
+ vector_dimensions: 1536
30
+ ```
31
+
32
+ ### Basic Setup
33
+
34
+ ```ruby
35
+ # config/initializers/active_rage.rb
36
+ ActiveRage.configure do |config|
37
+ config.embedding_model = "text-embedding-3-small"
38
+ config.search_limit = 10
39
+ end
40
+ ```
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests.
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/seuros/active_rage.
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ t.verbose = true
11
+ end
12
+
13
+ task default: :test
14
+
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRage
4
+ class ApplicationJob < ActiveJob::Base
5
+ # Placeholder
6
+ end
7
+ end
8
+
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRage
4
+ class IndexingJob < ApplicationJob
5
+ # Placeholder
6
+ end
7
+ end
8
+
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRage
4
+ class ApplicationRecord < ActiveRecord::Base
5
+ self.abstract_class = true
6
+ end
7
+ end
8
+
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRage
4
+ class Document < ApplicationRecord
5
+ # Placeholder
6
+ end
7
+ end
8
+
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRage
4
+ class EmbeddingService
5
+ # Placeholder
6
+ end
7
+ end
8
+
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRage
4
+ class SearchService
5
+ # Placeholder
6
+ end
7
+ end
8
+
@@ -0,0 +1,14 @@
1
+ development:
2
+ embedding_model: "text-embedding-3-small"
3
+ search_limit: 10
4
+ vector_dimensions: 1536
5
+
6
+ test:
7
+ embedding_model: "text-embedding-3-small"
8
+ search_limit: 5
9
+ vector_dimensions: 1536
10
+
11
+ production:
12
+ embedding_model: "text-embedding-3-large"
13
+ search_limit: 20
14
+ vector_dimensions: 3072
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRage
4
+ class Configuration
5
+ attr_accessor :environment, :embedding_model, :search_limit, :vector_dimensions
6
+
7
+ def initialize
8
+ @environment = 'development'
9
+ @embedding_model = nil
10
+ @search_limit = 10
11
+ @vector_dimensions = 1536
12
+ end
13
+
14
+ def load_from_file(path)
15
+ return unless File.exist?(path)
16
+
17
+ config = YAML.load_file(path)[environment]
18
+ return unless config
19
+
20
+ config.each do |key, value|
21
+ public_send("#{key}=", value) if respond_to?("#{key}=")
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRage
4
+ class Engine < Rails::Engine
5
+ isolate_namespace ActiveRage
6
+
7
+ config.active_rage = ActiveSupport::OrderedOptions.new
8
+
9
+ initializer 'active_rage.configure' do |app|
10
+ ActiveRage.configure do |config|
11
+ config.environment = Rails.env.to_s
12
+ config.load_from_file(app.config.active_rage.config_path) if app.config.active_rage.config_path
13
+ end
14
+ end
15
+
16
+ config.generators do |g|
17
+ g.test_framework :minitest
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRage
4
+ module VERSION
5
+ MAJOR = 0
6
+ MINOR = 0
7
+ TINY = 0
8
+ PRE = nil
9
+
10
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
11
+ end
12
+ end
13
+
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'zeitwerk'
4
+ require 'active_record'
5
+ require 'active_job'
6
+ require 'active_rage/engine' if defined?(Rails)
7
+
8
+ loader = Zeitwerk::Loader.for_gem
9
+ loader.ignore("#{__dir__}/generators")
10
+ loader.inflector.inflect(
11
+ 'openai' => 'OpenAI'
12
+ )
13
+ loader.setup
14
+
15
+ module ActiveRage
16
+ class Error < StandardError; end
17
+
18
+ mattr_accessor :configuration
19
+ @@configuration = nil
20
+
21
+ def self.configure
22
+ self.configuration ||= Configuration.new
23
+ yield(configuration) if block_given?
24
+ configuration
25
+ end
26
+
27
+ def self.config
28
+ configuration || configure
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Abdelkader Boudih
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: activejob
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '8'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '8'
26
+ - !ruby/object:Gem::Dependency
27
+ name: activerecord
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '8'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '8'
40
+ - !ruby/object:Gem::Dependency
41
+ name: activesupport
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '8'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '8'
54
+ - !ruby/object:Gem::Dependency
55
+ name: railties
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '8'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '8'
68
+ - !ruby/object:Gem::Dependency
69
+ name: zeitwerk
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: minitest
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '5.0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '5.0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rubocop
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rubocop-rails
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '2.0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '2.0'
124
+ - !ruby/object:Gem::Dependency
125
+ name: simplecov
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '0.21'
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '0.21'
138
+ description: A RAG (Retrieval Augmented Generation) engine that integrates seamlessly
139
+ with Rails applications
140
+ email:
141
+ - terminale@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - MIT-LICENSE
147
+ - README.md
148
+ - Rakefile
149
+ - app/jobs/active_rage/application_job.rb
150
+ - app/jobs/active_rage/indexing_job.rb
151
+ - app/models/active_rage/application_record.rb
152
+ - app/models/active_rage/document.rb
153
+ - app/services/active_rage/embedding_service.rb
154
+ - app/services/active_rage/search_service.rb
155
+ - config/active_rage.example.yml
156
+ - lib/active_rage.rb
157
+ - lib/active_rage/configuration.rb
158
+ - lib/active_rage/engine.rb
159
+ - lib/active_rage/version.rb
160
+ homepage: https://github.com/seuros/active_rage
161
+ licenses:
162
+ - MIT
163
+ metadata:
164
+ homepage_uri: https://github.com/seuros/active_rage
165
+ source_code_uri: https://github.com/seuros/active_rage
166
+ changelog_uri: https://github.com/seuros/active_rage/blob/master/CHANGELOG.md
167
+ rubygems_mfa_required: 'true'
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubygems_version: 3.6.9
183
+ specification_version: 4
184
+ summary: 'ActiveRage: RAG Engine for Rails'
185
+ test_files: []