gpt4all 0.0.2 → 0.0.4

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: 73096360c4f9175928af641a06e4b137191afae53438bbbe9ef4b095463053e5
4
- data.tar.gz: e79c2ea669da611104cd7c1890e7b5ba1b0c0baa7dca90ca6fa149158ad1910a
3
+ metadata.gz: bcbc4d0a68ce0e29cae2ded264680ea57c279b0cb514545b199b6c03141b6af4
4
+ data.tar.gz: 9662b980b9c22ec94d252ac5793f48deba90739db2804757438f2a345632cff2
5
5
  SHA512:
6
- metadata.gz: 923387d8c54178edb2a3538ea05ee591034458c1af9fb4534fa28219f6f6723a3f4418bcd2b9345157fbb3b4435a01c7832eb305f0378ca39964caf724bc0508
7
- data.tar.gz: dd98dbf6c1275c34f2e844bce810a0ae4f7bccecc0ab686a827da43627fe4f54dc2ccef2990c6945196561331589fb3fc576fdc36bf6cb98d7ae3b5f88091e76
6
+ metadata.gz: a6f1e2c6146a365aee6ec0df861113b6e9ea452781f19473429147d563c32a7d1897a55aeeab72dfc66d64e0e32a6cf0a0f9ddf70062a154ad84fbb6766fe14a
7
+ data.tar.gz: 13e4b5cd8aa2dbbf7d707d8e484c8ddebb3699aed13c761813085b9b55ae4e7d7145d48fb6a2549d66eb04f59eb5528a0caf5d579bacff04f2fd7bfec24b5e86
data/.rubocop.yml CHANGED
@@ -4,7 +4,6 @@ require:
4
4
 
5
5
  AllCops:
6
6
  NewCops: enable
7
- TargetRubyVersion: 3.2
8
7
  Exclude:
9
8
  - db/**/*.rb
10
9
  - bin/**/*.rb
data/Gemfile CHANGED
@@ -15,8 +15,7 @@ gem 'brakeman'
15
15
  gem 'bundler-audit'
16
16
  gem 'byebug'
17
17
  gem 'dotenv'
18
- gem 'license_finder'
19
- gem 'overcommit'
18
+
20
19
  gem 'rubocop-performance'
21
20
  gem 'rubocop-sequel'
22
21
  gem 'rubocop-shopify'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gpt4all (0.0.2)
4
+ gpt4all (0.0.4)
5
5
  faraday (~> 2.7)
6
6
  os (~> 1.1)
7
7
  tty-progressbar (~> 0.18.2)
@@ -17,7 +17,6 @@ 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
23
22
  diff-lcs (1.5.0)
@@ -27,20 +26,8 @@ GEM
27
26
  ruby2_keywords (>= 0.0.4)
28
27
  faraday-net_http (3.0.2)
29
28
  hashdiff (1.0.1)
30
- iniparse (1.5.0)
31
29
  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
30
  os (1.1.4)
40
- overcommit (0.60.0)
41
- childprocess (>= 0.6.3, < 5)
42
- iniparse (~> 1.4)
43
- rexml (~> 3.2)
44
31
  parallel (1.22.1)
45
32
  parser (3.2.2.0)
46
33
  ast (~> 2.4.1)
@@ -83,10 +70,8 @@ GEM
83
70
  rubocop (~> 1.44)
84
71
  ruby-progressbar (1.13.0)
85
72
  ruby2_keywords (0.0.5)
86
- rubyzip (2.3.2)
87
73
  strings-ansi (0.2.0)
88
74
  thor (1.2.1)
89
- tomlrb (2.0.3)
90
75
  tty-cursor (0.7.1)
91
76
  tty-progressbar (0.18.2)
92
77
  strings-ansi (~> 0.2)
@@ -99,12 +84,14 @@ GEM
99
84
  addressable (>= 2.8.0)
100
85
  crack (>= 0.3.2)
101
86
  hashdiff (>= 0.4.0, < 2.0.0)
102
- with_env (1.1.0)
103
- xml-simple (1.1.9)
104
- rexml
105
87
 
106
88
  PLATFORMS
89
+ aarch64-linux
90
+ aarch64-linux-musl
91
+ arm64-darwin-21
107
92
  arm64-darwin-22
93
+ x86_64-linux
94
+ x86_64-linux-musl
108
95
 
109
96
  DEPENDENCIES
110
97
  brakeman
@@ -112,8 +99,6 @@ DEPENDENCIES
112
99
  byebug
113
100
  dotenv
114
101
  gpt4all!
115
- license_finder
116
- overcommit
117
102
  rake (~> 13.0)
118
103
  rspec (~> 3.0)
119
104
  rubocop (~> 1.21)
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/gpt4all.svg)](https://badge.fury.io/rb/gpt4all)
4
4
  [![CI](https://github.com/jaigouk/gpt4all/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/jaigouk/gpt4all/actions/workflows/main.yml)
5
5
 
6
- Gpt4all is a Ruby gem that provides an easy-to-use interface for interacting with the GPT-4 conversational AI model.
6
+ Gpt4all is a Ruby gem that provides an easy-to-use interface for interacting with the [GPT4ALL](https://github.com/nomic-ai/gpt4all-ts) conversational AI model.
7
7
 
8
8
  ## Installation
9
9
 
data/gpt4all.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'interface to gpt4all'
13
13
  spec.homepage = 'https://github.com/jaigouk/gpt4all'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = '>= 3.2'
15
+ spec.required_ruby_version = '>= 2.7.0'
16
16
 
17
17
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
18
 
@@ -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'
@@ -66,9 +67,33 @@ module Gpt4all
66
67
  @bot_pid = nil
67
68
  end
68
69
 
70
+ def restart_bot
71
+ stop_bot
72
+ start_bot
73
+ end
74
+
75
+ def prompt(input)
76
+ ensure_bot_is_ready
77
+
78
+ begin
79
+ bot.first.puts(input)
80
+ response = bot.last.gets.strip
81
+ rescue StandardError => e
82
+ puts "Error during prompt: #{e.message}"
83
+ restart_bot
84
+ response = prompt(input)
85
+ end
86
+
87
+ response
88
+ end
89
+
90
+ private
91
+
92
+ attr_reader :bot
93
+
69
94
  def download_executable
70
- upstream = determine_upstream_url
71
- download_file(upstream, executable_path)
95
+ FileUtils.mkdir_p(File.dirname(executable_path))
96
+ download_file(determine_upstream_url, executable_path)
72
97
  FileUtils.chmod(0o755, executable_path)
73
98
  puts "File downloaded successfully to #{executable_path}"
74
99
  end
@@ -87,8 +112,9 @@ module Gpt4all
87
112
 
88
113
  def download_model
89
114
  model_url = "https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/#{model}.bin"
90
-
91
115
  download_file(model_url, model_path)
116
+ download_md5_file
117
+ verify_md5_signature
92
118
 
93
119
  puts "File downloaded successfully to #{model_path}"
94
120
  end
@@ -130,13 +156,33 @@ module Gpt4all
130
156
 
131
157
  def write_chunks_to_file(response, destination, progress_bar)
132
158
  File.open(destination, 'wb') do |file|
159
+ downloaded_size = 0
133
160
  response.body.each_chunk do |chunk|
134
161
  progress_bar.advance(chunk.bytesize)
135
162
  file.write(chunk)
163
+ downloaded_size += chunk.bytesize
136
164
  end
165
+ raise 'Incomplete file downloaded.' if downloaded_size < progress_bar.total
137
166
  end
138
167
  end
139
168
 
169
+ def download_md5_file
170
+ md5_url = "https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/#{model}.bin.md5"
171
+ md5_path = "#{model_path}.md5"
172
+ download_file(md5_url, md5_path)
173
+ end
174
+
175
+ def verify_md5_signature
176
+ md5_path = "#{model_path}.md5"
177
+ raise 'MD5 file not found.' unless File.exist?(md5_path)
178
+
179
+ expected_md5 = File.read(md5_path).strip
180
+ actual_md5 = Digest::MD5.file(model_path).hexdigest
181
+ raise 'MD5 signature mismatch.' unless expected_md5 == actual_md5
182
+
183
+ puts 'MD5 signature verified successfully.'
184
+ end
185
+
140
186
  def wait_for_bot_ready
141
187
  loop do
142
188
  output = bot.last.gets
@@ -144,29 +190,9 @@ module Gpt4all
144
190
  end
145
191
  end
146
192
 
147
- def prompt(input)
148
- ensure_bot_is_ready
149
-
150
- begin
151
- bot.first.puts(input)
152
- response = bot.last.gets.strip
153
- rescue StandardError => e
154
- puts "Error during prompt: #{e.message}"
155
- restart_bot
156
- response = prompt(input)
157
- end
158
-
159
- response
160
- end
161
-
162
193
  def ensure_bot_is_ready
163
194
  raise 'Bot is not initialized.' unless bot
164
195
  end
165
-
166
- def restart_bot
167
- stop_bot
168
- start_bot
169
- end
170
196
  end
171
197
  # rubocop:enable Metrics/ClassLength
172
198
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gpt4all
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.4'
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.2
4
+ version: 0.0.4
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-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -71,7 +71,6 @@ files:
71
71
  - lib/gpt4all.rb
72
72
  - lib/gpt4all/conversational_ai.rb
73
73
  - lib/gpt4all/version.rb
74
- - sig/gpt4all.rbs
75
74
  homepage: https://github.com/jaigouk/gpt4all
76
75
  licenses:
77
76
  - MIT
@@ -89,7 +88,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
88
  requirements:
90
89
  - - ">="
91
90
  - !ruby/object:Gem::Version
92
- version: '3.2'
91
+ version: 2.7.0
93
92
  required_rubygems_version: !ruby/object:Gem::Requirement
94
93
  requirements:
95
94
  - - ">="
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