llamafile 0.1.9 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eecffa6e74da830d2293c3d25d0b94e96d142aab138086c7d11f65d90d148c5b
4
- data.tar.gz: fa0736d62ab201d4691c86e073d77e442d19a24ca7fc1437ba8767230f8905b5
3
+ metadata.gz: 8f65be502a0aaa502ab94785114d66f057e9af629cda650851a39c73d3b78c97
4
+ data.tar.gz: 376add4a170db17299c3e11b1f2cc20313433894c1264c1ee729827b240ec08d
5
5
  SHA512:
6
- metadata.gz: '046846dcb6eae1b18503f64fab042bbe29a8e0de757c14055dc4932fd45f8792c1484307f4f7f00133790ff2ae607d37d23b5858a2b5e752ac1bd0ceca6fcddb'
7
- data.tar.gz: 399a97efd2be9d9b7af4afaf2cd7447524b5f502cc6c75c9f182853d710ec38b3360063f91fa6b7b7d7711d43714ccbab12c0e965719895804567746b7a5b0e2
6
+ metadata.gz: 13ccc9565d30515cafe42c61ee8e32c270e89399d1189b0f834285f277f70e31351b8ff0fdcdcacec0b5f78f16960768115918a4f3ee60ad92a03e16fda94e74
7
+ data.tar.gz: 3ef5540c172c6bdb6b021b20bfa0cbba2420f70059903a9961eb83586aaf2ae91ed069101d6b92100de396313825cbf8f4a767a79ff0b6b547ac430bba90b7f1
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Llamafile
4
- VERSION = "0.1.9"
4
+ VERSION = "0.2.1"
5
5
  end
data/lib/llamafile.rb CHANGED
@@ -21,19 +21,40 @@ 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 fact q, a
37
+ @convo << [ q, a ]
38
+ end
39
+ def hist
40
+ @convo
41
+ end
42
+ def convo
43
+ o = []; @convo[-5..-1].each { |e| o << %[User: #{e[0]}\nLlama: #{e[1]}] };
44
+ return o.join("\n\n")
45
+ end
46
+ def prompt
47
+ %[Llama is #{@character}\nUser is #{@actor}\n#{@format}\nUse this example to guide your response:\n#{@example}\n#{convo}]
28
48
  end
29
49
  def << i
30
- @output = Lf.prompt(output: %[User: #{@input}\nLlama: #{@output}], input: i)
31
- @input = i
32
- return @output
50
+ chain i
33
51
  end
34
52
  def chain *p
35
53
  [p].flatten.compact.each { |e|
36
- @output = Lf.prompt(output: %[User: #{@input}\nLlama: #{@output}], input: e)
54
+ puts %[<-- #{e}]
55
+ @convo << [ e, Lf.prompt(output: prompt, input: e)]
56
+ @output = @convo[-1][1]
57
+ puts %[--> #{@output}]
37
58
  @input = e
38
59
  }
39
60
  return @output
@@ -49,10 +70,8 @@ module Lf
49
70
  @@C.delete(k)
50
71
  end
51
72
  def self.chain *p
52
- s = ""
53
- [p].flatten.compact.each { |e|
54
- s = LLAMA << %[#{s}#{e}]
55
- }
73
+ s = {}
74
+ [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
75
  return s
57
76
  end
58
77
  end
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.1.9
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Olson