human_sql 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e45103fa9637558a0eadf18130856bf6d53c2c33225315c80e90906962a68fd2
4
- data.tar.gz: be46708a8723b7de39926eb7e8872d48466c70bd39700b1d36f7c1a01b1323a0
3
+ metadata.gz: 252749f91542523c968e6819c589754afd16ff53fe5dc2851ce55b82c67fc42a
4
+ data.tar.gz: eab62bcd1da26e6d3f89bd1d6859122b9524dd769a24978f7fe0277e60867a9d
5
5
  SHA512:
6
- metadata.gz: cd1cfee88517e5bb5613227f790a3396f6a4e05df8a28cb96a4fb85c4fb1606916995c72490f4af52e63bfda794c14c4430942499576c28390df62e25405a9fd
7
- data.tar.gz: a6782bb601f3437ec6cf7ccd6b11893b51861431501c5f4b003200ab29080a6094261a2f6bdb90edd6977722bb2a3bcec68180f1415a24a989795398c8d01f2c
6
+ metadata.gz: 1d8aeb7e0cb4247509445c9105c3885ff8395f576b35c136d0ee410f963110f9880b1f35e37bad6af32c633860486580908b8fab9c67ff9a0fab92f3e771bb08
7
+ data.tar.gz: eaabff247f028ec2553440ca0f52029a7bd6b32e080f3d2f4b12fcaf2de1c944858b1562488ae666a03bc459c2800cc304456eda7e0a951e792a6fe593c7131d
data/CODE_OF_CONDUCT.md CHANGED
@@ -60,8 +60,7 @@ representative at an online or offline event.
60
60
 
61
61
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
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.
63
+ [mail@nicobertin.dev]. All complaints will be reviewed and investigated promptly and fairly.
65
64
 
66
65
  All community leaders are obligated to respect the privacy and security of the
67
66
  reporter of any incident.
@@ -129,4 +128,4 @@ For answers to common questions about this code of conduct, see the FAQ at
129
128
  [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
129
  [Mozilla CoC]: https://github.com/mozilla/diversity
131
130
  [FAQ]: https://www.contributor-covenant.org/faq
132
- [translations]: https://www.contributor-covenant.org/translations
131
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt CHANGED
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,43 +1,72 @@
1
1
  # HumanSql
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/human_sql`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ `HumanSql` is a gem that converts natural language queries into ActiveRecord queries using the OpenAI API. This gem allows developers to execute complex database queries by simply providing instructions in plain English (or another supported language).
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
- Install the gem and add to the application's Gemfile by executing:
7
+ After releasing to RubyGems.org, you can install the gem and add it to your application's Gemfile by executing:
12
8
 
13
9
  ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
10
+ bundle add human_sql
15
11
  ```
16
12
 
17
- If bundler is not being used to manage dependencies, install the gem by executing:
13
+ If Bundler is not being used to manage dependencies, you can install the gem by executing:
18
14
 
19
15
  ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
16
+ gem install human_sql
17
+ ```
18
+
19
+ ### Post Installation
20
+ Once the gem is installed, you'll need to configure it by creating an initializer. In your Rails application, create a file named config/initializers/human_sql.rb and add the following:
21
+
22
+ ```ruby
23
+ HumanSQLConfig = {
24
+ api_key: 'your_openai_api_key', # Replace with your actual OpenAI API key
25
+ default_language: 'english' # You can change this to 'spanish', 'japanese', etc.
26
+ }
21
27
  ```
22
28
 
23
- ## Usage
29
+ Make sure to replace 'your_openai_api_key' with your actual API key from OpenAI. The default_language setting controls the language used for the natural language responses.
30
+
31
+ ### Usage
32
+
33
+ To use HumanSql in your application, simply call the run method on HumanSQL::QueryBuilder with a natural language query. For example:
34
+
35
+ ```ruby
36
+ result = HumanSQL::QueryBuilder.run("Give me the first user from my database")
37
+ puts result
38
+ ```
24
39
 
25
- TODO: Write usage instructions here
40
+ This will convert the natural language query into an ActiveRecord query, execute it, and return the results formatted in the specified language.
26
41
 
27
- ## Development
42
+ ### Disclaimer
28
43
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
44
+ IMPORTANT: By using this gem, you agree that the author is not responsible for any kind of data loss, damage, or issues that may arise from the use of this software. You are solely responsible for verifying the safety of the generated queries before running them in your production environment or on critical data. Use at your own risk.
30
45
 
31
- 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).
46
+ ### Development
32
47
 
33
- ## Contributing
48
+ After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.
49
+
50
+ To install this gem onto your local machine, run:
51
+
52
+ ```bash
53
+ bundle
54
+ ```
55
+
56
+ To release a new version, update the version number in version.rb, and then run:
57
+
58
+ ```bash
59
+ bundle exec rake release
60
+ ```
34
61
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/human_sql. 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/[USERNAME]/human_sql/blob/main/CODE_OF_CONDUCT.md).
62
+ This will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
36
63
 
37
- ## License
64
+ ### Contributing
38
65
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nicobertin/human_sql. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
40
67
 
41
- ## Code of Conduct
68
+ ### License
69
+ The gem is available as open source under the terms of the MIT License.
42
70
 
43
- Everyone interacting in the HumanSql project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/human_sql/blob/main/CODE_OF_CONDUCT.md).
71
+ ### Code of Conduct
72
+ Everyone interacting in the HumanSql project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the code of conduct.
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HumanSql
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/human_sql.rb CHANGED
@@ -134,7 +134,7 @@ module HumanSQL
134
134
 
135
135
  "#{error_message}"
136
136
 
137
- Please generate a natural language response that explains the error in a way that is understandable to the user.
137
+ Please generate a natural language response that explains the error in a way that is understandable to the user in #{HumanSQLConfig[:default_language]}.
138
138
  PROMPT
139
139
 
140
140
  call_openai_service(prompt)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: human_sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Bertin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-08 00:00:00.000000000 Z
11
+ date: 2024-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,7 @@ files:
52
52
  - LICENSE.txt
53
53
  - README.md
54
54
  - Rakefile
55
+ - human_sql-0.1.1.gem
55
56
  - lib/human_sql.rb
56
57
  - lib/human_sql/version.rb
57
58
  - sig/human_sql.rbs