llamafile 0.1.9 → 0.2.0
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 -1
- data/lib/llamafile.rb +22 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa8d8b3b005c7f195b14adc3c06a6779302862704942399a8d622a0ab82d86c4
|
4
|
+
data.tar.gz: caa2a7f2c3d092b402c37a352f85aed52d1a47472d4a32685f7a0a7bdd4bcdf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fd5a0a86e10c80de170d2c4c4bed938036ac317ab9f866080a5c971a035605d38c9e22b711de2e53ea5c6ef7331c61d0b3a1a2d9dd58b943c0dd8451e53ab10
|
7
|
+
data.tar.gz: 75af1fe10bbf5224e76aeda87ff15db852fdbbd43e8f4ef9c9933a36f81593f99763172460720b7ced9f8583a0f343e4354d47a5d088fd5c5b9d864a3e97f8cc
|
data/lib/llamafile/version.rb
CHANGED
data/lib/llamafile.rb
CHANGED
@@ -21,19 +21,35 @@ module Lf
|
|
21
21
|
end
|
22
22
|
@@C = Hash.new { |h,k| h[k] = C.new(k) }
|
23
23
|
class C
|
24
|
+
attr_accessor :character, :actor, :example, :format
|
25
|
+
attr_reader :output, :input
|
24
26
|
def initialize k
|
25
27
|
@id = k
|
26
28
|
@input = ""
|
27
29
|
@output = ""
|
30
|
+
@character = %[a helpful and honest personal assistant.]
|
31
|
+
@actor = %[an honest person.]
|
32
|
+
@format = %[Format your response as properly formatted markdown.]
|
33
|
+
@example = %[# this is a heading\nThis is some general text about the heading.\n1. list item one.\n2. list item two.\n3. list item three.]
|
34
|
+
@convo = []
|
35
|
+
end
|
36
|
+
def pre q, a
|
37
|
+
@convo << [ q, a ]
|
38
|
+
end
|
39
|
+
def convo
|
40
|
+
o = []; @convo[-5..-1].each { |e| o << %[User: #{e[0]}\nLlama: #{e[1]}] };
|
41
|
+
return o.join("\n\n")
|
42
|
+
end
|
43
|
+
def prompt
|
44
|
+
%[Llama is #{@character}\nUser is #{@actor}\n#{@format}\nUse this example to guide your response:\n#{@example}\n#{convo}]
|
28
45
|
end
|
29
46
|
def << i
|
30
|
-
|
31
|
-
@input = i
|
32
|
-
return @output
|
47
|
+
chain i
|
33
48
|
end
|
34
49
|
def chain *p
|
35
50
|
[p].flatten.compact.each { |e|
|
36
|
-
@
|
51
|
+
@convo << [ i, Lf.prompt(output: prompt, input: i)]
|
52
|
+
@output = @convo[-1][1]
|
37
53
|
@input = e
|
38
54
|
}
|
39
55
|
return @output
|
@@ -49,10 +65,8 @@ module Lf
|
|
49
65
|
@@C.delete(k)
|
50
66
|
end
|
51
67
|
def self.chain *p
|
52
|
-
s =
|
53
|
-
[p].flatten.compact.each { |e|
|
54
|
-
s = LLAMA << %[#{s}#{e}]
|
55
|
-
}
|
68
|
+
s = {}
|
69
|
+
[p].flatten.compact.each { |e| o = []; s.each_pair {|k,v| o << %[User: #{k}\nLlama: #{v}] }; s[e] = Lf.prompt(output: o.join("\n"), input: e); }
|
56
70
|
return s
|
57
71
|
end
|
58
72
|
end
|