AIFaker 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7bde2c3f571fa5b745523114e1313f79ea768b1c48408918cbe9a1f2975e9c2a
4
+ data.tar.gz: 1fe46a60220f6fb95ef4308db036b317a8e17ac7508c4af8b72db0f480ee9b2c
5
+ SHA512:
6
+ metadata.gz: bf33a25da19a490ef4337bb59794c59919b380ccf76138617c42015de4f0243b56cf0d54fd6958c21db02721930674f0f7575e20d2b38e4a7d9032a9e9a88e78
7
+ data.tar.gz: 54ad8a9d77abd245309fd8c0fa0f1b8791b2e46b28ff2a8c4913a0fc4959a675aac2d277d5b4645069641f84804a6ad7e55fa2bdbd1b56bcf2eea754d15eee7a
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 TODO: Write your name
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,245 @@
1
+ # AIFaker
2
+
3
+ AI-powered, schema-aware Rails seeding for modern teams.
4
+
5
+ `AIFaker` helps developers, startups, and product teams generate realistic demo and test data in minutes instead of spending hours writing and maintaining manual `db/seeds.rb` logic.
6
+
7
+ It reads your Rails schema and model relationships, uses an LLM to generate meaningful attributes, and creates records in dependency order (`belongs_to` parents first) so your data is usable from day one.
8
+
9
+ Why teams use AIFaker:
10
+
11
+ - realistic data for demos, QA, staging, and local development
12
+ - faster onboarding for new developers (no manual seed setup)
13
+ - schema-aware generation that respects model structure and validations
14
+ - automatic retry + repair flow for common seeding failures
15
+ - provider flexibility (`openai`, `claude`/`anthropic`, `gemini`, `deepseek`, `bedrock`)
16
+
17
+ ## Installation
18
+
19
+ Add both gems to your Rails app:
20
+
21
+ ```bash
22
+ bundle add AIFaker
23
+ bundle add ruby_llm
24
+ ```
25
+
26
+ Or in `Gemfile`:
27
+
28
+ ```ruby
29
+ gem "AIFaker"
30
+ gem "ruby_llm"
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ Set provider + API key in your shell:
36
+
37
+ ```bash
38
+ export AIFAKER_PROVIDER=openai
39
+ export OPENAI_API_KEY="your_key_here"
40
+ ```
41
+
42
+ Create `db/seeds.rb`:
43
+
44
+ ```ruby
45
+ client = AIFaker.connect
46
+ client.seed!
47
+ ```
48
+
49
+ Run:
50
+
51
+ ```bash
52
+ rails db:seed
53
+ ```
54
+
55
+ ## What To Write In `db/seeds.rb`
56
+
57
+ ### 1) Interactive mode (default)
58
+
59
+ If you do not set `automode`, it stays `false` by default.
60
+
61
+ ```ruby
62
+ client = AIFaker.connect
63
+ client.seed!
64
+ ```
65
+
66
+ Behavior:
67
+
68
+ - asks confirmation before seeding
69
+ - asks count per table (range: 5..50)
70
+ - asks per model/table whether to seed or skip
71
+
72
+ ### 2) Non-interactive mode (`client.automode = true`)
73
+
74
+ ```ruby
75
+ client = AIFaker.connect
76
+ client.automode = true
77
+ client.seed!
78
+ ```
79
+
80
+ Behavior:
81
+
82
+ - no prompts (auto-yes everywhere)
83
+ - random count per table (`10..20`)
84
+ - seeds all models in planned order
85
+
86
+ Equivalent shorthand:
87
+
88
+ ```ruby
89
+ client = AIFaker.connect
90
+ client.automode!
91
+ client.seed!
92
+ ```
93
+
94
+ ### 3) Explicit provider in code
95
+
96
+ ```ruby
97
+ client = AIFaker.connect("gemini")
98
+ client.automode = true
99
+ client.seed!
100
+ ```
101
+
102
+ `AIFaker.connect` provider fallback order:
103
+
104
+ 1. explicit argument (`AIFaker.connect("gemini")`)
105
+ 2. `ENV["AIFAKER_PROVIDER"]`
106
+ 3. default `"openai"`
107
+
108
+ `claude` is also supported as a friendly alias for Anthropic:
109
+
110
+ ```ruby
111
+ client = AIFaker.connect("claude") # internally uses anthropic provider
112
+ client.seed!
113
+ ```
114
+
115
+ ## Environment Variables
116
+
117
+ ### Provider selection
118
+
119
+ - `AIFAKER_PROVIDER` -> `openai | anthropic | claude | gemini | deepseek | bedrock`
120
+
121
+ ### Provider credentials
122
+
123
+ - `OPENAI_API_KEY` for `openai`
124
+ - `ANTHROPIC_API_KEY` for `anthropic` and `claude`
125
+ - `GEMINI_API_KEY` for `gemini`
126
+ - `DEEPSEEK_API_KEY` for `deepseek`
127
+ - `BEDROCK_API_KEY`, `BEDROCK_SECRET_KEY`, `BEDROCK_REGION` for `bedrock`
128
+ - `BEDROCK_SESSION_TOKEN` (optional)
129
+
130
+ ### Model and request tuning
131
+
132
+ - `AIFAKER_MODEL` -> force a specific model id
133
+ - `AIFAKER_TIMEOUT` -> request timeout in seconds
134
+
135
+ Examples:
136
+
137
+ ```bash
138
+ export AIFAKER_PROVIDER=gemini
139
+ export GEMINI_API_KEY="your_key_here"
140
+ export AIFAKER_MODEL="models/gemini-1.5-flash"
141
+ export AIFAKER_TIMEOUT=120
142
+ ```
143
+
144
+ ```bash
145
+ export AIFAKER_PROVIDER=openai
146
+ export OPENAI_API_KEY="your_key_here"
147
+ export AIFAKER_MODEL="gpt-4.1-mini"
148
+ ```
149
+
150
+ ```bash
151
+ export AIFAKER_PROVIDER=claude
152
+ export ANTHROPIC_API_KEY="your_key_here"
153
+ # optional: choose a specific Claude model
154
+ export AIFAKER_MODEL="claude-3-5-sonnet-latest"
155
+ ```
156
+
157
+ ## Provider Notes
158
+
159
+ ### Gemini
160
+
161
+ - If a discovered model is unsupported for `generateContent` (for example `models/aqa`), AIFaker automatically tries other available provider models.
162
+ - You can still force a model via `AIFAKER_MODEL`.
163
+
164
+ ## How Seeding Works
165
+
166
+ During `client.seed!`, AIFaker:
167
+
168
+ 1. connects to LLM provider
169
+ 2. reads schema
170
+ 3. reads models + associations
171
+ 4. builds dependency-aware seed plan
172
+ 5. generates attributes and creates records
173
+ 6. auto-repairs common failures (including uniqueness retries)
174
+
175
+ When record creation fails, AIFaker shares failure context back to the LLM (error details + attempted attributes + uniqueness exclusions) to improve the next attempt.
176
+
177
+ ## Typical `db/seeds.rb` Templates
178
+
179
+ ### Template A: local development (interactive)
180
+
181
+ ```ruby
182
+ client = AIFaker.connect
183
+ client.seed!
184
+ ```
185
+
186
+ ### Template B: CI / scripted runs
187
+
188
+ ```ruby
189
+ client = AIFaker.connect
190
+ client.automode = true
191
+ client.seed!
192
+ ```
193
+
194
+ ### Template C: fixed provider + fixed model
195
+
196
+ ```ruby
197
+ client = AIFaker.connect("gemini")
198
+ client.automode = true
199
+ client.seed!
200
+ ```
201
+
202
+ Then:
203
+
204
+ ```bash
205
+ export GEMINI_API_KEY="your_key_here"
206
+ export AIFAKER_MODEL="models/gemini-1.5-flash"
207
+ rails db:seed
208
+ ```
209
+
210
+ ## Security
211
+
212
+ - Never hardcode API keys in `db/seeds.rb`.
213
+ - Prefer shell env vars, `.env`, or encrypted credentials.
214
+ - If a key is ever exposed in logs/chat/history, rotate it immediately.
215
+
216
+ ## Development
217
+
218
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
219
+
220
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
221
+
222
+ ## Contributing
223
+
224
+ Bug reports and pull requests are welcome on GitHub at [AIFaker](https://github.com/VaibhavDJain/AIFaker). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/VaibhavDJain/AIFaker/blob/master/CODE_OF_CONDUCT.md).
225
+
226
+ ## Author
227
+
228
+ - Name: Vaibhav Jain
229
+ - Email: [hiivaibhav1@gmail.com](mailto:hiivaibhav1@gmail.com)
230
+ - GitHub: [VaibhavDJain](https://github.com/VaibhavDJain)
231
+ - LinkedIn: [vaibhav-jain-6454971a4](https://linkedin.com/in/vaibhav-jain-6454971a4)
232
+ - Medium: [vaibhavdjain.medium.com](https://vaibhavdjain.medium.com/)
233
+ - Stack Overflow: [vaibhav-jain](https://stackoverflow.com/users/14558544/vaibhav-jain)
234
+
235
+ ## Contributors
236
+
237
+ - [Vaibhav Jain](https://github.com/VaibhavDJain)
238
+
239
+ ## License
240
+
241
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
242
+
243
+ ## Code of Conduct
244
+
245
+ Everyone interacting in the AIFaker project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/VaibhavDJain/AIFaker/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ task default: :test
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AIFaker
4
+ VERSION = "0.1.0"
5
+ end
data/lib/AIFaker.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "AIFaker/version"
4
+ require_relative "AIFaker/errors"
5
+ require_relative "AIFaker/client"
6
+
7
+ module AIFaker
8
+ # Connects to an LLM provider and returns a client object.
9
+ #
10
+ # @param provider [String, Symbol, nil] e.g. :openai, :gemini. Defaults to ENV or "openai".
11
+ # @param options [Hash] provider-specific options
12
+ # @return [AIFaker::Client]
13
+ def self.connect(provider = nil, **options)
14
+ Client.connect(provider, **options)
15
+ end
16
+
17
+ class << self
18
+ alias_method :client, :connect
19
+ end
20
+ end
data/sig/AIFaker.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module AIFaker
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: AIFaker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vaibhav Jain
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2026-03-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby_llm
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "<"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "<"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.0
27
+ description: Reads schema + associations and generates realistic seed data using an
28
+ LLM (via ruby_llm).
29
+ email:
30
+ - hiivaibhav1@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - CODE_OF_CONDUCT.md
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - lib/AIFaker.rb
40
+ - lib/AIFaker/version.rb
41
+ - sig/AIFaker.rbs
42
+ homepage: https://github.com/VaibhavDJain/AIFaker
43
+ licenses:
44
+ - MIT
45
+ metadata:
46
+ homepage_uri: https://github.com/VaibhavDJain/AIFaker
47
+ source_code_uri: https://github.com/VaibhavDJain/AIFaker
48
+ changelog_uri: https://github.com/VaibhavDJain/AIFaker
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 3.1.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubygems_version: 3.3.7
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: AI-powered, schema-aware Rails seeding
68
+ test_files: []