ollama-ruby 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/CHANGES.md +11 -0
- data/README.md +2 -2
- data/Rakefile +4 -5
- data/bin/ollama_chat +27 -21
- data/lib/ollama/client/command.rb +2 -2
- data/lib/ollama/version.rb +1 -1
- data/lib/ollama.rb +0 -4
- data/ollama-ruby.gemspec +11 -12
- metadata +26 -88
- data/lib/ollama/documents/cache/common.rb +0 -36
- data/lib/ollama/documents/cache/memory_cache.rb +0 -44
- data/lib/ollama/documents/cache/records.rb +0 -87
- data/lib/ollama/documents/cache/redis_backed_memory_cache.rb +0 -39
- data/lib/ollama/documents/cache/redis_cache.rb +0 -68
- data/lib/ollama/documents/cache/sqlite_cache.rb +0 -215
- data/lib/ollama/documents/splitters/character.rb +0 -72
- data/lib/ollama/documents/splitters/semantic.rb +0 -91
- data/lib/ollama/documents.rb +0 -184
- data/lib/ollama/utils/colorize_texts.rb +0 -65
- data/lib/ollama/utils/math.rb +0 -48
- data/lib/ollama/utils/tags.rb +0 -67
- data/spec/assets/embeddings.json +0 -1
- data/spec/ollama/documents/cache/memory_cache_spec.rb +0 -97
- data/spec/ollama/documents/cache/redis_backed_memory_cache_spec.rb +0 -118
- data/spec/ollama/documents/cache/redis_cache_spec.rb +0 -121
- data/spec/ollama/documents/cache/sqlite_cache_spec.rb +0 -141
- data/spec/ollama/documents/splitters/character_spec.rb +0 -110
- data/spec/ollama/documents/splitters/semantic_spec.rb +0 -56
- data/spec/ollama/documents_spec.rb +0 -162
- data/spec/ollama/utils/colorize_texts_spec.rb +0 -13
- data/spec/ollama/utils/tags_spec.rb +0 -53
data/lib/ollama/documents.rb
DELETED
@@ -1,184 +0,0 @@
|
|
1
|
-
require 'numo/narray'
|
2
|
-
require 'digest'
|
3
|
-
require 'kramdown/ansi'
|
4
|
-
|
5
|
-
class Ollama::Documents
|
6
|
-
end
|
7
|
-
module Ollama::Documents::Cache
|
8
|
-
end
|
9
|
-
require 'ollama/documents/cache/records'
|
10
|
-
require 'ollama/documents/cache/memory_cache'
|
11
|
-
require 'ollama/documents/cache/redis_cache'
|
12
|
-
require 'ollama/documents/cache/redis_backed_memory_cache'
|
13
|
-
require 'ollama/documents/cache/sqlite_cache'
|
14
|
-
module Ollama::Documents::Splitters
|
15
|
-
end
|
16
|
-
require 'ollama/documents/splitters/character'
|
17
|
-
require 'ollama/documents/splitters/semantic'
|
18
|
-
|
19
|
-
class Ollama::Documents
|
20
|
-
include Kramdown::ANSI::Width
|
21
|
-
include Ollama::Documents::Cache
|
22
|
-
|
23
|
-
Record = Class.new Ollama::Documents::Cache::Records::Record
|
24
|
-
|
25
|
-
def initialize(ollama:, model:, model_options: nil, collection: nil, embedding_length: 1_024, cache: MemoryCache, database_filename: nil, redis_url: nil, debug: false)
|
26
|
-
collection ||= default_collection
|
27
|
-
@ollama, @model, @model_options, @collection, @debug =
|
28
|
-
ollama, model, model_options, collection.to_sym, debug
|
29
|
-
database_filename ||= ':memory:'
|
30
|
-
@cache = connect_cache(cache, redis_url, embedding_length, database_filename)
|
31
|
-
end
|
32
|
-
|
33
|
-
def default_collection
|
34
|
-
:default
|
35
|
-
end
|
36
|
-
|
37
|
-
attr_reader :ollama, :model, :collection, :cache
|
38
|
-
|
39
|
-
def collection=(new_collection)
|
40
|
-
@collection = new_collection.to_sym
|
41
|
-
@cache.prefix = prefix
|
42
|
-
end
|
43
|
-
|
44
|
-
def add(inputs, batch_size: nil, source: nil, tags: [])
|
45
|
-
inputs = Array(inputs)
|
46
|
-
batch_size ||= 10
|
47
|
-
tags = Ollama::Utils::Tags.new(tags, source:)
|
48
|
-
if source
|
49
|
-
tags.add(File.basename(source).gsub(/\?.*/, ''), source:)
|
50
|
-
end
|
51
|
-
inputs.map! { |i|
|
52
|
-
text = i.respond_to?(:read) ? i.read : i.to_s
|
53
|
-
text
|
54
|
-
}
|
55
|
-
inputs.reject! { |i| exist?(i) }
|
56
|
-
inputs.empty? and return self
|
57
|
-
if @debug
|
58
|
-
puts Ollama::Utils::ColorizeTexts.new(inputs)
|
59
|
-
end
|
60
|
-
batches = inputs.each_slice(batch_size).
|
61
|
-
with_infobar(
|
62
|
-
label: "Add #{truncate(tags.to_s(link: false), percentage: 25)}",
|
63
|
-
total: inputs.size
|
64
|
-
)
|
65
|
-
batches.each do |batch|
|
66
|
-
embeddings = fetch_embeddings(model:, options: @model_options, input: batch)
|
67
|
-
batch.zip(embeddings) do |text, embedding|
|
68
|
-
norm = @cache.norm(embedding)
|
69
|
-
self[text] = Record[text:, embedding:, norm:, source:, tags: tags.to_a]
|
70
|
-
end
|
71
|
-
infobar.progress by: batch.size
|
72
|
-
end
|
73
|
-
infobar.newline
|
74
|
-
self
|
75
|
-
end
|
76
|
-
alias << add
|
77
|
-
|
78
|
-
def [](text)
|
79
|
-
@cache[key(text)]
|
80
|
-
end
|
81
|
-
|
82
|
-
def []=(text, record)
|
83
|
-
@cache[key(text)] = record
|
84
|
-
end
|
85
|
-
|
86
|
-
def exist?(text)
|
87
|
-
@cache.key?(key(text))
|
88
|
-
end
|
89
|
-
|
90
|
-
def delete(text)
|
91
|
-
@cache.delete(key(text))
|
92
|
-
end
|
93
|
-
|
94
|
-
def size
|
95
|
-
@cache.size
|
96
|
-
end
|
97
|
-
|
98
|
-
def clear(tags: nil)
|
99
|
-
@cache.clear(tags:)
|
100
|
-
self
|
101
|
-
end
|
102
|
-
|
103
|
-
def find(string, tags: nil, prompt: nil, max_records: nil)
|
104
|
-
needle = convert_to_vector(string, prompt:)
|
105
|
-
@cache.find_records(needle, tags:, max_records: nil)
|
106
|
-
end
|
107
|
-
|
108
|
-
def find_where(string, text_size: nil, text_count: nil, **opts)
|
109
|
-
if text_count
|
110
|
-
opts[:max_records] = text_count
|
111
|
-
end
|
112
|
-
records = find(string, **opts)
|
113
|
-
size, count = 0, 0
|
114
|
-
records.take_while do |record|
|
115
|
-
if text_size and (size += record.text.size) > text_size
|
116
|
-
next false
|
117
|
-
end
|
118
|
-
if text_count and (count += 1) > text_count
|
119
|
-
next false
|
120
|
-
end
|
121
|
-
true
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def collections
|
126
|
-
([ default_collection ] + @cache.collections('%s-' % self.class)).uniq
|
127
|
-
end
|
128
|
-
|
129
|
-
def tags
|
130
|
-
@cache.tags
|
131
|
-
end
|
132
|
-
|
133
|
-
private
|
134
|
-
|
135
|
-
def connect_cache(cache_class, redis_url, embedding_length, database_filename)
|
136
|
-
cache = nil
|
137
|
-
if (cache_class.instance_method(:redis) rescue nil)
|
138
|
-
begin
|
139
|
-
cache = cache_class.new(prefix:, url: redis_url, object_class: Record)
|
140
|
-
cache.size
|
141
|
-
rescue Redis::CannotConnectError
|
142
|
-
STDERR.puts(
|
143
|
-
"Cannot connect to redis URL #{redis_url.inspect}, "\
|
144
|
-
"falling back to MemoryCache."
|
145
|
-
)
|
146
|
-
end
|
147
|
-
elsif cache_class == SQLiteCache
|
148
|
-
cache = cache_class.new(
|
149
|
-
prefix:,
|
150
|
-
embedding_length:,
|
151
|
-
filename: database_filename,
|
152
|
-
debug: @debug
|
153
|
-
)
|
154
|
-
end
|
155
|
-
ensure
|
156
|
-
cache ||= MemoryCache.new(prefix:,)
|
157
|
-
cache.respond_to?(:find_records) or cache.extend(Records::FindRecords)
|
158
|
-
cache.extend(Records::Tags)
|
159
|
-
if cache.respond_to?(:redis)
|
160
|
-
cache.extend(Records::RedisFullEach)
|
161
|
-
end
|
162
|
-
return cache
|
163
|
-
end
|
164
|
-
|
165
|
-
def convert_to_vector(input, prompt: nil)
|
166
|
-
if prompt
|
167
|
-
input = prompt % input
|
168
|
-
end
|
169
|
-
input.is_a?(String) and input = fetch_embeddings(model:, input:).first
|
170
|
-
@cache.convert_to_vector(input)
|
171
|
-
end
|
172
|
-
|
173
|
-
def fetch_embeddings(model:, input:, options: nil)
|
174
|
-
@ollama.embed(model:, input:, options:).embeddings
|
175
|
-
end
|
176
|
-
|
177
|
-
def prefix
|
178
|
-
'%s-%s-' % [ self.class, @collection ]
|
179
|
-
end
|
180
|
-
|
181
|
-
def key(input)
|
182
|
-
Digest::SHA256.hexdigest(input)
|
183
|
-
end
|
184
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'term/ansicolor'
|
2
|
-
require 'kramdown/ansi'
|
3
|
-
|
4
|
-
class Ollama::Utils::ColorizeTexts
|
5
|
-
include Math
|
6
|
-
include Term::ANSIColor
|
7
|
-
include Kramdown::ANSI::Width
|
8
|
-
|
9
|
-
# Initializes a new instance of Ollama::Utils::ColorizeTexts
|
10
|
-
#
|
11
|
-
# @param [Array<String>] texts the array of strings to be displayed with colors
|
12
|
-
#
|
13
|
-
# @return [Ollama::Utils::ColorizeTexts] an instance of Ollama::Utils::ColorizeTexts
|
14
|
-
def initialize(*texts)
|
15
|
-
texts = texts.map(&:to_a)
|
16
|
-
@texts = Array(texts.flatten)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Returns a string representation of the object, including all texts content,
|
20
|
-
# colored differently and their sizes.
|
21
|
-
#
|
22
|
-
# @return [String] The formatted string.
|
23
|
-
def to_s
|
24
|
-
result = +''
|
25
|
-
@texts.each_with_index do |t, i|
|
26
|
-
color = colors[(t.hash ^ i.hash) % colors.size]
|
27
|
-
wrap(t, percentage: 90).each_line { |l|
|
28
|
-
result << on_color(color) { color(text_color(color)) { l } }
|
29
|
-
}
|
30
|
-
result << "\n##{bold{t.size.to_s}} \n\n"
|
31
|
-
end
|
32
|
-
result
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
# Returns the nearest RGB color to the given ANSI color
|
38
|
-
#
|
39
|
-
# @param [color] color The ANSI color attribute
|
40
|
-
#
|
41
|
-
# @return [Array<RGBTriple>] An array containing two RGB colors, one for black and
|
42
|
-
# one for white text, where the first is the closest match to the input color
|
43
|
-
# when printed on a black background, and the second is the closest match
|
44
|
-
# when printed on a white background.
|
45
|
-
def text_color(color)
|
46
|
-
color = Term::ANSIColor::Attribute[color]
|
47
|
-
[
|
48
|
-
Attribute.nearest_rgb_color('#000'),
|
49
|
-
Attribute.nearest_rgb_color('#fff'),
|
50
|
-
].max_by { |t| t.distance_to(color) }
|
51
|
-
end
|
52
|
-
|
53
|
-
# Returns an array of colors for each step in the gradient
|
54
|
-
#
|
55
|
-
# @return [Array<Array<Integer>>] An array of RGB color arrays
|
56
|
-
def colors
|
57
|
-
@colors ||= (0..255).map { |i|
|
58
|
-
[
|
59
|
-
128 + 128 * sin(PI * i / 32.0),
|
60
|
-
128 + 128 * sin(PI * i / 64.0),
|
61
|
-
128 + 128 * sin(PI * i / 128.0),
|
62
|
-
].map { _1.clamp(0, 255).round }
|
63
|
-
}
|
64
|
-
end
|
65
|
-
end
|
data/lib/ollama/utils/math.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
module Ollama::Utils::Math
|
2
|
-
# Returns the cosine similarity between two vectors +a+ and +b+, 1.0 is
|
3
|
-
# exactly the same, 0.0 means decorrelated.
|
4
|
-
#
|
5
|
-
# @param [Vector] a The first vector
|
6
|
-
# @param [Vector] b The second vector
|
7
|
-
# @option a_norm [Float] a The Euclidean norm of vector a (default: calculated from a)
|
8
|
-
# @option b_norm [Float] b The Euclidean norm of vector b (default: calculated from b)
|
9
|
-
#
|
10
|
-
# @return [Float] The cosine similarity between the two vectors
|
11
|
-
#
|
12
|
-
# @example Calculate the cosine similarity between two vectors
|
13
|
-
# cosine_similarity(a: [1, 2], b: [3, 4])
|
14
|
-
#
|
15
|
-
# @see #convert_to_vector
|
16
|
-
# @see #norm
|
17
|
-
def cosine_similarity(a:, b:, a_norm: norm(a), b_norm: norm(b))
|
18
|
-
a, b = convert_to_vector(a), convert_to_vector(b)
|
19
|
-
a.dot(b) / (a_norm * b_norm)
|
20
|
-
end
|
21
|
-
|
22
|
-
# Returns the Euclidean norm (magnitude) of a vector.
|
23
|
-
#
|
24
|
-
# @param vector [Array] The input vector.
|
25
|
-
#
|
26
|
-
# @return [Float] The magnitude of the vector.
|
27
|
-
#
|
28
|
-
# @example
|
29
|
-
# norm([3, 4]) # => 5.0
|
30
|
-
def norm(vector)
|
31
|
-
s = 0.0
|
32
|
-
vector.each { s += _1.abs2 }
|
33
|
-
Math.sqrt(s)
|
34
|
-
end
|
35
|
-
|
36
|
-
# Converts an array to a Numo NArray.
|
37
|
-
#
|
38
|
-
# @param [Array] vector The input array to be converted.
|
39
|
-
#
|
40
|
-
# @return [Numo::NArray] The converted NArray, or the original if it's already a Numo NArray.
|
41
|
-
#
|
42
|
-
# @example Convert an array to a Numo NArray
|
43
|
-
# convert_to_vector([1, 2, 3]) # => Numo::NArray[1, 2, 3]
|
44
|
-
def convert_to_vector(vector)
|
45
|
-
vector.is_a?(Numo::NArray) and return vector
|
46
|
-
Numo::NArray[*vector]
|
47
|
-
end
|
48
|
-
end
|
data/lib/ollama/utils/tags.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
class Ollama::Utils::Tags
|
2
|
-
class Tag < String
|
3
|
-
include Term::ANSIColor
|
4
|
-
|
5
|
-
def initialize(tag, source: nil)
|
6
|
-
super(tag.to_s.gsub(/\A#+/, ''))
|
7
|
-
self.source = source
|
8
|
-
end
|
9
|
-
|
10
|
-
attr_accessor :source
|
11
|
-
|
12
|
-
alias_method :internal, :to_s
|
13
|
-
|
14
|
-
def to_s(link: true)
|
15
|
-
tag_string = start_with?(?#) ? super() : ?# + super()
|
16
|
-
my_source = source
|
17
|
-
if link && my_source
|
18
|
-
unless my_source =~ %r(\A(https?|file)://)
|
19
|
-
my_source = 'file://%s' % File.expand_path(my_source)
|
20
|
-
end
|
21
|
-
hyperlink(my_source) { tag_string }
|
22
|
-
else
|
23
|
-
tag_string
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def initialize(tags = [], source: nil)
|
29
|
-
tags = Array(tags)
|
30
|
-
@set = []
|
31
|
-
tags.each { |tag| add(tag, source:) }
|
32
|
-
end
|
33
|
-
|
34
|
-
def add(tag, source: nil)
|
35
|
-
unless tag.is_a?(Tag)
|
36
|
-
tag = Tag.new(tag, source:)
|
37
|
-
end
|
38
|
-
index = @set.bsearch_index { _1 >= tag }
|
39
|
-
if index == nil
|
40
|
-
@set.push(tag)
|
41
|
-
elsif @set.at(index) != tag
|
42
|
-
@set.insert(index, tag)
|
43
|
-
end
|
44
|
-
self
|
45
|
-
end
|
46
|
-
|
47
|
-
def empty?
|
48
|
-
@set.empty?
|
49
|
-
end
|
50
|
-
|
51
|
-
def size
|
52
|
-
@set.size
|
53
|
-
end
|
54
|
-
|
55
|
-
def clear
|
56
|
-
@set.clear
|
57
|
-
end
|
58
|
-
|
59
|
-
def each(&block)
|
60
|
-
@set.each(&block)
|
61
|
-
end
|
62
|
-
include Enumerable
|
63
|
-
|
64
|
-
def to_s(link: true)
|
65
|
-
@set.map { |tag| tag.to_s(link:) } * ' '
|
66
|
-
end
|
67
|
-
end
|
data/spec/assets/embeddings.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
[[-0.009,-0.0,-0.035,-0.002,-0.044,-0.063,0.1,0.03,0.052,-0.06,-0.027,0.012,0.03,-0.04,-0.013,0.023,-0.028,0.015,-0.066,-0.032,0.052,0.028,0.063,0.037,-0.005,-0.024,0.006,0.008,0.014,-0.007,-0.042,-0.018,0.012,-0.061,-0.03,0.004,-0.019,0.003,0.065,0.058,0.004,-0.032,0.023,-0.016,0.03,-0.009,-0.022,-0.026,0.057,-0.013,0.002,0.004,-0.059,-0.047,0.084,0.085,0.048,-0.008,0.11,0.041,-0.018,0.071,-0.022,-0.067,0.015,-0.031,0.037,-0.034,0.032,0.121,0.063,0.003,-0.016,-0.007,0.011,0.093,0.056,-0.054,0.028,0.014,-0.008,-0.102,-0.072,-0.042,0.025,0.005,-0.005,-0.083,-0.008,0.018,-0.076,0.07,0.03,0.003,-0.029,0.021,0.016,0.036,-0.101,0.194,-0.01,-0.014,0.07,-0.004,0.001,-0.087,0.001,-0.0,0.02,0.0,-0.061,-0.108,-0.039,0.068,-0.015,0.033,0.008,0.044,0.016,-0.017,-0.034,-0.018,0.023,-0.018,-0.031,-0.068,0.021,0.0,-0.006,0.032,-0.019,0.019,-0.004,0.063,-0.018,-0.057,0.021,-0.054,-0.047,0.035,-0.113,-0.005,0.065,0.033,-0.018,0.055,-0.033,0.01,-0.095,0.008,0.008,0.053,-0.03,-0.036,0.068,-0.128,-0.011,0.034,-0.022,0.01,-0.012,0.033,-0.016,0.127,0.081,-0.028,-0.07,0.004,-0.067,0.063,-0.056,0.025,-0.014,0.094,-0.012,-0.016,0.065,0.045,0.082,0.001,-0.023,0.014,-0.04,-0.002,0.024,0.001,0.03,0.051,-0.017,-0.071,0.108,-0.028,0.004,-0.048,-0.026,0.041,-0.038,0.05,0.002,-0.027,-0.005,0.019,-0.045,-0.077,-0.16,0.021,0.05,-0.068,0.069,-0.045,0.041,-0.091,-0.024,0.025,-0.052,-0.046,0.066,-0.114,-0.002,0.004,0.063,-0.056,-0.004,0.0,0.071,0.08,0.022,-0.087,-0.02,-0.078,0.002,0.081,-0.038,-0.001,-0.072,0.003,0.014,0.005,0.022,-0.008,0.094,0.011,0.068,-0.013,-0.015,-0.046,0.055,0.013,-0.004,-0.001,-0.015,0.01,-0.014,0.013,-0.036,-0.007,-0.07,-0.061,-0.08,0.018,0.005,-0.001,-0.017,0.027,0.031,-0.023,0.001,0.167,-0.007,-0.031,0.035,0.032,-0.009,0.122,-0.037,-0.032,-0.011,0.018,-0.042,0.051,-0.002,-0.081,0.06,-0.009,0.061,0.065,-0.037,0.076,0.05,0.083,-0.026,0.034,-0.097,-0.016,0.116,0.026,-0.173,0.011,0.051,-0.055,0.013,0.045,-0.017,-0.121,-0.071,-0.025,0.075,-0.031,0.047,0.062,0.05,0.101,-0.036,-0.018,0.051,-0.072,0.004,-0.023,0.019,0.0,-0.024,0.073,0.018,-0.063,0.079,0.012,-0.076,-0.006,-0.009,0.002,-0.025,0.063,-0.011,0.104,0.004,0.025,0.009,-0.071,-0.032,-0.051,-0.096,-0.072,-0.116,-0.06,-0.035,-0.021,0.016,0.045,0.014,0.036,-0.03,0.009,-0.091,-0.045,0.02,-0.105,-0.006,0.046,-0.028,-0.116,-0.078,-0.013,0.019,0.004,-0.05,0.023,0.046,-0.03,-0.021,0.001,0.022,0.02,-0.015,0.059,0.132,0.022,-0.01,-0.003,-0.002,0.021,0.052,-0.023,0.017,0.009],[-0.009,-0.0,-0.035,-0.002,-0.044,-0.063,0.1,0.03,0.052,-0.06,-0.027,0.012,0.03,-0.04,-0.013,0.023,-0.028,0.015,-0.066,-0.032,0.052,0.028,0.063,0.037,-0.005,-0.024,0.006,0.008,0.014,-0.007,-0.042,-0.018,0.012,-0.061,-0.03,0.004,-0.019,0.003,0.065,0.058,0.004,-0.032,0.023,-0.016,0.03,-0.009,-0.022,-0.026,0.057,-0.013,0.002,0.004,-0.059,-0.047,0.084,0.085,0.048,-0.008,0.11,0.041,-0.018,0.071,-0.022,-0.067,0.015,-0.031,0.037,-0.034,0.032,0.121,0.063,0.003,-0.016,-0.007,0.011,0.093,0.056,-0.054,0.028,0.014,-0.008,-0.102,-0.072,-0.042,0.025,0.005,-0.005,-0.083,-0.008,0.018,-0.076,0.07,0.03,0.003,-0.029,0.021,0.016,0.036,-0.101,0.194,-0.01,-0.014,0.07,-0.004,0.001,-0.087,0.001,-0.0,0.02,0.0,-0.061,-0.108,-0.039,0.068,-0.015,0.033,0.008,0.044,0.016,-0.017,-0.034,-0.018,0.023,-0.018,-0.031,-0.068,0.021,0.0,-0.006,0.032,-0.019,0.019,-0.004,0.063,-0.018,-0.057,0.021,-0.054,-0.047,0.035,-0.113,-0.005,0.065,0.033,-0.018,0.055,-0.033,0.01,-0.095,0.008,0.008,0.053,-0.03,-0.036,0.068,-0.128,-0.011,0.034,-0.022,0.01,-0.012,0.033,-0.016,0.127,0.081,-0.028,-0.07,0.004,-0.067,0.063,-0.056,0.025,-0.014,0.094,-0.012,-0.016,0.065,0.045,0.082,0.001,-0.023,0.014,-0.04,-0.002,0.024,0.001,0.03,0.051,-0.017,-0.071,0.108,-0.028,0.004,-0.048,-0.026,0.041,-0.038,0.05,0.002,-0.027,-0.005,0.019,-0.045,-0.077,-0.16,0.021,0.05,-0.068,0.069,-0.045,0.041,-0.091,-0.024,0.025,-0.052,-0.046,0.066,-0.114,-0.002,0.004,0.063,-0.056,-0.004,0.0,0.071,0.08,0.022,-0.087,-0.02,-0.078,0.002,0.081,-0.038,-0.001,-0.072,0.003,0.014,0.005,0.022,-0.008,0.094,0.011,0.068,-0.013,-0.015,-0.046,0.055,0.013,-0.004,-0.001,-0.015,0.01,-0.014,0.013,-0.036,-0.007,-0.07,-0.061,-0.08,0.018,0.005,-0.001,-0.017,0.027,0.031,-0.023,0.001,0.167,-0.007,-0.031,0.035,0.032,-0.009,0.122,-0.037,-0.032,-0.011,0.018,-0.042,0.051,-0.002,-0.081,0.06,-0.009,0.061,0.065,-0.037,0.076,0.05,0.083,-0.026,0.034,-0.097,-0.016,0.116,0.026,-0.173,0.011,0.051,-0.055,0.013,0.045,-0.017,-0.121,-0.071,-0.025,0.075,-0.031,0.047,0.062,0.05,0.101,-0.036,-0.018,0.051,-0.072,0.004,-0.023,0.019,0.0,-0.024,0.073,0.018,-0.063,0.079,0.012,-0.076,-0.006,-0.009,0.002,-0.025,0.063,-0.011,0.104,0.004,0.025,0.009,-0.071,-0.032,-0.051,-0.096,-0.072,-0.116,-0.06,-0.035,-0.021,0.016,0.045,0.014,0.036,-0.03,0.009,-0.091,-0.045,0.02,-0.105,-0.006,0.046,-0.028,-0.116,-0.078,-0.013,0.019,0.004,-0.05,0.023,0.046,-0.03,-0.021,0.001,0.022,0.02,-0.015,0.059,0.132,0.022,-0.01,-0.003,-0.002,0.021,0.052,-0.023,0.017,0.009],[-0.009,-0.0,-0.035,-0.002,-0.044,-0.063,0.1,0.03,0.052,-0.06,-0.027,0.012,0.03,-0.04,-0.013,0.023,-0.028,0.015,-0.066,-0.032,0.052,0.028,0.063,0.037,-0.005,-0.024,0.006,0.008,0.014,-0.007,-0.042,-0.018,0.012,-0.061,-0.03,0.004,-0.019,0.003,0.065,0.058,0.004,-0.032,0.023,-0.016,0.03,-0.009,-0.022,-0.026,0.057,-0.013,0.002,0.004,-0.059,-0.047,0.084,0.085,0.048,-0.008,0.11,0.041,-0.018,0.071,-0.022,-0.067,0.015,-0.031,0.037,-0.034,0.032,0.121,0.063,0.003,-0.016,-0.007,0.011,0.093,0.056,-0.054,0.028,0.014,-0.008,-0.102,-0.072,-0.042,0.025,0.005,-0.005,-0.083,-0.008,0.018,-0.076,0.07,0.03,0.003,-0.029,0.021,0.016,0.036,-0.101,0.194,-0.01,-0.014,0.07,-0.004,0.001,-0.087,0.001,-0.0,0.02,0.0,-0.061,-0.108,-0.039,0.068,-0.015,0.033,0.008,0.044,0.016,-0.017,-0.034,-0.018,0.023,-0.018,-0.031,-0.068,0.021,0.0,-0.006,0.032,-0.019,0.019,-0.004,0.063,-0.018,-0.057,0.021,-0.054,-0.047,0.035,-0.113,-0.005,0.065,0.033,-0.018,0.055,-0.033,0.01,-0.095,0.008,0.008,0.053,-0.03,-0.036,0.068,-0.128,-0.011,0.034,-0.022,0.01,-0.012,0.033,-0.016,0.127,0.081,-0.028,-0.07,0.004,-0.067,0.063,-0.056,0.025,-0.014,0.094,-0.012,-0.016,0.065,0.045,0.082,0.001,-0.023,0.014,-0.04,-0.002,0.024,0.001,0.03,0.051,-0.017,-0.071,0.108,-0.028,0.004,-0.048,-0.026,0.041,-0.038,0.05,0.002,-0.027,-0.005,0.019,-0.045,-0.077,-0.16,0.021,0.05,-0.068,0.069,-0.045,0.041,-0.091,-0.024,0.025,-0.052,-0.046,0.066,-0.114,-0.002,0.004,0.063,-0.056,-0.004,0.0,0.071,0.08,0.022,-0.087,-0.02,-0.078,0.002,0.081,-0.038,-0.001,-0.072,0.003,0.014,0.005,0.022,-0.008,0.094,0.011,0.068,-0.013,-0.015,-0.046,0.055,0.013,-0.004,-0.001,-0.015,0.01,-0.014,0.013,-0.036,-0.007,-0.07,-0.061,-0.08,0.018,0.005,-0.001,-0.017,0.027,0.031,-0.023,0.001,0.167,-0.007,-0.031,0.035,0.032,-0.009,0.122,-0.037,-0.032,-0.011,0.018,-0.042,0.051,-0.002,-0.081,0.06,-0.009,0.061,0.065,-0.037,0.076,0.05,0.083,-0.026,0.034,-0.097,-0.016,0.116,0.026,-0.173,0.011,0.051,-0.055,0.013,0.045,-0.017,-0.121,-0.071,-0.025,0.075,-0.031,0.047,0.062,0.05,0.101,-0.036,-0.018,0.051,-0.072,0.004,-0.023,0.019,0.0,-0.024,0.073,0.018,-0.063,0.079,0.012,-0.076,-0.006,-0.009,0.002,-0.025,0.063,-0.011,0.104,0.004,0.025,0.009,-0.071,-0.032,-0.051,-0.096,-0.072,-0.116,-0.06,-0.035,-0.021,0.016,0.045,0.014,0.036,-0.03,0.009,-0.091,-0.045,0.02,-0.105,-0.006,0.046,-0.028,-0.116,-0.078,-0.013,0.019,0.004,-0.05,0.023,0.046,-0.03,-0.021,0.001,0.022,0.02,-0.015,0.059,0.132,0.022,-0.01,-0.003,-0.002,0.021,0.052,-0.023,0.017,0.009],[-0.003,-0.038,-0.045,0.046,-0.102,-0.023,0.163,0.003,0.041,-0.042,-0.026,-0.083,0.078,-0.014,-0.057,-0.018,0.034,0.022,-0.025,-0.026,-0.071,0.043,-0.062,0.067,-0.012,0.032,0.025,-0.009,-0.046,-0.135,0.026,0.067,0.036,-0.041,0.038,-0.023,0.021,0.026,0.025,-0.019,-0.01,-0.081,0.029,0.08,-0.012,-0.001,0.067,-0.012,0.044,-0.042,-0.009,-0.039,-0.065,0.078,0.041,0.087,-0.023,0.046,0.056,-0.025,-0.047,0.068,0.01,0.019,0.0,0.036,-0.061,-0.014,-0.012,-0.019,0.033,0.033,0.023,0.072,0.037,0.016,0.064,0.038,0.129,-0.029,-0.119,-0.086,-0.025,-0.006,-0.011,0.028,-0.016,-0.061,-0.08,0.019,0.026,0.045,0.058,0.002,-0.123,-0.047,-0.0,-0.029,-0.029,0.163,0.016,0.011,-0.031,-0.029,0.05,-0.093,0.036,-0.011,-0.008,0.014,0.003,-0.074,-0.017,0.004,0.039,-0.053,-0.025,0.031,0.047,-0.023,-0.009,0.08,-0.031,-0.049,-0.15,0.012,-0.007,0.0,0.02,-0.068,0.069,0.07,-0.043,0.048,-0.092,-0.012,-0.027,0.017,-0.026,0.008,-0.006,0.02,0.132,0.001,-0.086,-0.017,-0.021,0.039,-0.083,0.04,-0.021,0.122,-0.01,-0.053,0.057,-0.07,-0.041,0.062,0.004,-0.033,-0.041,-0.018,0.008,-0.074,0.024,-0.012,-0.052,-0.039,0.011,-0.062,-0.087,-0.064,0.048,0.061,0.074,0.073,-0.044,0.04,-0.002,-0.034,0.037,0.051,-0.001,-0.005,0.016,0.009,-0.001,0.12,0.061,0.094,0.037,-0.052,-0.037,-0.028,0.016,-0.075,-0.006,-0.128,-0.031,-0.026,0.061,0.017,-0.038,0.021,-0.045,-0.055,-0.066,-0.007,-0.03,-0.019,0.044,-0.018,-0.036,0.04,-0.007,-0.102,0.008,0.049,-0.135,-0.006,0.079,-0.002,-0.039,0.0,0.029,-0.087,-0.023,0.024,-0.036,-0.038,0.027,-0.04,0.064,0.028,-0.056,-0.043,0.044,-0.041,0.033,0.004,0.015,0.007,-0.019,0.056,-0.04,0.012,-0.089,0.063,-0.071,0.088,0.027,0.014,0.09,0.006,0.013,0.017,-0.016,-0.001,-0.082,0.079,0.053,0.0,-0.03,-0.044,-0.061,0.033,-0.03,0.081,0.05,0.013,0.036,0.029,-0.01,0.048,-0.106,-0.021,-0.049,0.043,-0.047,-0.043,-0.037,0.027,0.098,-0.017,0.04,0.024,0.049,0.036,-0.005,-0.005,-0.01,-0.002,-0.05,-0.049,0.105,0.077,-0.073,0.042,0.028,0.074,-0.001,0.002,-0.05,0.087,-0.02,0.029,-0.018,0.066,-0.027,-0.015,0.039,0.031,0.001,-0.055,-0.018,0.021,-0.031,-0.061,0.029,0.0,0.014,0.031,0.003,0.033,0.071,-0.007,0.077,0.067,0.014,0.004,0.055,0.038,-0.009,0.091,0.073,0.028,-0.006,-0.04,-0.008,0.027,0.006,0.0,0.016,-0.056,-0.052,-0.055,-0.032,0.024,0.071,0.023,0.055,0.107,-0.057,-0.124,0.001,0.004,-0.013,0.077,0.02,-0.007,-0.029,-0.037,0.006,-0.052,-0.046,-0.113,0.037,0.002,-0.02,-0.036,-0.059,0.1,0.042,0.007,0.068,0.047,-0.036,-0.011,-0.078,0.084,0.033,-0.053,0.011,-0.054],[-0.003,-0.038,-0.045,0.046,-0.102,-0.023,0.163,0.003,0.041,-0.042,-0.026,-0.083,0.078,-0.014,-0.057,-0.018,0.034,0.022,-0.025,-0.026,-0.071,0.043,-0.062,0.067,-0.012,0.032,0.025,-0.009,-0.046,-0.135,0.026,0.067,0.036,-0.041,0.038,-0.023,0.021,0.026,0.025,-0.019,-0.01,-0.081,0.029,0.08,-0.012,-0.001,0.067,-0.012,0.044,-0.042,-0.009,-0.039,-0.065,0.078,0.041,0.087,-0.023,0.046,0.056,-0.025,-0.047,0.068,0.01,0.019,0.0,0.036,-0.061,-0.014,-0.012,-0.019,0.033,0.033,0.023,0.072,0.037,0.016,0.064,0.038,0.129,-0.029,-0.119,-0.086,-0.025,-0.006,-0.011,0.028,-0.016,-0.061,-0.08,0.019,0.026,0.045,0.058,0.002,-0.123,-0.047,-0.0,-0.029,-0.029,0.163,0.016,0.011,-0.031,-0.029,0.05,-0.093,0.036,-0.011,-0.008,0.014,0.003,-0.074,-0.017,0.004,0.039,-0.053,-0.025,0.031,0.047,-0.023,-0.009,0.08,-0.031,-0.049,-0.15,0.012,-0.007,0.0,0.02,-0.068,0.069,0.07,-0.043,0.048,-0.092,-0.012,-0.027,0.017,-0.026,0.008,-0.006,0.02,0.132,0.001,-0.086,-0.017,-0.021,0.039,-0.083,0.04,-0.021,0.122,-0.01,-0.053,0.057,-0.07,-0.041,0.062,0.004,-0.033,-0.041,-0.018,0.008,-0.074,0.024,-0.012,-0.052,-0.039,0.011,-0.062,-0.087,-0.064,0.048,0.061,0.074,0.073,-0.044,0.04,-0.002,-0.034,0.037,0.051,-0.001,-0.005,0.016,0.009,-0.001,0.12,0.061,0.094,0.037,-0.052,-0.037,-0.028,0.016,-0.075,-0.006,-0.128,-0.031,-0.026,0.061,0.017,-0.038,0.021,-0.045,-0.055,-0.066,-0.007,-0.03,-0.019,0.044,-0.018,-0.036,0.04,-0.007,-0.102,0.008,0.049,-0.135,-0.006,0.079,-0.002,-0.039,0.0,0.029,-0.087,-0.023,0.024,-0.036,-0.038,0.027,-0.04,0.064,0.028,-0.056,-0.043,0.044,-0.041,0.033,0.004,0.015,0.007,-0.019,0.056,-0.04,0.012,-0.089,0.063,-0.071,0.088,0.027,0.014,0.09,0.006,0.013,0.017,-0.016,-0.001,-0.082,0.079,0.053,0.0,-0.03,-0.044,-0.061,0.033,-0.03,0.081,0.05,0.013,0.036,0.029,-0.01,0.048,-0.106,-0.021,-0.049,0.043,-0.047,-0.043,-0.037,0.027,0.098,-0.017,0.04,0.024,0.049,0.036,-0.005,-0.005,-0.01,-0.002,-0.05,-0.049,0.105,0.077,-0.073,0.042,0.028,0.074,-0.001,0.002,-0.05,0.087,-0.02,0.029,-0.018,0.066,-0.027,-0.015,0.039,0.031,0.001,-0.055,-0.018,0.021,-0.031,-0.061,0.029,0.0,0.014,0.031,0.003,0.033,0.071,-0.007,0.077,0.067,0.014,0.004,0.055,0.038,-0.009,0.091,0.073,0.028,-0.006,-0.04,-0.008,0.027,0.006,0.0,0.016,-0.056,-0.052,-0.055,-0.032,0.024,0.071,0.023,0.055,0.107,-0.057,-0.124,0.001,0.004,-0.013,0.077,0.02,-0.007,-0.029,-0.037,0.006,-0.052,-0.046,-0.113,0.037,0.002,-0.02,-0.036,-0.059,0.1,0.042,0.007,0.068,0.047,-0.036,-0.011,-0.078,0.084,0.033,-0.053,0.011,-0.054],[-0.003,-0.038,-0.045,0.046,-0.102,-0.023,0.163,0.003,0.041,-0.042,-0.026,-0.083,0.078,-0.014,-0.057,-0.018,0.034,0.022,-0.025,-0.026,-0.071,0.043,-0.062,0.067,-0.012,0.032,0.025,-0.009,-0.046,-0.135,0.026,0.067,0.036,-0.041,0.038,-0.023,0.021,0.026,0.025,-0.019,-0.01,-0.081,0.029,0.08,-0.012,-0.001,0.067,-0.012,0.044,-0.042,-0.009,-0.039,-0.065,0.078,0.041,0.087,-0.023,0.046,0.056,-0.025,-0.047,0.068,0.01,0.019,0.0,0.036,-0.061,-0.014,-0.012,-0.019,0.033,0.033,0.023,0.072,0.037,0.016,0.064,0.038,0.129,-0.029,-0.119,-0.086,-0.025,-0.006,-0.011,0.028,-0.016,-0.061,-0.08,0.019,0.026,0.045,0.058,0.002,-0.123,-0.047,-0.0,-0.029,-0.029,0.163,0.016,0.011,-0.031,-0.029,0.05,-0.093,0.036,-0.011,-0.008,0.014,0.003,-0.074,-0.017,0.004,0.039,-0.053,-0.025,0.031,0.047,-0.023,-0.009,0.08,-0.031,-0.049,-0.15,0.012,-0.007,0.0,0.02,-0.068,0.069,0.07,-0.043,0.048,-0.092,-0.012,-0.027,0.017,-0.026,0.008,-0.006,0.02,0.132,0.001,-0.086,-0.017,-0.021,0.039,-0.083,0.04,-0.021,0.122,-0.01,-0.053,0.057,-0.07,-0.041,0.062,0.004,-0.033,-0.041,-0.018,0.008,-0.074,0.024,-0.012,-0.052,-0.039,0.011,-0.062,-0.087,-0.064,0.048,0.061,0.074,0.073,-0.044,0.04,-0.002,-0.034,0.037,0.051,-0.001,-0.005,0.016,0.009,-0.001,0.12,0.061,0.094,0.037,-0.052,-0.037,-0.028,0.016,-0.075,-0.006,-0.128,-0.031,-0.026,0.061,0.017,-0.038,0.021,-0.045,-0.055,-0.066,-0.007,-0.03,-0.019,0.044,-0.018,-0.036,0.04,-0.007,-0.102,0.008,0.049,-0.135,-0.006,0.079,-0.002,-0.039,0.0,0.029,-0.087,-0.023,0.024,-0.036,-0.038,0.027,-0.04,0.064,0.028,-0.056,-0.043,0.044,-0.041,0.033,0.004,0.015,0.007,-0.019,0.056,-0.04,0.012,-0.089,0.063,-0.071,0.088,0.027,0.014,0.09,0.006,0.013,0.017,-0.016,-0.001,-0.082,0.079,0.053,0.0,-0.03,-0.044,-0.061,0.033,-0.03,0.081,0.05,0.013,0.036,0.029,-0.01,0.048,-0.106,-0.021,-0.049,0.043,-0.047,-0.043,-0.037,0.027,0.098,-0.017,0.04,0.024,0.049,0.036,-0.005,-0.005,-0.01,-0.002,-0.05,-0.049,0.105,0.077,-0.073,0.042,0.028,0.074,-0.001,0.002,-0.05,0.087,-0.02,0.029,-0.018,0.066,-0.027,-0.015,0.039,0.031,0.001,-0.055,-0.018,0.021,-0.031,-0.061,0.029,0.0,0.014,0.031,0.003,0.033,0.071,-0.007,0.077,0.067,0.014,0.004,0.055,0.038,-0.009,0.091,0.073,0.028,-0.006,-0.04,-0.008,0.027,0.006,0.0,0.016,-0.056,-0.052,-0.055,-0.032,0.024,0.071,0.023,0.055,0.107,-0.057,-0.124,0.001,0.004,-0.013,0.077,0.02,-0.007,-0.029,-0.037,0.006,-0.052,-0.046,-0.113,0.037,0.002,-0.02,-0.036,-0.059,0.1,0.042,0.007,0.068,0.047,-0.036,-0.011,-0.078,0.084,0.033,-0.053,0.011,-0.054],[-0.009,-0.0,-0.035,-0.002,-0.044,-0.063,0.1,0.03,0.052,-0.06,-0.027,0.012,0.03,-0.04,-0.013,0.023,-0.028,0.015,-0.066,-0.032,0.052,0.028,0.063,0.037,-0.005,-0.024,0.006,0.008,0.014,-0.007,-0.042,-0.018,0.012,-0.061,-0.03,0.004,-0.019,0.003,0.065,0.058,0.004,-0.032,0.023,-0.016,0.03,-0.009,-0.022,-0.026,0.057,-0.013,0.002,0.004,-0.059,-0.047,0.084,0.085,0.048,-0.008,0.11,0.041,-0.018,0.071,-0.022,-0.067,0.015,-0.031,0.037,-0.034,0.032,0.121,0.063,0.003,-0.016,-0.007,0.011,0.093,0.056,-0.054,0.028,0.014,-0.008,-0.102,-0.072,-0.042,0.025,0.005,-0.005,-0.083,-0.008,0.018,-0.076,0.07,0.03,0.003,-0.029,0.021,0.016,0.036,-0.101,0.194,-0.01,-0.014,0.07,-0.004,0.001,-0.087,0.001,-0.0,0.02,0.0,-0.061,-0.108,-0.039,0.068,-0.015,0.033,0.008,0.044,0.016,-0.017,-0.034,-0.018,0.023,-0.018,-0.031,-0.068,0.021,0.0,-0.006,0.032,-0.019,0.019,-0.004,0.063,-0.018,-0.057,0.021,-0.054,-0.047,0.035,-0.113,-0.005,0.065,0.033,-0.018,0.055,-0.033,0.01,-0.095,0.008,0.008,0.053,-0.03,-0.036,0.068,-0.128,-0.011,0.034,-0.022,0.01,-0.012,0.033,-0.016,0.127,0.081,-0.028,-0.07,0.004,-0.067,0.063,-0.056,0.025,-0.014,0.094,-0.012,-0.016,0.065,0.045,0.082,0.001,-0.023,0.014,-0.04,-0.002,0.024,0.001,0.03,0.051,-0.017,-0.071,0.108,-0.028,0.004,-0.048,-0.026,0.041,-0.038,0.05,0.002,-0.027,-0.005,0.019,-0.045,-0.077,-0.16,0.021,0.05,-0.068,0.069,-0.045,0.041,-0.091,-0.024,0.025,-0.052,-0.046,0.066,-0.114,-0.002,0.004,0.063,-0.056,-0.004,0.0,0.071,0.08,0.022,-0.087,-0.02,-0.078,0.002,0.081,-0.038,-0.001,-0.072,0.003,0.014,0.005,0.022,-0.008,0.094,0.011,0.068,-0.013,-0.015,-0.046,0.055,0.013,-0.004,-0.001,-0.015,0.01,-0.014,0.013,-0.036,-0.007,-0.07,-0.061,-0.08,0.018,0.005,-0.001,-0.017,0.027,0.031,-0.023,0.001,0.167,-0.007,-0.031,0.035,0.032,-0.009,0.122,-0.037,-0.032,-0.011,0.018,-0.042,0.051,-0.002,-0.081,0.06,-0.009,0.061,0.065,-0.037,0.076,0.05,0.083,-0.026,0.034,-0.097,-0.016,0.116,0.026,-0.173,0.011,0.051,-0.055,0.013,0.045,-0.017,-0.121,-0.071,-0.025,0.075,-0.031,0.047,0.062,0.05,0.101,-0.036,-0.018,0.051,-0.072,0.004,-0.023,0.019,0.0,-0.024,0.073,0.018,-0.063,0.079,0.012,-0.076,-0.006,-0.009,0.002,-0.025,0.063,-0.011,0.104,0.004,0.025,0.009,-0.071,-0.032,-0.051,-0.096,-0.072,-0.116,-0.06,-0.035,-0.021,0.016,0.045,0.014,0.036,-0.03,0.009,-0.091,-0.045,0.02,-0.105,-0.006,0.046,-0.028,-0.116,-0.078,-0.013,0.019,0.004,-0.05,0.023,0.046,-0.03,-0.021,0.001,0.022,0.02,-0.015,0.059,0.132,0.022,-0.01,-0.003,-0.002,0.021,0.052,-0.023,0.017,0.009],[-0.009,-0.0,-0.035,-0.002,-0.044,-0.063,0.1,0.03,0.052,-0.06,-0.027,0.012,0.03,-0.04,-0.013,0.023,-0.028,0.015,-0.066,-0.032,0.052,0.028,0.063,0.037,-0.005,-0.024,0.006,0.008,0.014,-0.007,-0.042,-0.018,0.012,-0.061,-0.03,0.004,-0.019,0.003,0.065,0.058,0.004,-0.032,0.023,-0.016,0.03,-0.009,-0.022,-0.026,0.057,-0.013,0.002,0.004,-0.059,-0.047,0.084,0.085,0.048,-0.008,0.11,0.041,-0.018,0.071,-0.022,-0.067,0.015,-0.031,0.037,-0.034,0.032,0.121,0.063,0.003,-0.016,-0.007,0.011,0.093,0.056,-0.054,0.028,0.014,-0.008,-0.102,-0.072,-0.042,0.025,0.005,-0.005,-0.083,-0.008,0.018,-0.076,0.07,0.03,0.003,-0.029,0.021,0.016,0.036,-0.101,0.194,-0.01,-0.014,0.07,-0.004,0.001,-0.087,0.001,-0.0,0.02,0.0,-0.061,-0.108,-0.039,0.068,-0.015,0.033,0.008,0.044,0.016,-0.017,-0.034,-0.018,0.023,-0.018,-0.031,-0.068,0.021,0.0,-0.006,0.032,-0.019,0.019,-0.004,0.063,-0.018,-0.057,0.021,-0.054,-0.047,0.035,-0.113,-0.005,0.065,0.033,-0.018,0.055,-0.033,0.01,-0.095,0.008,0.008,0.053,-0.03,-0.036,0.068,-0.128,-0.011,0.034,-0.022,0.01,-0.012,0.033,-0.016,0.127,0.081,-0.028,-0.07,0.004,-0.067,0.063,-0.056,0.025,-0.014,0.094,-0.012,-0.016,0.065,0.045,0.082,0.001,-0.023,0.014,-0.04,-0.002,0.024,0.001,0.03,0.051,-0.017,-0.071,0.108,-0.028,0.004,-0.048,-0.026,0.041,-0.038,0.05,0.002,-0.027,-0.005,0.019,-0.045,-0.077,-0.16,0.021,0.05,-0.068,0.069,-0.045,0.041,-0.091,-0.024,0.025,-0.052,-0.046,0.066,-0.114,-0.002,0.004,0.063,-0.056,-0.004,0.0,0.071,0.08,0.022,-0.087,-0.02,-0.078,0.002,0.081,-0.038,-0.001,-0.072,0.003,0.014,0.005,0.022,-0.008,0.094,0.011,0.068,-0.013,-0.015,-0.046,0.055,0.013,-0.004,-0.001,-0.015,0.01,-0.014,0.013,-0.036,-0.007,-0.07,-0.061,-0.08,0.018,0.005,-0.001,-0.017,0.027,0.031,-0.023,0.001,0.167,-0.007,-0.031,0.035,0.032,-0.009,0.122,-0.037,-0.032,-0.011,0.018,-0.042,0.051,-0.002,-0.081,0.06,-0.009,0.061,0.065,-0.037,0.076,0.05,0.083,-0.026,0.034,-0.097,-0.016,0.116,0.026,-0.173,0.011,0.051,-0.055,0.013,0.045,-0.017,-0.121,-0.071,-0.025,0.075,-0.031,0.047,0.062,0.05,0.101,-0.036,-0.018,0.051,-0.072,0.004,-0.023,0.019,0.0,-0.024,0.073,0.018,-0.063,0.079,0.012,-0.076,-0.006,-0.009,0.002,-0.025,0.063,-0.011,0.104,0.004,0.025,0.009,-0.071,-0.032,-0.051,-0.096,-0.072,-0.116,-0.06,-0.035,-0.021,0.016,0.045,0.014,0.036,-0.03,0.009,-0.091,-0.045,0.02,-0.105,-0.006,0.046,-0.028,-0.116,-0.078,-0.013,0.019,0.004,-0.05,0.023,0.046,-0.03,-0.021,0.001,0.022,0.02,-0.015,0.059,0.132,0.022,-0.01,-0.003,-0.002,0.021,0.052,-0.023,0.017,0.009],[-0.009,-0.0,-0.035,-0.002,-0.044,-0.063,0.1,0.03,0.052,-0.06,-0.027,0.012,0.03,-0.04,-0.013,0.023,-0.028,0.015,-0.066,-0.032,0.052,0.028,0.063,0.037,-0.005,-0.024,0.006,0.008,0.014,-0.007,-0.042,-0.018,0.012,-0.061,-0.03,0.004,-0.019,0.003,0.065,0.058,0.004,-0.032,0.023,-0.016,0.03,-0.009,-0.022,-0.026,0.057,-0.013,0.002,0.004,-0.059,-0.047,0.084,0.085,0.048,-0.008,0.11,0.041,-0.018,0.071,-0.022,-0.067,0.015,-0.031,0.037,-0.034,0.032,0.121,0.063,0.003,-0.016,-0.007,0.011,0.093,0.056,-0.054,0.028,0.014,-0.008,-0.102,-0.072,-0.042,0.025,0.005,-0.005,-0.083,-0.008,0.018,-0.076,0.07,0.03,0.003,-0.029,0.021,0.016,0.036,-0.101,0.194,-0.01,-0.014,0.07,-0.004,0.001,-0.087,0.001,-0.0,0.02,0.0,-0.061,-0.108,-0.039,0.068,-0.015,0.033,0.008,0.044,0.016,-0.017,-0.034,-0.018,0.023,-0.018,-0.031,-0.068,0.021,0.0,-0.006,0.032,-0.019,0.019,-0.004,0.063,-0.018,-0.057,0.021,-0.054,-0.047,0.035,-0.113,-0.005,0.065,0.033,-0.018,0.055,-0.033,0.01,-0.095,0.008,0.008,0.053,-0.03,-0.036,0.068,-0.128,-0.011,0.034,-0.022,0.01,-0.012,0.033,-0.016,0.127,0.081,-0.028,-0.07,0.004,-0.067,0.063,-0.056,0.025,-0.014,0.094,-0.012,-0.016,0.065,0.045,0.082,0.001,-0.023,0.014,-0.04,-0.002,0.024,0.001,0.03,0.051,-0.017,-0.071,0.108,-0.028,0.004,-0.048,-0.026,0.041,-0.038,0.05,0.002,-0.027,-0.005,0.019,-0.045,-0.077,-0.16,0.021,0.05,-0.068,0.069,-0.045,0.041,-0.091,-0.024,0.025,-0.052,-0.046,0.066,-0.114,-0.002,0.004,0.063,-0.056,-0.004,0.0,0.071,0.08,0.022,-0.087,-0.02,-0.078,0.002,0.081,-0.038,-0.001,-0.072,0.003,0.014,0.005,0.022,-0.008,0.094,0.011,0.068,-0.013,-0.015,-0.046,0.055,0.013,-0.004,-0.001,-0.015,0.01,-0.014,0.013,-0.036,-0.007,-0.07,-0.061,-0.08,0.018,0.005,-0.001,-0.017,0.027,0.031,-0.023,0.001,0.167,-0.007,-0.031,0.035,0.032,-0.009,0.122,-0.037,-0.032,-0.011,0.018,-0.042,0.051,-0.002,-0.081,0.06,-0.009,0.061,0.065,-0.037,0.076,0.05,0.083,-0.026,0.034,-0.097,-0.016,0.116,0.026,-0.173,0.011,0.051,-0.055,0.013,0.045,-0.017,-0.121,-0.071,-0.025,0.075,-0.031,0.047,0.062,0.05,0.101,-0.036,-0.018,0.051,-0.072,0.004,-0.023,0.019,0.0,-0.024,0.073,0.018,-0.063,0.079,0.012,-0.076,-0.006,-0.009,0.002,-0.025,0.063,-0.011,0.104,0.004,0.025,0.009,-0.071,-0.032,-0.051,-0.096,-0.072,-0.116,-0.06,-0.035,-0.021,0.016,0.045,0.014,0.036,-0.03,0.009,-0.091,-0.045,0.02,-0.105,-0.006,0.046,-0.028,-0.116,-0.078,-0.013,0.019,0.004,-0.05,0.023,0.046,-0.03,-0.021,0.001,0.022,0.02,-0.015,0.059,0.132,0.022,-0.01,-0.003,-0.002,0.021,0.052,-0.023,0.017,0.009]]
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Ollama::Documents::MemoryCache do
|
4
|
-
let :prefix do
|
5
|
-
'test-'
|
6
|
-
end
|
7
|
-
|
8
|
-
let :cache do
|
9
|
-
described_class.new prefix:
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'can be instantiated' do
|
13
|
-
expect(cache).to be_a described_class
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'can get/set a key' do
|
17
|
-
key, value = 'foo', { test: true }
|
18
|
-
expect {
|
19
|
-
cache[key] = value
|
20
|
-
}.to change {
|
21
|
-
cache[key]
|
22
|
-
}.from(nil).to(value)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'can determine if key exists' do
|
26
|
-
key, value = 'foo', { test: true }
|
27
|
-
expect {
|
28
|
-
cache[key] = value
|
29
|
-
}.to change {
|
30
|
-
cache.key?(key)
|
31
|
-
}.from(false).to(true)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'can set key with different prefixes' do
|
35
|
-
key, value = 'foo', { test: true }
|
36
|
-
expect {
|
37
|
-
cache[key] = value
|
38
|
-
}.to change {
|
39
|
-
cache.size
|
40
|
-
}.from(0).to(1)
|
41
|
-
cache2 = cache.dup
|
42
|
-
cache2.prefix = 'test2-'
|
43
|
-
expect {
|
44
|
-
cache2[key] = value
|
45
|
-
}.to change {
|
46
|
-
cache2.size
|
47
|
-
}.from(0).to(1)
|
48
|
-
expect(cache.size).to eq 1
|
49
|
-
s = 0
|
50
|
-
cache.full_each { s += 1 }
|
51
|
-
expect(s).to eq 2
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'can delete' do
|
55
|
-
key, value = 'foo', { test: true }
|
56
|
-
expect(cache.delete(key)).to be_falsy
|
57
|
-
cache[key] = value
|
58
|
-
expect {
|
59
|
-
expect(cache.delete(key)).to be_truthy
|
60
|
-
}.to change {
|
61
|
-
cache.key?(key)
|
62
|
-
}.from(true).to(false)
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'can iterate over keys, values' do
|
66
|
-
key, value = 'foo', { test: true }
|
67
|
-
cache[key] = value
|
68
|
-
cache.each do |k, v|
|
69
|
-
expect(k).to eq prefix + key
|
70
|
-
expect(v).to eq value
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'returns size' do
|
75
|
-
key, value = 'foo', { test: true }
|
76
|
-
expect {
|
77
|
-
cache[key] = value
|
78
|
-
}.to change {
|
79
|
-
cache.size
|
80
|
-
}.from(0).to(1)
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'can clear' do
|
84
|
-
key, value = 'foo', { test: true }
|
85
|
-
cache[key] = value
|
86
|
-
expect {
|
87
|
-
expect(cache.clear).to eq cache
|
88
|
-
}.to change {
|
89
|
-
cache.size
|
90
|
-
}.from(1).to(0)
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'can iterate over keys under a prefix' do
|
94
|
-
cache['foo'] = 'bar'
|
95
|
-
expect(cache.to_a).to eq [ %W[ #{prefix}foo bar ] ]
|
96
|
-
end
|
97
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Ollama::Documents::RedisBackedMemoryCache do
|
4
|
-
let :prefix do
|
5
|
-
'test-'
|
6
|
-
end
|
7
|
-
|
8
|
-
let :cache do
|
9
|
-
described_class.new prefix: 'test-', url: 'something'
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'raises ArgumentError if url is missing' do
|
13
|
-
expect {
|
14
|
-
described_class.new prefix:, url: nil
|
15
|
-
}.to raise_error ArgumentError
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'test redis interactions' do
|
19
|
-
let :data do
|
20
|
-
cache.instance_eval { @data }
|
21
|
-
end
|
22
|
-
|
23
|
-
let :redis_cache do
|
24
|
-
cache.instance_eval { @redis_cache }
|
25
|
-
end
|
26
|
-
|
27
|
-
let :redis do
|
28
|
-
double('Redis')
|
29
|
-
end
|
30
|
-
|
31
|
-
before do
|
32
|
-
allow_any_instance_of(Ollama::Documents::RedisCache).to\
|
33
|
-
receive(:redis).and_return(redis)
|
34
|
-
allow(redis).to receive(:scan_each)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'can be instantiated and initialized' do
|
38
|
-
expect(cache).to be_a described_class
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'defaults to nil object_class' do
|
42
|
-
expect(cache.object_class).to be_nil
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'can be configured with object_class' do
|
46
|
-
object_class = Class.new(JSON::GenericObject)
|
47
|
-
cache = described_class.new(prefix: 'test-', url: 'something', object_class:)
|
48
|
-
expect(cache.object_class).to eq object_class
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'has Redis client' do
|
52
|
-
expect(cache.redis).to eq redis
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'can get a key' do
|
56
|
-
key = 'foo'
|
57
|
-
expect(data).to receive(:[]).with('test-' + key).and_return 666
|
58
|
-
expect(cache[key]).to eq 666
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'can set a value for a key' do
|
62
|
-
key, value = 'foo', { test: true }
|
63
|
-
expect(data).to receive(:[]=).with('test-' + key, { test: true }).and_call_original
|
64
|
-
expect(redis).to receive(:set).with('test-' + key, JSON(value))
|
65
|
-
cache[key] = value
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'can determine if key exists' do
|
69
|
-
key = 'foo'
|
70
|
-
expect(data).to receive(:key?).with('test-' + key).and_return(false, true)
|
71
|
-
expect(cache.key?('foo')).to eq false
|
72
|
-
expect(cache.key?('foo')).to eq true
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'can delete' do
|
76
|
-
key = 'foo'
|
77
|
-
expect(data).to receive(:delete).with('test-' + key)
|
78
|
-
expect(redis).to receive(:del).with('test-' + key)
|
79
|
-
cache.delete(key)
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'can iterate over keys, values' do
|
83
|
-
key, value = 'foo', { 'test' => true }
|
84
|
-
expect(redis).to receive(:set).with('test-' + key, JSON(value))
|
85
|
-
cache[key] = value
|
86
|
-
cache.each do |k, v|
|
87
|
-
expect(k).to eq prefix + key
|
88
|
-
expect(v).to eq value
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'returns size' do
|
93
|
-
expect(cache).to receive(:count).and_return 3
|
94
|
-
expect(cache.size).to eq 3
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'can clear' do
|
98
|
-
expect(redis).to receive(:scan_each).with(match: 'test-*').and_yield(
|
99
|
-
'test-foo'
|
100
|
-
)
|
101
|
-
expect(redis).to receive(:del).with('test-foo')
|
102
|
-
expect(cache.clear).to eq cache
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'can iterate over keys under a prefix' do
|
106
|
-
data['test-foo'] = 'bar'
|
107
|
-
expect(cache.to_a).to eq [ %w[ test-foo bar ] ]
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'can compute prefix with pre' do
|
111
|
-
expect(cache.pre('foo')).to eq 'test-foo'
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'can remove prefix with unpre' do
|
115
|
-
expect(cache.unpre('test-foo')).to eq 'foo'
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|