llamafile 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/llamafile/version.rb +1 -3
- data/lib/llamafile.rb +51 -52
- data/llamafile +1 -0
- metadata +2 -2
- data/lib/llamafile/llama.rb +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43d717db277352fb5af8fe9e9fd85efd448870b3c5907a50ebdac950c0f51308
|
4
|
+
data.tar.gz: ccfb62f362faa72cdd8d41f33feda59febd6c6d836c757cc4becb92af617ec51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc30ccc8acc320ffc49286cf0c878adafbbede1d23630bf6a64031dc66570567cc17fde96633d031428b39a3f974cc17567537f8464cecc4526be787ecae6043
|
7
|
+
data.tar.gz: 3dbd9a3e7bb5b4ded37d24250400b470f316056203cde3202951677c907006ccfa7d5bf44c8bedd8ed4990a5522273e5638c81864dc5c87cf6edb5c4f49b19d9
|
data/lib/llamafile/version.rb
CHANGED
data/lib/llamafile.rb
CHANGED
@@ -3,63 +3,62 @@
|
|
3
3
|
require 'httparty'
|
4
4
|
|
5
5
|
require_relative "llamafile/version"
|
6
|
-
|
7
|
-
module LLAMA
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
6
|
+
module Lf
|
7
|
+
module LLAMA
|
8
|
+
DEF = {
|
9
|
+
stream: false,
|
10
|
+
grammar: %[root ::= l+\nl ::= i "\n"\ni ::= [^\n\t{|}]+ [.!?]],
|
11
|
+
n_predict: 2048,
|
12
|
+
n_probs: 0,
|
13
|
+
cache_prompt: true,
|
14
|
+
min_keep: 10,
|
15
|
+
min_p: 0.05,
|
16
|
+
mirostat: 2,
|
17
|
+
mirostat_eta: 0.1,
|
18
|
+
mirostat_tau: 5,
|
19
|
+
repeat_lat_n: 256,
|
20
|
+
repeat_penalty: 2,
|
21
|
+
slot_id: -1,
|
22
|
+
temperature: 0,
|
23
|
+
tfs_z: 1,
|
24
|
+
top_k: 95,
|
25
|
+
top_p: 0.95,
|
26
|
+
typical_p: 1,
|
27
|
+
stop: ['</s>','Llama:','User:']
|
28
|
+
}
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
30
|
+
class Llama
|
31
|
+
include HTTParty
|
32
|
+
base_uri ENV['LLAMA']
|
33
|
+
end
|
34
|
+
def self.post h={}, &b
|
35
|
+
hh = {
|
36
|
+
headers: { "Content-Type": "application/json", "Connection": 'keep-alive', "Priority": 'u=0' },
|
37
|
+
body: JSON.generate(DEF.merge(h))
|
38
|
+
}
|
39
|
+
fiber = Fiber.new do |hhh|
|
40
|
+
begin
|
41
|
+
r = Llama.post('/completion', hhh)
|
42
|
+
#puts %[LLAMA CODE: #{r.code}]
|
43
|
+
if r.code == 200
|
44
|
+
rr = r['content'].gsub(/<.+>/, "").gsub(/\s\s+/, " ").gsub(/\n+/, "\n");
|
45
|
+
if block_given?
|
46
|
+
Fiber.yield b.call(rr);
|
47
|
+
else
|
48
|
+
Fiber.yield rr;
|
49
|
+
end
|
50
|
+
else
|
51
|
+
Fiber.yield false
|
52
|
+
end
|
53
|
+
rescue => err
|
54
|
+
puts %[LLAMA POST ERR: #{err}]
|
55
|
+
Fiber.yield false
|
49
56
|
end
|
50
|
-
else
|
51
|
-
Fiber.yield false
|
52
57
|
end
|
53
|
-
|
54
|
-
|
55
|
-
Fiber.yield false
|
56
|
-
end
|
58
|
+
fiber.resume(hh)
|
59
|
+
end
|
57
60
|
end
|
58
|
-
fiber.resume(hh)
|
59
|
-
end
|
60
|
-
end
|
61
61
|
|
62
|
-
module Lf
|
63
62
|
AI = %[a helpful artificial intelligence who responds accurately and truthfully to User.]
|
64
63
|
|
65
64
|
AND_BOOL = %[ Respond yes or no.]
|
data/llamafile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby bin/console
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: llamafile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Olson
|
@@ -78,8 +78,8 @@ files:
|
|
78
78
|
- README.md
|
79
79
|
- Rakefile
|
80
80
|
- lib/llamafile.rb
|
81
|
-
- lib/llamafile/llama.rb
|
82
81
|
- lib/llamafile/version.rb
|
82
|
+
- llamafile
|
83
83
|
- llamafile.gemspec
|
84
84
|
- main.log
|
85
85
|
- sig/llamafile.rbs
|
data/lib/llamafile/llama.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
|
2
|
-
module LLAMA
|
3
|
-
DEF = {
|
4
|
-
stream: false,
|
5
|
-
grammar: %[root ::= l+\nl ::= i "\n"\ni ::= [^\n\t{|}]+ [.!?]],
|
6
|
-
n_predict: 2048,
|
7
|
-
n_probs: 0,
|
8
|
-
cache_prompt: true,
|
9
|
-
min_keep: 10,
|
10
|
-
min_p: 0.05,
|
11
|
-
mirostat: 2,
|
12
|
-
mirostat_eta: 0.1,
|
13
|
-
mirostat_tau: 5,
|
14
|
-
repeat_lat_n: 256,
|
15
|
-
repeat_penalty: 2,
|
16
|
-
slot_id: -1,
|
17
|
-
temperature: 0,
|
18
|
-
tfs_z: 1,
|
19
|
-
top_k: 95,
|
20
|
-
top_p: 0.95,
|
21
|
-
typical_p: 1,
|
22
|
-
stop: ['</s>','Llama:','User:']
|
23
|
-
}
|
24
|
-
|
25
|
-
class Llama
|
26
|
-
include HTTParty
|
27
|
-
base_uri ENV['LLAMA']
|
28
|
-
end
|
29
|
-
def self.post h={}, &b
|
30
|
-
hh = {
|
31
|
-
headers: { "Content-Type": "application/json", "Connection": 'keep-alive', "Priority": 'u=0' },
|
32
|
-
body: JSON.generate(DEF.merge(h))
|
33
|
-
}
|
34
|
-
fiber = Fiber.new do |hhh|
|
35
|
-
begin
|
36
|
-
r = Llama.post('/completion', hhh)
|
37
|
-
#puts %[LLAMA CODE: #{r.code}]
|
38
|
-
if r.code == 200
|
39
|
-
rr = r['content'].gsub(/<.+>/, "").gsub(/\s\s+/, " ").gsub(/\n+/, "\n");
|
40
|
-
if block_given?
|
41
|
-
Fiber.yield b.call(rr);
|
42
|
-
else
|
43
|
-
Fiber.yield rr;
|
44
|
-
end
|
45
|
-
else
|
46
|
-
Fiber.yield false
|
47
|
-
end
|
48
|
-
rescue => err
|
49
|
-
puts %[LLAMA POST ERR: #{err}]
|
50
|
-
Fiber.yield false
|
51
|
-
end
|
52
|
-
end
|
53
|
-
fiber.resume(hh)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|