n2b 0.1.3 → 0.1.5

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: a202dae3ba4645542ae044ca8c2e924c34673907ecbcc4bd123ac054fb1493eb
4
- data.tar.gz: b308ead565a4ce70433f52551370246d2c4f1043e76d314f0ba5d4f7224f7a92
3
+ metadata.gz: d58cae30259d2c0399fe26b0170d1c59eb9e9ed89ba3831668e6931571d4407e
4
+ data.tar.gz: f8f05b3fa22da7257ba7bbca704537d21f4e7ec80f7304225935e32cd1596d50
5
5
  SHA512:
6
- metadata.gz: 9bcb6e988ca781399ff84c8189aa37c4ddface4cc6dc5474b9f22793b10b5de10c82bba7c8d2475bf0f0a030ea4c638fb4136ec2b5d98871a84affb60a5a5ab7
7
- data.tar.gz: 598a4d9a0a684a8d95bbb644d2ba799b32e617868be56cc4e5d661d4ee6646cd42389c0315a60175546faadcdb0c4fde1742ca9270e3b9a9500d3f77c933d935
6
+ metadata.gz: c2a96d2da2390481dea2cf5044d64164e58d4a168e5f5367df4162ebfa8867c01c078af42c186bfad8518546b602cce65029b07c7251534530847beeed0febef
7
+ data.tar.gz: 4eb2e07f2021e19e3beea4dcff79c3e226eb03198ba574a54f62e13df248a625bcd51764e23b0aa956e11215d726705be2bc877defb9d302eb5cde6452f4b82d
@@ -38,7 +38,7 @@ module N2M
38
38
  answer = JSON.parse(response.body)['content'].first['text']
39
39
  begin
40
40
  # removee everything before the first { and after the last }
41
- answer = answer.sub(/.*\{(.*)\}.*/m, '{\1}')
41
+ answer = answer.sub(/.*\{(.*)\}.*/m, '{\1}') unless answer.start_with?('{')
42
42
  answer = JSON.parse(answer)
43
43
  rescue JSON::ParserError
44
44
  answer = { 'commands' => answer.split("\n"), explanation: answer}
@@ -37,11 +37,10 @@ module N2M
37
37
  puts response.body
38
38
  exit 1
39
39
  end
40
- puts JSON.parse(response.body)
41
40
  answer = JSON.parse(response.body)['choices'].first['message']['content']
42
41
  begin
43
42
  # remove everything before the first { and after the last }
44
- answer = answer.sub(/.*\{(.*)\}.*/m, '{\1}')
43
+ answer = answer.sub(/.*\{(.*)\}.*/m, '{\1}') unless answer.start_with?('{')
45
44
  answer = JSON.parse(answer)
46
45
  rescue JSON::ParserError
47
46
  answer = { 'commands' => answer.split("\n"), explanation: answer }
data/lib/n2b/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # lib/n2b/version.rb
2
2
  module N2B
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.5"
4
4
  end
data/lib/n2b.rb CHANGED
@@ -137,7 +137,7 @@ module N2B
137
137
  { "commands": [ "echo 'Hello, World!'" ], "explanation": "This command prints 'Hello, World!' to the terminal."}
138
138
  EOF
139
139
 
140
-
140
+
141
141
  answer = llm.make_request(content)
142
142
 
143
143
  append_to_llm_history_file("#{prompt}\n#{answer}")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: n2b
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Nothegger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-10 00:00:00.000000000 Z
11
+ date: 2024-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '13.0'
55
55
  description: A tool to convert natural language instructions to bash commands using
56
- Claude API
56
+ Claude API or OpenAI's GPT.
57
57
  email:
58
58
  - stefan@kaproblem.com
59
59
  executables: