human_sql 0.1.1 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +2 -3
- data/LICENSE.txt +1 -1
- data/README.md +49 -20
- data/human_sql-0.1.1.gem +0 -0
- data/human_sql-0.1.2.gem +0 -0
- data/human_sql-0.1.3.gem +0 -0
- data/lib/human_sql/version.rb +1 -1
- data/lib/human_sql.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2105327e3f06a71f6a2e87920bd571bd82e6c2d7c891a9bf939f685a9796a2dc
|
4
|
+
data.tar.gz: 5012bb480c854b5b86a891130dd73ac938e7cf1138428a6918d76193836f8d9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e39cece766a98e64e0f6bf59a2124348e15a6e970fbee4d25c6184a74508b839445cf9d00012d081240b6dfff4336ff19b12b1ac27c0a587ab212cdba57adbee
|
7
|
+
data.tar.gz: 66b6ee8fb138967521063913ab8891f36b1950f01ce4dd733555d7cc58da40a3b6f72a1cf843b38a85546cd8f53b13625d2a6cef96d608f9292cc0356d691a28
|
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
|
-
[
|
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
|
-
|
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
|
-
|
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
|
10
|
+
bundle add human_sql
|
15
11
|
```
|
16
12
|
|
17
|
-
If
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
42
|
+
### Disclaimer
|
28
43
|
|
29
|
-
|
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
|
-
|
46
|
+
### Development
|
32
47
|
|
33
|
-
|
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
|
-
|
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
|
-
|
64
|
+
### Contributing
|
38
65
|
|
39
|
-
|
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
|
-
|
68
|
+
### License
|
69
|
+
The gem is available as open source under the terms of the MIT License.
|
42
70
|
|
43
|
-
|
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.
|
data/human_sql-0.1.1.gem
ADDED
Binary file
|
data/human_sql-0.1.2.gem
ADDED
Binary file
|
data/human_sql-0.1.3.gem
ADDED
Binary file
|
data/lib/human_sql/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.4
|
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-
|
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,9 @@ files:
|
|
52
52
|
- LICENSE.txt
|
53
53
|
- README.md
|
54
54
|
- Rakefile
|
55
|
+
- human_sql-0.1.1.gem
|
56
|
+
- human_sql-0.1.2.gem
|
57
|
+
- human_sql-0.1.3.gem
|
55
58
|
- lib/human_sql.rb
|
56
59
|
- lib/human_sql/version.rb
|
57
60
|
- sig/human_sql.rbs
|