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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eecffa6e74da830d2293c3d25d0b94e96d142aab138086c7d11f65d90d148c5b
4
- data.tar.gz: fa0736d62ab201d4691c86e073d77e442d19a24ca7fc1437ba8767230f8905b5
3
+ metadata.gz: aa8d8b3b005c7f195b14adc3c06a6779302862704942399a8d622a0ab82d86c4
4
+ data.tar.gz: caa2a7f2c3d092b402c37a352f85aed52d1a47472d4a32685f7a0a7bdd4bcdf0
5
5
  SHA512:
6
- metadata.gz: '046846dcb6eae1b18503f64fab042bbe29a8e0de757c14055dc4932fd45f8792c1484307f4f7f00133790ff2ae607d37d23b5858a2b5e752ac1bd0ceca6fcddb'
7
- data.tar.gz: 399a97efd2be9d9b7af4afaf2cd7447524b5f502cc6c75c9f182853d710ec38b3360063f91fa6b7b7d7711d43714ccbab12c0e965719895804567746b7a5b0e2
6
+ metadata.gz: 0fd5a0a86e10c80de170d2c4c4bed938036ac317ab9f866080a5c971a035605d38c9e22b711de2e53ea5c6ef7331c61d0b3a1a2d9dd58b943c0dd8451e53ab10
7
+ data.tar.gz: 75af1fe10bbf5224e76aeda87ff15db852fdbbd43e8f4ef9c9933a36f81593f99763172460720b7ced9f8583a0f343e4354d47a5d088fd5c5b9d864a3e97f8cc
@@ -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.0"
5
5
  end
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
- @output = Lf.prompt(output: %[User: #{@input}\nLlama: #{@output}], input: i)
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
- @output = Lf.prompt(output: %[User: #{@input}\nLlama: #{@output}], input: e)
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
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Olson