llamafile 0.1.a → 0.1.c

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: 6c89dfd2eb64a990d0ec285d8961626464df2dc4b92997fe1247ae60bc245ad0
4
+ data.tar.gz: 0ccf6006bbb9d5be6b6f0b5f748f4464525f71c0f8f2bbdcfdaf6007d116c951
5
5
  SHA512:
6
- metadata.gz: d0ac1e9f7a442a18f431dc3cc350f098a6437d4ca6432e34ef42f186767a51f25a4b7571ed50bc740bedd713bf3313c498b48d571dfe245861ea103a9b338f59
7
- data.tar.gz: 03b812d9a6d52ec5ed457eef481d9a17c031f0a217c2d49b98715f61799be7edfaa6ac1be71966cce941bdd8ea81a1bb415d73c86079536db9571205ca16d538
6
+ metadata.gz: f32e82de553064be7487c6fe0ebbb972ed2ab49b2fca5cc7ed1a1eb06a84473afccb7b44c75f82f42339ab866dd91f0b5083bd270874542e91356b3eb83d3a08
7
+ data.tar.gz: 23fa858db06a3bbc2194ca53662f43912c90dda8d084f4122a19517090bbe4327b6c0498cf7e47c9d74d08ce65cdbca38a26c24e42e335b681c0435cf0413427
@@ -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.c"
5
5
  end
data/lib/llamafile.rb CHANGED
@@ -21,19 +21,32 @@ 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 convo
37
+ o = []; @convo[-5..-1].each { |e| o << %[User: #{e[0]}\nLlama: #{e[1]}] };
38
+ return o.join("\n\n")
39
+ end
40
+ def prompt
41
+ %[Llama is #{@character}\nUser is #{@actor}\n#{@format}\nUse this example to guide your response:\n#{@example}\n#{convo}]
28
42
  end
29
43
  def << i
30
- @output = Lf.prompt(output: %[User: #{@input}\nLlama: #{@output}], input: i)
31
- @input = i
32
- return @output
44
+ chain i
33
45
  end
34
46
  def chain *p
35
47
  [p].flatten.compact.each { |e|
36
- @output = Lf.prompt(output: %[User: #{@input}\nLlama: #{@output}], input: e)
48
+ @convo << [ i, Lf.prompt(output: prompt, input: i)]
49
+ @output = @convo[-1][1]
37
50
  @input = e
38
51
  }
39
52
  return @output
@@ -49,8 +62,8 @@ module Lf
49
62
  @@C.delete(k)
50
63
  end
51
64
  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); }
65
+ s = {}
66
+ [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
67
  return s
55
68
  end
56
69
  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.c
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Olson