openai_pipe 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bfeb3903a2ddaf5a0639611b797662f1f04a4884792d60b81b65a590660b84e3
4
+ data.tar.gz: c62e6fc90a1e5fcab6059e95abec5cd0bffa72c162c064147cc2f21aa6d49345
5
+ SHA512:
6
+ metadata.gz: 6d93cf540037b54b3038ccae81f0cd6947b00895e562144aa1e55caff17f15226331a1aed1816821b704d161d3f2dd011fbaf86dd166bb986dd0a9a700eff56e
7
+ data.tar.gz: aa29f3738ebfc161d11283f79b2c0c1840a245edbebdfb8d120a35e9fa4376777ff603d540c4d3639e387ba3ba26de85cc8327ad1f68f2b51867733d4b721673
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 2.6
4
+
5
+ Style/StringLiterals:
6
+ Enabled: true
7
+ EnforcedStyle: double_quotes
8
+
9
+ Style/StringLiteralsInInterpolation:
10
+ Enabled: true
11
+ EnforcedStyle: double_quotes
12
+
13
+ Layout/LineLength:
14
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-12-23
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in openai_pipe.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ openai_pipe (0.1.0)
5
+ quick_openai (~> 0.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.8.1)
11
+ public_suffix (>= 2.0.2, < 6.0)
12
+ ast (2.4.2)
13
+ diff-lcs (1.5.0)
14
+ dotenv (2.8.1)
15
+ down (5.3.1)
16
+ addressable (~> 2.8)
17
+ httparty (0.20.0)
18
+ mime-types (~> 3.0)
19
+ multi_xml (>= 0.5.2)
20
+ json (2.6.3)
21
+ mime-types (3.4.1)
22
+ mime-types-data (~> 3.2015)
23
+ mime-types-data (3.2022.0105)
24
+ multi_xml (0.6.0)
25
+ parallel (1.22.1)
26
+ parser (3.1.3.0)
27
+ ast (~> 2.4.1)
28
+ public_suffix (5.0.1)
29
+ quick_openai (0.1.0)
30
+ down (~> 5)
31
+ ruby-openai (~> 2)
32
+ rainbow (3.1.1)
33
+ rake (13.0.6)
34
+ regexp_parser (2.6.1)
35
+ rexml (3.2.5)
36
+ rspec (3.12.0)
37
+ rspec-core (~> 3.12.0)
38
+ rspec-expectations (~> 3.12.0)
39
+ rspec-mocks (~> 3.12.0)
40
+ rspec-core (3.12.0)
41
+ rspec-support (~> 3.12.0)
42
+ rspec-expectations (3.12.1)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.12.0)
45
+ rspec-mocks (3.12.1)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.12.0)
48
+ rspec-support (3.12.0)
49
+ rubocop (1.41.1)
50
+ json (~> 2.3)
51
+ parallel (~> 1.10)
52
+ parser (>= 3.1.2.1)
53
+ rainbow (>= 2.2.2, < 4.0)
54
+ regexp_parser (>= 1.8, < 3.0)
55
+ rexml (>= 3.2.5, < 4.0)
56
+ rubocop-ast (>= 1.23.0, < 2.0)
57
+ ruby-progressbar (~> 1.7)
58
+ unicode-display_width (>= 1.4.0, < 3.0)
59
+ rubocop-ast (1.24.0)
60
+ parser (>= 3.1.1.0)
61
+ ruby-openai (2.2.0)
62
+ dotenv (>= 2.7.6, < 2.9.0)
63
+ httparty (>= 0.18.1, < 0.21.0)
64
+ ruby-progressbar (1.11.0)
65
+ unicode-display_width (2.3.0)
66
+
67
+ PLATFORMS
68
+ x86_64-linux
69
+
70
+ DEPENDENCIES
71
+ openai_pipe!
72
+ rake (~> 13.0)
73
+ rspec (~> 3.0)
74
+ rubocop (~> 1.21)
75
+
76
+ BUNDLED WITH
77
+ 2.3.12
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 John DeSilva
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,181 @@
1
+ # OpenAIPipe
2
+
3
+ This library provides a UNIX-ey interface to OpenAI.
4
+ See [Installation](#installation) and [Setup](#setup) below, but first, some examples.
5
+
6
+ ## Examples
7
+
8
+ ```console
9
+ $ ai what is two plus two
10
+ Two plus two is equal to four.
11
+ ```
12
+
13
+ ```console
14
+ $ uptime | ai convert this to json
15
+ {
16
+ "time_of_measurement": "13:48:26",
17
+ "up_time": "30 days, 18:07",
18
+ "users": 3,
19
+ "load_average": [
20
+ 0.46,
21
+ 0.61,
22
+ 0.79
23
+ ]
24
+ }
25
+ ```
26
+
27
+ ```console
28
+ $ ai list the nine planets as JSON | ai convert this to XML but in French | tee planets.fr.xml
29
+ <Planètes>
30
+ <Planète>Mercure</Planète>
31
+ <Planète>Vénus</Planète>
32
+ <Planète>La Terre</Planète>
33
+ <Planète>Mars</Planète>
34
+ <Planète>Jupiter</Planète>
35
+ <Planète>Saturne</Planète>
36
+ <Planète>Uranus</Planète>
37
+ <Planète>Neptune</Planète>
38
+ <Planète>Pluton</Planète>
39
+ </Planètes>
40
+ ```
41
+
42
+ ```console
43
+ $ curl -sL "https://en.wikipedia.org/wiki/cats" | head -n 5 | ai extract just the title of this webpage | figlet
44
+ ____ _ __ ___ _ _ _ _
45
+ / ___|__ _| |_ \ \ / (_) | _(_)_ __ ___ __| (_) __ _
46
+ | | / _` | __| _____ \ \ /\ / /| | |/ / | '_ \ / _ \/ _` | |/ _` |
47
+ | |__| (_| | |_ |_____| \ V V / | | <| | |_) | __/ (_| | | (_| |
48
+ \____\__,_|\__| \_/\_/ |_|_|\_\_| .__/ \___|\__,_|_|\__,_|
49
+ |_|
50
+ ```
51
+
52
+ ```console
53
+ $ ls | ai What is this directory for?
54
+ This directory contains the source code for a Ruby-based project called openai_pipe. It includes files related to the project's license (LICENSE.txt), changelog (CHANGELOG.md), dependencies (Gemfile and Gemfile.lock), executables (bin and exe), libraries (lib), signature (sig) and tests (spec). There is also a Rakefile and a README.md file which provide information about how to build and install the project, as well as its features and usage. Finally, it includes the openai_pipe-0.1.0.gem and openai_pipe.gemspec files which are used to build the gem which can be installed on other systems.
55
+ ```
56
+
57
+ ```console
58
+ $ ls -l | ai which of these are directories?
59
+ bin, exe, lib, sig, spec
60
+ ```
61
+
62
+ ```console
63
+ $ ls | ai "For each of these files, provide a description of what is likely to be their contents?"
64
+ bin - Likely contains compiled binary executable files.
65
+ CHANGELOG.md - Likely contains a log of changes/modifications, such as bug fixes and new features, that have been made to the project.
66
+ exe - Likely contains executable files.
67
+ french_planets.xml - Likely contains an XML file containing data related to planets, likely in French.
68
+ Gemfile - Likely contains Ruby code for the project's dependencies.
69
+ Gemfile.lock - Likely contains a snapshot of the dependencies of the project and versions of those dependencies.
70
+ lib - Likely contains the Ruby source code (e.g. classes and modules) for the project.
71
+ LICENSE.txt - Likely contains the terms of use/license for the project.
72
+ openai_pipe-0.1.0.gem - Likely contains a gem that gathers information from the OpenAI API.
73
+ openai_pipe.gemspec - Likely contains configuration details for the gem.
74
+ planets.lst - Likely contains a list of planets.
75
+ poem.txt - Likely contains a text file containing a poem.
76
+ Rakefile - Likely contains Ruby tasks and dependencies that can be used in projects.
77
+ README.md - Likely contains general information about the project and usage instructions.
78
+ reverse.lst - Likely contains a list of words or items that are in reverse order.
79
+ sig - Likely contains digital signatures to validate individual files.
80
+ spec - Likely contains Ruby specs (i.e. tests) for the project.
81
+ uptime.json - Likely contains a file with information regarding system uptime of a computer.
82
+ ```
83
+
84
+ ```console
85
+ $ git commit -m "$(git status | ai write me a commit message for these changes)"
86
+ [master 7d0271f] Add new files and modify README.md
87
+ ```
88
+
89
+ ```console
90
+ $ git status | tee /dev/tty | ai write me a sonnet about the status of this git repository
91
+ On branch master
92
+ Untracked files:
93
+ (use "git add <file>..." to include in what will be committed)
94
+ openai_pipe-0.1.0.gem
95
+
96
+ nothing added to commit but untracked files present (use "git add" to track)
97
+
98
+ My master branch may lack to thee its kin
99
+ For change it holds the only force within
100
+ Thé untracked files, they still remain unnamed
101
+ ‘Tis fervent hope thé change will soon be claimed
102
+
103
+ Fraught with the choice to leave or to persist
104
+ The repository wavers ‘tween future and past
105
+ The openai_pipe-0.1.0 gem stands out
106
+ Waiting to be added, not yet about
107
+
108
+ The commit awaits for brave new changes bold
109
+ While time’s old force is ever unfurled
110
+ Commit forth young mind, furrow not to crawl
111
+ From untracked files, a future stands tall.
112
+ ```
113
+
114
+ ```console
115
+ % history | ai what was the last thing I did
116
+ The last command you entered was 'history'.
117
+ ```
118
+ n.b. somehow it sees history-esque output and determines that history was typed -- the history command does not itself include the history command in the output.
119
+
120
+ ```console
121
+ $ history | ai what was the last thing I did before typing history
122
+ The last thing you did was amend a README.md file.
123
+ ```
124
+ n.b. here it determines the amend was for README.md not from the previous command but from ones prior that edited README.md.
125
+
126
+ ```console
127
+ $ cat lib/openai_pipe/version.rb | ai rewrite this file with just the minor version incremented | sponge > lib/openai_pipe/version.rb
128
+ $ git diff
129
+ diff --git a/lib/openai_pipe/version.rb b/lib/openai_pipe/version.rb
130
+ index 0f82357..cc57fab 100644
131
+ --- a/lib/openai_pipe/version.rb
132
+ +++ b/lib/openai_pipe/version.rb
133
+ @@ -1,5 +1,5 @@
134
+ # frozen_string_literal: true
135
+
136
+ module OpenAIPipe
137
+ - VERSION = "0.1.0"
138
+ + VERSION = "0.1.1"
139
+ end
140
+ ```
141
+
142
+ ```console
143
+ $ ruby -e "$(ai write me a python script that prints the current month | ai translate this into ruby)" | ai translate this into French
144
+ Le mois courant est Décembre.
145
+ ```
146
+
147
+ ## Installation
148
+
149
+ Install the gem by executing:
150
+
151
+ $ gem install openai_pipe
152
+
153
+ ## Setup
154
+
155
+ By default the executable is called `openai_pipe`. It is reccommended to alias this command to something shorter in .bashrc or equivalent, e.g.
156
+ ```bash
157
+ alias ai="openai_pipe"
158
+ ```
159
+
160
+ You will also need to have your OpenAI access token in ENV, so also in .bashrc or equivalent,
161
+ ```bash
162
+ export OPENAI_ACCESS_TOKEN=mytoken
163
+ ```
164
+
165
+ ## Notes
166
+
167
+ Be aware that there is a cost associated every time GPT3 is invoked, so be mindful of your account usage. Also be wary of sending sensitive data to OpenAI, and also wary of arbitrarily executing scripts or programs that GPT3 generates.
168
+
169
+ ## Development
170
+
171
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
172
+
173
+ 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).
174
+
175
+ ## Contributing
176
+
177
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Aesthetikx/openai_pipe.
178
+
179
+ ## License
180
+
181
+ 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,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/exe/openai_pipe ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "openai_pipe"
4
+
5
+ OpenAIPipe.exe
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenAIPipe
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "openai_pipe/version"
4
+
5
+ require "quick_openai"
6
+
7
+ module OpenAIPipe
8
+ class Error < StandardError; end
9
+
10
+ def self.exe
11
+ input_from_pipe = $stdin.read if $stdin.stat.pipe?
12
+
13
+ input_from_arguments = ARGV.join(" ") if ARGV.any?
14
+
15
+ prompt = [input_from_arguments, input_from_pipe].compact.join("\n\n")
16
+
17
+ puts prompt.gpt3
18
+ rescue QuickOpenAI::Error => e
19
+ warn e.message
20
+ exit 1
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ module OpenaiPipe
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openai_pipe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - John DeSilva
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-12-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: quick_openai
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ description: Provides pipe and redirect functionality to quick_openai
28
+ email:
29
+ - desilvjo@umich.edu
30
+ executables:
31
+ - openai_pipe
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".rspec"
36
+ - ".rubocop.yml"
37
+ - CHANGELOG.md
38
+ - Gemfile
39
+ - Gemfile.lock
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - exe/openai_pipe
44
+ - lib/openai_pipe.rb
45
+ - lib/openai_pipe/version.rb
46
+ - sig/openai_pipe.rbs
47
+ homepage: https://www.github.com/Aesthetikx/openai_pipe
48
+ licenses:
49
+ - MIT
50
+ metadata:
51
+ homepage_uri: https://www.github.com/Aesthetikx/openai_pipe
52
+ source_code_uri: https://www.github.com/Aesthetikx/openai_pipe
53
+ changelog_uri: https://www.github.com/Aesthetikx/openai_pipe/blob/master/CHANGELOG.md
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.6.0
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.3.7
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: A UNIX-ey interface to OpenAI
73
+ test_files: []