speaky 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06f3d5c76d75de0c05238c26dfc83d3707d7cc5448f83ef474249b0bd5df185b
4
- data.tar.gz: 64cac48f6f8fcdd88512940ae3888d736f7b52890dd6cf92a7f91f6716ffee48
3
+ metadata.gz: 978cd92d282523846c4b7b592776656f3d351162a361e28460de95e4af338378
4
+ data.tar.gz: dac048c47d89c41ef1b96dc31d3a7f600ee2ef393d59bffd203af1b7f97c17cd
5
5
  SHA512:
6
- metadata.gz: 104878c920e7de1c268e727b2ff774f8a6f8c0e240be6cc5b252ee054beeb3f9ae37b36bf7f57ae5491e8d26b3af670b229304885d21f7b0bd63c3686eea5cf4
7
- data.tar.gz: 20a27ca58c2f0184d153e5652e9a71058335a9ba1ebd1fd9281f542d95df1c38a8ac5345976f93dd9a824f89b58bdec35440eb441dbf7b443b0a7347db1ad142
6
+ metadata.gz: 06e1d13344593cce42a57f730d44e4f838660a7581810a5357e023b42a6f7a00c866e3fadcbb98d6a4398f202a0c693c02202c69415f7eac16ca7f9190903b93
7
+ data.tar.gz: 3afc6a7bd45fd9fff233a5e753a6778421d8664405ccc33c1e7189988770056dcd6a45dd04c60052aa2d24b1c7eb61ecb85ee508959c9360e53e1b26ca70f211
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rails'
3
4
  require 'active_support'
4
5
 
5
6
  module Speaky
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rails'
3
4
  require 'qdrant'
4
5
 
5
6
  module Speaky
@@ -29,7 +30,7 @@ module Speaky
29
30
  collection_name: @config[:collection_name],
30
31
  points: [
31
32
  {
32
- id: id,
33
+ id: string_id_to_unique_int_id(id),
33
34
  vector: embeddings,
34
35
  payload: {
35
36
  content: data
@@ -40,6 +41,7 @@ module Speaky
40
41
  )
41
42
 
42
43
  if !points_upsert || points_upsert.dig('status') != 'ok'
44
+ Rails.logger.error(points_upsert)
43
45
  raise 'Failed to add vector'
44
46
  end
45
47
 
@@ -49,10 +51,11 @@ module Speaky
49
51
  def remove(id)
50
52
  points_delete = @client.points.delete(
51
53
  collection_name: @config[:collection_name],
52
- points: [id],
54
+ points: [string_id_to_unique_int_id(id)],
53
55
  )
54
56
 
55
57
  if !points_delete || points_delete.dig('status') != 'ok'
58
+ Rails.logger.error(points_delete)
56
59
  raise 'Failed to remove vector'
57
60
  end
58
61
 
@@ -71,6 +74,7 @@ module Speaky
71
74
  )
72
75
 
73
76
  if !points_search || points_search.dig('status') != 'ok'
77
+ Rails.logger.error(points_search)
74
78
  raise 'Failed to search vectors'
75
79
  end
76
80
 
@@ -80,6 +84,7 @@ module Speaky
80
84
  def reset
81
85
  collections_delete = @client.collections.delete(collection_name: @config[:collection_name])
82
86
  if !collections_delete || collections_delete.dig('status') != 'ok'
87
+ Rails.logger.error(collections_delete)
83
88
  raise 'Failed to delete collection'
84
89
  end
85
90
 
@@ -99,6 +104,7 @@ module Speaky
99
104
  }
100
105
  )
101
106
  if !collections_create || collections_create.dig('status') != 'ok'
107
+ Rails.logger.error(collections_create)
102
108
  raise 'Failed to create collection'
103
109
  end
104
110
  end
@@ -106,10 +112,17 @@ module Speaky
106
112
  # create index for field "id" in collection
107
113
  collections_create_index = @client.collections.create_index(collection_name: @config[:collection_name], field_name: 'id', field_schema: 'keyword')
108
114
  if !collections_create_index || collections_create_index.dig('status') != 'ok'
115
+ Rails.logger.error(collections_create_index)
109
116
  raise 'Failed to create index for field "id" on collection'
110
117
  end
111
118
 
112
119
  true
113
120
  end
121
+
122
+ # This method is used to convert a string ID to a unique integer ID
123
+ # that can be used by the Qdrant API.
124
+ def string_id_to_unique_int_id(string_id)
125
+ string_id.to_s.hash.abs
126
+ end
114
127
  end
115
128
  end
@@ -1,3 +1,3 @@
1
1
  module Speaky
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: speaky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante