openai-please 0.1.3 → 0.2.0

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: de7075efdfbec978dc13fa6621f80e9e146e81cffb9652b19c17577befb4258a
4
- data.tar.gz: 22fcdec50244d7d02826e25a3f4fb7a5e542f151da749ab67d7d9a3de0e7d7cb
3
+ metadata.gz: f57df851a98cb38c098cae4762fb1174ceb8a43e6bae36104c1dcc479fbcedb9
4
+ data.tar.gz: 23e3002663ae954bfd109500a7bedde579a5f28add34fb94abfdf114a48dbe92
5
5
  SHA512:
6
- metadata.gz: 7aa0a478868627ba84898ca812958f5c37a46bd0872fe4ddbba4d1c222d2700f0d887b0e7ba207683e3a4620e9a73c63e61d73f77e6bf76f8b422a9f54a2bbf6
7
- data.tar.gz: 978bcfb2597c5b2f7c1157cedd755b6a058395c9d844472649524ddc9531d5f9a4fde7e6f7af5dd237ed4801274f3274d14753cfd6c25e65387ff16b38ee2250
6
+ metadata.gz: fa0e870e7d6ef5cb147ea92b96ecaf6b5dae6c4c138732dfcca90a2af5646be62fdc1aa59931aa19c5d1f4197616116d223f218e4bd4df190a4bd41f5e30cb44
7
+ data.tar.gz: 32b6ebf0c3fa2f5228dfd2a97ff019e01984d59f92e27d1f50fafbaab53b841c00be4b4678d1caf87983a8b00a3770d4488a7746aecf3eeeac92936680c71a8e
data/Gemfile.lock CHANGED
@@ -1,21 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openai-please (0.1.2)
5
- ruby-openai (>= 1.3)
6
- tty-prompt (>= 0.23)
4
+ openai-please (0.2.0)
5
+ ruby-openai (~> 3.0)
6
+ tty-prompt (~> 0.23)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  ast (2.4.2)
12
- dotenv (2.7.6)
13
- httparty (0.18.1)
14
- mime-types (~> 3.0)
12
+ httparty (0.21.0)
13
+ mini_mime (>= 1.0.0)
15
14
  multi_xml (>= 0.5.2)
16
- mime-types (3.3.1)
17
- mime-types-data (~> 3.2015)
18
- mime-types-data (3.2021.0901)
15
+ mini_mime (1.1.2)
19
16
  minitest (5.14.4)
20
17
  multi_xml (0.6.0)
21
18
  parallel (1.21.0)
@@ -38,9 +35,8 @@ GEM
38
35
  unicode-display_width (>= 1.4.0, < 3.0)
39
36
  rubocop-ast (1.11.0)
40
37
  parser (>= 3.0.1.1)
41
- ruby-openai (1.3.1)
42
- dotenv (~> 2.7.6)
43
- httparty (~> 0.18.1)
38
+ ruby-openai (3.0.3)
39
+ httparty (>= 0.18.1, < 0.22.0)
44
40
  ruby-progressbar (1.11.0)
45
41
  tty-color (0.6.0)
46
42
  tty-cursor (0.7.1)
@@ -65,4 +61,4 @@ DEPENDENCIES
65
61
  rubocop (~> 1.7)
66
62
 
67
63
  BUNDLED WITH
68
- 2.2.22
64
+ 2.4.3
data/README.md CHANGED
@@ -10,7 +10,7 @@ Convert natural language to bash commands using OpenAI Codex
10
10
 
11
11
  $ gem install openai-please
12
12
 
13
- Ensure your [OpenAI API key](https://help.openai.com/en/articles/5480100-how-do-i-gain-access-to-openai-codex) is stored in an environment variable.
13
+ Provide your [OpenAI API key](https://help.openai.com/en/articles/5480100-how-do-i-gain-access-to-openai-codex) in an environment variable, or using the [configuration file](#configuration).
14
14
 
15
15
  ```
16
16
  OPENAI_ACCESS_TOKEN=[YOUR ACCESS TOKEN HERE]
@@ -18,20 +18,66 @@ OPENAI_ACCESS_TOKEN=[YOUR ACCESS TOKEN HERE]
18
18
 
19
19
  ## Usage
20
20
 
21
+ Type `please`, followed by an instruction written in natural language.
22
+
21
23
  ```shell
22
24
  user@host:~$ please find all files larger than 1 mb
23
25
  $ find . -type f -size +1M
24
26
  Run the command? (enter "h" for help) [y,n,e,h]
25
27
  ```
26
28
 
27
- You can [e]dit the command before running it by pressing the 'e' key. This uses the editor specified in the $EDITOR variable, defaulting to vi.
29
+ You can [e]dit the command before running it by pressing the 'e' key. This uses the command specified in the `$EDITOR` variable, or `vi` if no editor is set.
30
+
31
+ See `please --help` for more information.
32
+
33
+ ## Configuration
34
+
35
+ You can modify the default configuration in `~/.config/please/config.yml`.
36
+
37
+ ```yaml
38
+ send_pwd: false # default: true
39
+ send_ls: false # default: true
40
+ send_uname: true # default: true
41
+
42
+ access_token: ... # default: $OPENAI_ACCESS_TOKEN
43
+
44
+ examples: # default: []
45
+ - instruction: Run my super secret command
46
+ command: /super/secret/command
47
+
48
+ - instruction: Show git status
49
+ command: git status
50
+ execute: true # default: false
51
+
52
+ skip_default_examples: true # default: false
53
+ ```
54
+
55
+ ### `examples`
56
+
57
+ Any examples listed here will be added to the prompt in the following form.
58
+
59
+ ```
60
+ # INSTRUCTION
61
+ $ COMMAND
62
+ [RESULT, if execute is set to true]
63
+ ```
64
+
65
+ If `execute` is set to true, the command will be executed prior to sending the request and the result will be included in the prompt. This is useful for providing dynamic context which the AI can use to inform completions.
66
+
67
+ ### `skip_default_examples`
68
+
69
+ Do not include the default set of examples in the prompt. You can see the full prompt by running `please --show-prompt`.
70
+
71
+ *Note:* This option does not automatically imply `send_*: false`. To remove all examples from the prompt other than those explicitly specified, use this option in combination with the `send_*: false` options.
28
72
 
29
73
  ## Privacy
30
74
 
31
- In addition to the instruction text, the result of each of the following commands is sent to OpenAI Codex to improve the relevance of completions.
75
+ By default, the result of each of the following commands is sent to OpenAI Codex to improve the relevance of completions.
32
76
 
33
77
  - `pwd`
34
78
  - `uname -a`
35
79
  - `ls -a`
36
80
 
81
+ This behaviour can be disabled using the configuration options described above. You can review the prompt before sending it to OpenAI by running `please --show-prompt`.
82
+
37
83
  See [OpenAI's privacy policy](https://beta.openai.com/policies/privacy-policy) for more information.
@@ -9,10 +9,7 @@ module Please
9
9
  client = ::OpenAI::Client.new(access_token: access_token)
10
10
 
11
11
  response = client.completions(
12
- engine: 'davinci-codex',
13
- parameters: default_parameters.merge(
14
- prompt: prompt,
15
- ),
12
+ parameters: default_parameters.merge(prompt: prompt),
16
13
  )
17
14
 
18
15
  response.parsed_response.fetch('choices').first.fetch('text')
@@ -22,6 +19,7 @@ module Please
22
19
 
23
20
  def default_parameters
24
21
  {
22
+ model: 'code-davinci-002',
25
23
  temperature: 0,
26
24
  max_tokens: 512,
27
25
  top_p: 1,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Please
4
- VERSION = '0.1.3'
4
+ VERSION = '0.2.0'
5
5
  end
data/please.gemspec CHANGED
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ['lib']
27
27
 
28
28
  # Uncomment to register a new dependency of your gem
29
- spec.add_dependency 'ruby-openai', '>= 1.3'
30
- spec.add_dependency 'tty-prompt', '>= 0.23'
29
+ spec.add_dependency 'ruby-openai', '~> 3.0'
30
+ spec.add_dependency 'tty-prompt', '~> 0.23'
31
31
 
32
32
  # For more information and examples about making a new gem, checkout our
33
33
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openai-please
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Anderson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-16 00:00:00.000000000 Z
11
+ date: 2023-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tty-prompt
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.23'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.23'
41
41
  description:
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements: []
90
- rubygems_version: 3.2.22
90
+ rubygems_version: 3.4.1
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Convert natural language to bash commands using OpenAI Codex