gpt4all 0.0.3 → 0.0.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: 677356f50a80a8d91eb4e0e2146ac4f005896ba1e1250ace66dd57e862444623
4
- data.tar.gz: fdb9dcf280aa544f8b7e26c4a9da143ce2ea3bfae4a7a20f995db6258b921c31
3
+ metadata.gz: 63ef21af70c63628f51e23eeee9a4958227a5789c43323c792676eef52289300
4
+ data.tar.gz: 19271183c40dffbae53dc3e171510ed787edbebdbb33ae432c92f9b0edcc0972
5
5
  SHA512:
6
- metadata.gz: cf7831d84c641dad48a6c8e6db0889af99a16cea58064f33fe7a6cf2bc331504ab1293d3c8636cdeb84685fbab7183d91bdb06c5b9ed1b7c681aa251e77dd4c3
7
- data.tar.gz: 27e532c867292cd131fa061d611497540984ab3ba69c633327b51709b04db33b440a8d834c2694c9a2ed01a0b098ab990260f3edeab59ad46a46599b15223749
6
+ metadata.gz: 8c929aa6408d5f6668ee0c6513968e64e0ee2e7ec4f71f87a5fe24de916a98300904a68837d2b8aaf2970754dfdd3a21f241e98ebde3225af31a64c93044d1a5
7
+ data.tar.gz: 2ef1a65e439ea312d01b7bb0445a1a0aed89981b0b7a6546ab3914f6bc8294cad196cb1d47f7036e4cfb32d6e8bde27a3067862e7eb941c3884b3e905a80fc52
data/CHANGELOG.md CHANGED
@@ -4,12 +4,15 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [Unreleased]
8
7
 
9
- ## [0.0.1] - 2023-04-07
8
+ ## [0.0.5] - 2023-04-18
10
9
 
11
- - Initial release
10
+ - [Fix error "private method gets called on Process::Waiter"]() by [Francis](https://github.com/francis)
11
+ - Fix write_chunks_to_file
12
+
13
+ ## [0.0.4] - 2023-04-11
14
+
15
+ - check md5 when downloading model file
16
+ - CI is working for multiple ruby version
12
17
 
13
- ## [0.0.2] - 2023-04-07
14
18
 
15
- - updated changelog link
data/Gemfile CHANGED
@@ -14,9 +14,9 @@ gem 'rubocop', '~> 1.21'
14
14
  gem 'brakeman'
15
15
  gem 'bundler-audit'
16
16
  gem 'byebug'
17
+ gem 'debug'
17
18
  gem 'dotenv'
18
- gem 'license_finder'
19
- gem 'overcommit'
19
+
20
20
  gem 'rubocop-performance'
21
21
  gem 'rubocop-sequel'
22
22
  gem 'rubocop-shopify'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gpt4all (0.0.3)
4
+ gpt4all (0.0.5)
5
5
  faraday (~> 2.7)
6
6
  os (~> 1.1)
7
7
  tty-progressbar (~> 0.18.2)
@@ -17,9 +17,11 @@ GEM
17
17
  bundler (>= 1.2.0, < 3)
18
18
  thor (~> 1.0)
19
19
  byebug (11.1.3)
20
- childprocess (4.1.0)
21
20
  crack (0.4.5)
22
21
  rexml
22
+ debug (1.7.2)
23
+ irb (>= 1.5.0)
24
+ reline (>= 0.3.1)
23
25
  diff-lcs (1.5.0)
24
26
  dotenv (2.8.1)
25
27
  faraday (2.7.4)
@@ -27,20 +29,11 @@ GEM
27
29
  ruby2_keywords (>= 0.0.4)
28
30
  faraday-net_http (3.0.2)
29
31
  hashdiff (1.0.1)
30
- iniparse (1.5.0)
32
+ io-console (0.6.0)
33
+ irb (1.6.4)
34
+ reline (>= 0.3.0)
31
35
  json (2.6.3)
32
- license_finder (7.1.0)
33
- bundler
34
- rubyzip (>= 1, < 3)
35
- thor (~> 1.2)
36
- tomlrb (>= 1.3, < 2.1)
37
- with_env (= 1.1.0)
38
- xml-simple (~> 1.1.9)
39
36
  os (1.1.4)
40
- overcommit (0.60.0)
41
- childprocess (>= 0.6.3, < 5)
42
- iniparse (~> 1.4)
43
- rexml (~> 3.2)
44
37
  parallel (1.22.1)
45
38
  parser (3.2.2.0)
46
39
  ast (~> 2.4.1)
@@ -48,6 +41,8 @@ GEM
48
41
  rainbow (3.1.1)
49
42
  rake (13.0.6)
50
43
  regexp_parser (2.7.0)
44
+ reline (0.3.3)
45
+ io-console (~> 0.5)
51
46
  rexml (3.2.5)
52
47
  rspec (3.12.0)
53
48
  rspec-core (~> 3.12.0)
@@ -83,10 +78,8 @@ GEM
83
78
  rubocop (~> 1.44)
84
79
  ruby-progressbar (1.13.0)
85
80
  ruby2_keywords (0.0.5)
86
- rubyzip (2.3.2)
87
81
  strings-ansi (0.2.0)
88
82
  thor (1.2.1)
89
- tomlrb (2.0.3)
90
83
  tty-cursor (0.7.1)
91
84
  tty-progressbar (0.18.2)
92
85
  strings-ansi (~> 0.2)
@@ -99,15 +92,13 @@ GEM
99
92
  addressable (>= 2.8.0)
100
93
  crack (>= 0.3.2)
101
94
  hashdiff (>= 0.4.0, < 2.0.0)
102
- with_env (1.1.0)
103
- xml-simple (1.1.9)
104
- rexml
105
95
 
106
96
  PLATFORMS
107
97
  aarch64-linux
108
98
  aarch64-linux-musl
109
99
  arm64-darwin-21
110
100
  arm64-darwin-22
101
+ x86_64-darwin-21
111
102
  x86_64-linux
112
103
  x86_64-linux-musl
113
104
 
@@ -115,10 +106,9 @@ DEPENDENCIES
115
106
  brakeman
116
107
  bundler-audit
117
108
  byebug
109
+ debug
118
110
  dotenv
119
111
  gpt4all!
120
- license_finder
121
- overcommit
122
112
  rake (~> 13.0)
123
113
  rspec (~> 3.0)
124
114
  rubocop (~> 1.21)
@@ -128,4 +118,4 @@ DEPENDENCIES
128
118
  webmock
129
119
 
130
120
  BUNDLED WITH
131
- 2.4.10
121
+ 2.4.7
@@ -9,8 +9,9 @@ require 'tty-progressbar'
9
9
  module Gpt4all
10
10
  # rubocop:disable Metrics/ClassLength
11
11
  class ConversationalAI
12
- attr_accessor :bot, :model, :decoder_config, :executable_path, :model_path, :force_download, :test_mode
12
+ attr_accessor :model, :decoder_config, :executable_path, :model_path, :force_download, :test_mode
13
13
 
14
+ # https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized.bin
14
15
  OSX_INTEL_URL = 'https://github.com/nomic-ai/gpt4all/blob/main/chat/gpt4all-lora-quantized-OSX-intel?raw=true'
15
16
  OSX_M1_URL = 'https://github.com/nomic-ai/gpt4all/blob/main/chat/gpt4all-lora-quantized-OSX-m1?raw=true'
16
17
  LINUX_URL = 'https://github.com/nomic-ai/gpt4all/blob/main/chat/gpt4all-lora-quantized-linux-x86?raw=true'
@@ -61,11 +62,37 @@ module Gpt4all
61
62
  def stop_bot
62
63
  return unless bot
63
64
 
64
- bot.each(&:close)
65
+ bot[0].close
66
+ bot[1].close
67
+ bot[2].exit
65
68
  @bot = nil
66
69
  @bot_pid = nil
67
70
  end
68
71
 
72
+ def restart_bot
73
+ stop_bot
74
+ start_bot
75
+ end
76
+
77
+ def prompt(input)
78
+ ensure_bot_is_ready
79
+
80
+ begin
81
+ bot.first.puts(input)
82
+ response = read_from_bot
83
+ rescue StandardError => e
84
+ puts "Error during prompt: #{e.message}"
85
+ restart_bot
86
+ response = prompt(input)
87
+ end
88
+
89
+ response
90
+ end
91
+
92
+ private
93
+
94
+ attr_reader :bot
95
+
69
96
  def download_executable
70
97
  FileUtils.mkdir_p(File.dirname(executable_path))
71
98
  download_file(determine_upstream_url, executable_path)
@@ -87,8 +114,9 @@ module Gpt4all
87
114
 
88
115
  def download_model
89
116
  model_url = "https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/#{model}.bin"
90
-
91
117
  download_file(model_url, model_path)
118
+ download_md5_file
119
+ verify_md5_signature
92
120
 
93
121
  puts "File downloaded successfully to #{model_path}"
94
122
  end
@@ -131,7 +159,7 @@ module Gpt4all
131
159
  def write_chunks_to_file(response, destination, progress_bar)
132
160
  File.open(destination, 'wb') do |file|
133
161
  downloaded_size = 0
134
- response.body.each_chunk do |chunk|
162
+ response.body.each(2048) do |chunk|
135
163
  progress_bar.advance(chunk.bytesize)
136
164
  file.write(chunk)
137
165
  downloaded_size += chunk.bytesize
@@ -140,36 +168,48 @@ module Gpt4all
140
168
  end
141
169
  end
142
170
 
143
- def wait_for_bot_ready
144
- loop do
145
- output = bot.last.gets
146
- break if output&.include?('>')
147
- end
171
+ def download_md5_file
172
+ md5_url = "https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/#{model}.bin.md5"
173
+ md5_path = "#{model_path}.md5"
174
+ download_file(md5_url, md5_path)
148
175
  end
149
176
 
150
- def prompt(input)
151
- ensure_bot_is_ready
177
+ def verify_md5_signature
178
+ md5_path = "#{model_path}.md5"
179
+ raise 'MD5 file not found.' unless File.exist?(md5_path)
152
180
 
153
- begin
154
- bot.first.puts(input)
155
- response = bot.last.gets.strip
156
- rescue StandardError => e
157
- puts "Error during prompt: #{e.message}"
158
- restart_bot
159
- response = prompt(input)
181
+ expected_md5 = File.read(md5_path).strip
182
+ actual_md5 = Digest::MD5.file(model_path).hexdigest
183
+ raise 'MD5 signature mismatch.' unless expected_md5 == actual_md5
184
+
185
+ puts 'MD5 signature verified successfully.'
186
+ end
187
+
188
+ # remove the stop character from end of the output
189
+ def strip_stop(output, stop)
190
+ output[0...output.rindex(stop)]
191
+ end
192
+
193
+ def read_from_bot(stop: '>')
194
+ output = ''
195
+ loop do
196
+ new_output = bot[1].read_nonblock(2048)
197
+ output += new_output
198
+ return strip_stop(output, stop) if new_output&.include?(stop)
199
+
200
+ rescue IO::WaitReadable
201
+ bot[1].wait_readable
202
+ retry
160
203
  end
204
+ end
161
205
 
162
- response
206
+ def wait_for_bot_ready
207
+ read_from_bot
163
208
  end
164
209
 
165
210
  def ensure_bot_is_ready
166
211
  raise 'Bot is not initialized.' unless bot
167
212
  end
168
-
169
- def restart_bot
170
- stop_bot
171
- start_bot
172
- end
173
213
  end
174
214
  # rubocop:enable Metrics/ClassLength
175
215
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gpt4all
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpt4all
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaigouk Kim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-07 00:00:00.000000000 Z
11
+ date: 2023-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -71,8 +71,6 @@ files:
71
71
  - lib/gpt4all.rb
72
72
  - lib/gpt4all/conversational_ai.rb
73
73
  - lib/gpt4all/version.rb
74
- - model.bin
75
- - sig/gpt4all.rbs
76
74
  homepage: https://github.com/jaigouk/gpt4all
77
75
  licenses:
78
76
  - MIT
@@ -97,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
95
  - !ruby/object:Gem::Version
98
96
  version: '0'
99
97
  requirements: []
100
- rubygems_version: 3.2.33
98
+ rubygems_version: 3.4.10
101
99
  signing_key:
102
100
  specification_version: 4
103
101
  summary: gpt4all
data/model.bin DELETED
@@ -1 +0,0 @@
1
- This is a mock file content
data/sig/gpt4all.rbs DELETED
@@ -1,27 +0,0 @@
1
- module Gpt4all
2
- VERSION: String
3
-
4
- class ConversationalAI
5
- @bot: Process::Child | nil
6
- @model: String
7
- @decoder_config: Hash[String, untyped]
8
- @executable_path: String
9
- @model_path: String
10
-
11
- def initialize: (String? model, bool? force_download, Hash[String, untyped]? decoder_config) -> void
12
-
13
- def init: (?bool force_download) -> void
14
-
15
- def open: () -> void
16
-
17
- def close: () -> void
18
-
19
- private def download_executable: () -> void
20
-
21
- private def download_model: () -> void
22
-
23
- private def download_file: (String url, String destination) -> void
24
-
25
- def prompt: (String input) -> String
26
- end
27
- end