llamafile 0.1.a → 0.1.b

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: 24769f0bcce302fe2f2fb917ece3feff871ce504733dafe2f13eddf1f46ce495
4
- data.tar.gz: 7f71099d0765507101549589afe113aab4946962faa223e0bc474922d89df2a4
3
+ metadata.gz: 90c49ba212f3e70212158feb96abaca940cad6076674106bf45225d3ed319134
4
+ data.tar.gz: 7e27448538124942422cfebb679a66fa523dec14a25e6bcefde28c2f8e5e6422
5
5
  SHA512:
6
- metadata.gz: d0ac1e9f7a442a18f431dc3cc350f098a6437d4ca6432e34ef42f186767a51f25a4b7571ed50bc740bedd713bf3313c498b48d571dfe245861ea103a9b338f59
7
- data.tar.gz: 03b812d9a6d52ec5ed457eef481d9a17c031f0a217c2d49b98715f61799be7edfaa6ac1be71966cce941bdd8ea81a1bb415d73c86079536db9571205ca16d538
6
+ metadata.gz: a3e09a105ae2b69ea6c50a72182f4ccda95bfdc386d47af5a4951c1970d899de73a2eeb299454e1a3d76ab29d308871d52ef255302b4eb8522ad33baed772676
7
+ data.tar.gz: f8bb58bc4b9523f21e1305cc6b785204d56562393b107a809e722dc55e209fa34d6c002f3dd0f7c7d7d36d85c9eabc7b7c69fcd1d0e6de6db05ee6db882ee71c
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Llamafile
4
- VERSION = "0.1.a"
4
+ VERSION = "0.1.b"
5
5
  end
data/lib/llamafile.rb CHANGED
@@ -21,19 +21,31 @@ module Lf
21
21
  end
22
22
  @@C = Hash.new { |h,k| h[k] = C.new(k) }
23
23
  class C
24
+ attr_reader :output, :input, :character, :actor, :example
24
25
  def initialize k
25
26
  @id = k
26
27
  @input = ""
27
28
  @output = ""
29
+ @character = %[a helpful and honest personal assistant.]
30
+ @actor = %[an honest person.]
31
+ @format = %[Format your response as properly formatted markdown.]
32
+ @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.]
33
+ @convo = []
34
+ end
35
+ def convo
36
+ o = []; @convo[-5..-1].each { |e| o << %[User: #{e[0]}\nLlama: #{e[1]}] };
37
+ return o.join("\n\n")
38
+ end
39
+ def prompt
40
+ %[Llama is #{@character}\nUser is #{@actor}\n#{@format}\nUse this example to guide your response:\n#{@example}\n#{convo}]
28
41
  end
29
42
  def << i
30
- @output = Lf.prompt(output: %[User: #{@input}\nLlama: #{@output}], input: i)
31
- @input = i
32
- return @output
43
+ chain i
33
44
  end
34
45
  def chain *p
35
46
  [p].flatten.compact.each { |e|
36
- @output = Lf.prompt(output: %[User: #{@input}\nLlama: #{@output}], input: e)
47
+ @convo << [ i, Lf.prompt(output: prompt, input: i)]
48
+ @output = @convo[-1][1]
37
49
  @input = e
38
50
  }
39
51
  return @output
@@ -49,8 +61,8 @@ module Lf
49
61
  @@C.delete(k)
50
62
  end
51
63
  def self.chain *p
52
- s, r = "", ""
53
- [p].flatten.compact.each { |e| r = e; s = Lf.prompt(output: %[User: #{r}\nLlama: #{s}], input: e); }
64
+ s = {}
65
+ [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); }
54
66
  return s
55
67
  end
56
68
  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.a
4
+ version: 0.1.b
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Olson