bx_builder_chain 0.1.15 → 0.1.17

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: 9eb5ff5b21c231a4b2780d308fb4f60e7547f665c01338d309e7e596d8ddcc88
4
- data.tar.gz: 23d0c9b0eaa1e9aac37e51bdad3e4228e7ca110bb74c03a0e3f51444c75e3844
3
+ metadata.gz: 022f97be7d06eac31ca9d9f70f541b9fc3636ae44f7fda16ee72f43e5b86aa69
4
+ data.tar.gz: dbe3501ebd87e3e3f1149b31e66a35bd26649c60c06e5195d87ba98a7c7c7913
5
5
  SHA512:
6
- metadata.gz: 0c6492b7df7f26268d0b950603c945d14b1b75c1bbde0876793dd03b02b7ca66c324d047ad1dd5aebe269a37400bfca7a9bbadab95bcd6e6ee1ac8d5adcc9124
7
- data.tar.gz: 8d959ade792d8f9977219814358b283cb79a105285e3ccc9c6034639f0df61e455aa61746b656d305dc82950f5e7de1eb35ee0f5bfcd3c8c4084f6425ab5c63b
6
+ metadata.gz: c10fbc01e9cedfa8ffb188e3d47c3522c931830002099a71b623b31574af2fb0b3df089760593d3b7e87fb38a1257eef54c4fde0b32eb600adea8dabdc234471
7
+ data.tar.gz: 95b0b54b0fbeba57225f6d7a07f2166dc3b28b4ea0a973d08cecdff7e3f870030f470df662a329dcc4b364b7c346e9357f9acfd693e67307e2c8cd05db4d8a92
@@ -185,7 +185,7 @@ module BxBuilderChain::Llm
185
185
  messages.map do |message|
186
186
  {
187
187
  role: ROLE_MAPPING.fetch(message[:type], message[:type]),
188
- content: message.content
188
+ content: message[:message]
189
189
  }
190
190
  end
191
191
  end
@@ -69,21 +69,26 @@ module BxBuilderChain::Vectorsearch
69
69
  # @return [Array<Integer>] The the ids of the added texts.
70
70
  def add_texts(texts:, ids: nil)
71
71
  if ids.nil? || ids.empty?
72
- Async do |parent|
73
- data = texts.each_slice(20).flat_map do |text_batch| # Process in batches of 20
72
+ mutex = Mutex.new
73
+ texts.each_slice(10).flat_map do |text_batch| # Process in batches of 10
74
+ data = []
75
+ Async do |parent|
74
76
  text_batch.map do |text|
75
77
  parent.async do |task|
76
78
  begin
77
- {content: text, vectors: llm.embed(text: text).to_s, namespace: namespaces[0]}
79
+ vectorised_text = {content: text, vectors: llm.embed(text: text).to_s, namespace: namespaces[0]}
80
+ mutex.synchronize do
81
+ data << vectorised_text
82
+ end
78
83
  rescue => e
79
84
  puts "Error processing text: #{e.message}"
80
85
  nil # or some error indication
81
86
  end
82
87
  end
83
- end.map(&:wait) # Ensure all tasks in the batch are completed
84
- end
88
+ end # Ensure all tasks in the batch are completed
89
+ end.map(&:wait)
90
+ @db[@table_name.to_sym].multi_insert(data, return: :primary_key)
85
91
  end
86
- @db[@table_name.to_sym].multi_insert(data, return: :primary_key)
87
92
  else
88
93
  upsert_texts(texts: texts, ids: ids)
89
94
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BxBuilderChain
4
- VERSION = "0.1.15"
4
+ VERSION = "0.1.17"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bx_builder_chain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Ketelle
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-01 00:00:00.000000000 Z
11
+ date: 2024-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk