bx_builder_chain 0.1.13 → 0.1.15

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: 38f4062b8cf5eb13c2ed44821bff90b6a29dbfbc3a39d5c38c052f19b8df7fb6
4
- data.tar.gz: e8b167d59f1764d3c2f8aff7edac1d51a0990b9971e281b3d42ce531129762cc
3
+ metadata.gz: 9eb5ff5b21c231a4b2780d308fb4f60e7547f665c01338d309e7e596d8ddcc88
4
+ data.tar.gz: 23d0c9b0eaa1e9aac37e51bdad3e4228e7ca110bb74c03a0e3f51444c75e3844
5
5
  SHA512:
6
- metadata.gz: 57cc603b6f20f8d66270680d2243583ce1cac57d3b36f849412fdb4c8ec77dd8830579954256aa02f9693753e088ab63c1f6e3b64aed35719f66eb9fa68c5430
7
- data.tar.gz: 607857292395ca97abbe6754ac5a896df79a4dfb2333e269a03be5dcdcdacfcbf9188c02d4eb09f387e66aebcfb6cce0792c39d5cbc5cff9625b9663681efa85
6
+ metadata.gz: 0c6492b7df7f26268d0b950603c945d14b1b75c1bbde0876793dd03b02b7ca66c324d047ad1dd5aebe269a37400bfca7a9bbadab95bcd6e6ee1ac8d5adcc9124
7
+ data.tar.gz: 8d959ade792d8f9977219814358b283cb79a105285e3ccc9c6034639f0df61e455aa61746b656d305dc82950f5e7de1eb35ee0f5bfcd3c8c4084f6425ab5c63b
@@ -184,7 +184,7 @@ module BxBuilderChain::Llm
184
184
  def transform_messages(messages)
185
185
  messages.map do |message|
186
186
  {
187
- role: ROLE_MAPPING.fetch(message.type, message.type),
187
+ role: ROLE_MAPPING.fetch(message[:type], message[:type]),
188
188
  content: message.content
189
189
  }
190
190
  end
@@ -69,13 +69,20 @@ 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
73
- data = texts.map do |text|
74
- Async do
75
- {content: text, vectors: llm.embed(text: text).to_s, namespace: namespaces[0]}
76
- end
72
+ Async do |parent|
73
+ data = texts.each_slice(20).flat_map do |text_batch| # Process in batches of 20
74
+ text_batch.map do |text|
75
+ parent.async do |task|
76
+ begin
77
+ {content: text, vectors: llm.embed(text: text).to_s, namespace: namespaces[0]}
78
+ rescue => e
79
+ puts "Error processing text: #{e.message}"
80
+ nil # or some error indication
81
+ end
82
+ end
83
+ end.map(&:wait) # Ensure all tasks in the batch are completed
77
84
  end
78
- end
85
+ end
79
86
  @db[@table_name.to_sym].multi_insert(data, return: :primary_key)
80
87
  else
81
88
  upsert_texts(texts: texts, ids: ids)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BxBuilderChain
4
- VERSION = "0.1.13"
4
+ VERSION = "0.1.15"
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.13
4
+ version: 0.1.15
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-01-19 00:00:00.000000000 Z
11
+ date: 2024-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk