langchainrb 0.6.2 → 0.6.3

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: 3df4368be6da730348143ba599d9fba642277a644a6dff9b9dc1b81014d29a8b
4
- data.tar.gz: 964c65411f2fe7d1768a65a1700eeb573f56946a60b8cfd04b43fade8faf75d1
3
+ metadata.gz: 73f980d6a7dd67d0112038a8266a05f8b5697e05c98e61a94598d38406de7c8b
4
+ data.tar.gz: 8abc93ad6da8ad05d76ac35eff9aaab963c33549acb94bda4dd83daddeb71f4d
5
5
  SHA512:
6
- metadata.gz: 1b032b337b109a953c49a5eafe4ad4161818bd02a2bd0076f7922aad438f4eb79029338dcb1c5d1f267b9f6ba1e0a35e7ba6fabe1369ae9d02b45240837012c8
7
- data.tar.gz: e6d03a7bf10aa60ffc833ecda448e75c84edaaf9febece3ec06385857f340f19efd674dfd2f43a7d08c1a6698a13880a0e54dd90b740ce438a4658b08eae37d7
6
+ metadata.gz: 7b5450e51ee732a1e2414e3db5f8a46d113d0b537b561f95556756e2854c9bb9175c898388acc2bb8672b2479e647625d3166580b7b1b25eb6cdc86ff6d42aee
7
+ data.tar.gz: b5843004533f952782946e6a753aa5306c6ad4a5f97887416f8f10f4192ca1f88d00d30624cd62581022314649e5d291d9c1ab46f2bab31f9455860fc533c83d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.3] - 2023-06-25
4
+ - Add #destroy_default_schema() to Langchain::Vectorsearch::* classes
5
+
3
6
  ## [0.6.2] - 2023-06-25
4
7
  - Qdrant, Chroma, and Pinecone are supported by ActiveRecord hooks
5
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- langchainrb (0.6.2)
4
+ langchainrb (0.6.3)
5
5
  baran (~> 0.1.6)
6
6
  colorize (~> 0.8.1)
7
7
  json-schema (~> 4.0.0)
data/README.md CHANGED
@@ -110,6 +110,22 @@ client.ask(
110
110
  )
111
111
  ```
112
112
 
113
+ ## Integrating Vector Search into ActiveRecord models
114
+ ```ruby
115
+ class Product < ActiveRecord::Base
116
+ vectorsearch provider: Langchain::Vectorsearch::Qdrant.new(
117
+ api_key: ENV["QDRANT_API_KEY"],
118
+ url: ENV["QDRANT_URL"],
119
+ index_name: "Products",
120
+ llm: Langchain::LLM::GooglePalm.new(api_key: ENV["GOOGLE_PALM_API_KEY"])
121
+ )
122
+
123
+ after_save :upsert_to_vectorsearch
124
+ end
125
+ ```
126
+
127
+ Additional info [here](https://github.com/andreibondarev/langchainrb/blob/main/lib/langchain/active_record/hooks.rb#L10-L38).
128
+
113
129
  ### Using Standalone LLMs 🗣️
114
130
 
115
131
  Add `gem "ruby-openai", "~> 4.0.0"` to your Gemfile.
@@ -370,15 +386,33 @@ Langchain.logger.level = :info
370
386
  Join us in the [Langchain.rb](https://discord.gg/WDARp7J2n8) Discord server.
371
387
 
372
388
  ## Core Contributors
373
- [<img style="border-radius:50%" alt="Andrei Bondarev" src="https://avatars.githubusercontent.com/u/541665?v=4" width="80" height="80" class="avatar">](https://github.com/andreibondarev)
389
+ [<img style="border-radius:50%" alt="Andrei Bondarev" src="https://avatars.githubusercontent.com/u/541665?v=4" width="80" height="80" class="avatar">](https://twitter.com/rushing_andrei)
374
390
 
375
- ## Honorary Contributors
376
- [<img style="border-radius:50%" alt="Andrei Bondarev" src="https://avatars.githubusercontent.com/u/541665?v=4" width="80" height="80" class="avatar">](https://github.com/andreibondarev)
377
- [<img style="border-radius:50%" alt="Rafael Figueiredo" src="https://avatars.githubusercontent.com/u/35845775?v=4" width="80" height="80" class="avatar">](https://github.com/rafaelqfigueiredo)
378
- [<img style="border-radius:50%" alt="Ricky Chilcott" src="https://avatars.githubusercontent.com/u/445759?v=4" width="80" height="80" class="avatar">](https://github.com/rickychilcott)
391
+ ## Contributors
379
392
  [<img style="border-radius:50%" alt="Alex Chaplinsky" src="https://avatars.githubusercontent.com/u/695947?v=4" width="80" height="80" class="avatar">](https://github.com/alchaplinsky)
380
-
381
- (Criteria for becoming an Honorary Contributor or Core Contributor is pending...)
393
+ [<img style="border-radius:50%" alt="Josh Nichols" src="https://avatars.githubusercontent.com/u/159?v=4" width="80" height="80" class="avatar">](https://github.com/technicalpickles)
394
+ [<img style="border-radius:50%" alt="Matt Lindsey" src="https://avatars.githubusercontent.com/u/5638339?v=4" width="80" height="80" class="avatar">](https://github.com/mattlindsey)
395
+ [<img style="border-radius:50%" alt="Ricky Chilcott" src="https://avatars.githubusercontent.com/u/445759?v=4" width="80" height="80" class="avatar">](https://github.com/rickychilcott)
396
+ [<img style="border-radius:50%" alt="Moeki Kawakami" src="https://avatars.githubusercontent.com/u/72325947?v=4" width="80" height="80" class="avatar">](https://github.com/moekidev)
397
+ [<img style="border-radius:50%" alt="Jens Stmrs" src="https://avatars.githubusercontent.com/u/3492669?v=4" width="80" height="80" class="avatar">](https://github.com/faustus7)
398
+ [<img style="border-radius:50%" alt="Rafael Figueiredo" src="https://avatars.githubusercontent.com/u/35845775?v=4" width="80" height="80" class="avatar">](https://github.com/rafaelqfigueiredo)
399
+ [<img style="border-radius:50%" alt="Piero Dotti" src="https://avatars.githubusercontent.com/u/5167659?v=4" width="80" height="80" class="avatar">](https://github.com/ProGM)
400
+ [<img style="border-radius:50%" alt="Michał Ciemięga" src="https://avatars.githubusercontent.com/u/389828?v=4" width="80" height="80" class="avatar">](https://github.com/zewelor)
401
+ [<img style="border-radius:50%" alt="Bruno Bornsztein" src="https://avatars.githubusercontent.com/u/3760?v=4" width="80" height="80" class="avatar">](https://github.com/bborn)
402
+ [<img style="border-radius:50%" alt="Tim Williams" src="https://avatars.githubusercontent.com/u/1192351?v=4" width="80" height="80" class="avatar">](https://github.com/timrwilliams)
403
+ [<img style="border-radius:50%" alt="Zhenhang Tung" src="https://avatars.githubusercontent.com/u/8170159?v=4" width="80" height="80" class="avatar">](https://github.com/ZhenhangTung)
404
+ [<img style="border-radius:50%" alt="Hama" src="https://avatars.githubusercontent.com/u/38002468?v=4" width="80" height="80" class="avatar">](https://github.com/akmhmgc)
405
+ [<img style="border-radius:50%" alt="Josh Weir" src="https://avatars.githubusercontent.com/u/10720337?v=4" width="80" height="80" class="avatar">](https://github.com/joshweir)
406
+ [<img style="border-radius:50%" alt="Arthur Hess" src="https://avatars.githubusercontent.com/u/446035?v=4" width="80" height="80" class="avatar">](https://github.com/arthurhess)
407
+ [<img style="border-radius:50%" alt="Jin Shen" src="https://avatars.githubusercontent.com/u/54917718?v=4" width="80" height="80" class="avatar">](https://github.com/jacshen-ebay)
408
+ [<img style="border-radius:50%" alt="Earle Bunao" src="https://avatars.githubusercontent.com/u/4653624?v=4" width="80" height="80" class="avatar">](https://github.com/erbunao)
409
+ [<img style="border-radius:50%" alt="Maël H." src="https://avatars.githubusercontent.com/u/61985678?v=4" width="80" height="80" class="avatar">](https://github.com/mael-ha)
410
+ [<img style="border-radius:50%" alt="Chris O. Adebiyi" src="https://avatars.githubusercontent.com/u/62605573?v=4" width="80" height="80" class="avatar">](https://github.com/oluvvafemi)
411
+ [<img style="border-radius:50%" alt="Aaron Breckenridge" src="https://avatars.githubusercontent.com/u/201360?v=4" width="80" height="80" class="avatar">](https://github.com/breckenedge)
412
+
413
+ ## Star History
414
+
415
+ [![Star History Chart](https://api.star-history.com/svg?repos=andreibondarev/langchainrb&type=Date)](https://star-history.com/#andreibondarev/langchainrb&Date)
382
416
 
383
417
  ## Contributing
384
418
 
@@ -35,7 +35,7 @@ module Langchain
35
35
  # Query the vector search provider
36
36
  # Recipe.similarity_search("carnivore dish")
37
37
  # Delete the default schema to start over
38
- # Recipe.class_variable_get(:@@provider).client.schema.delete class_name: "Recipes"
38
+ # Recipe.class_variable_get(:@@provider).destroy_default_schema
39
39
  #
40
40
  module Hooks
41
41
  def self.included(base)
@@ -103,6 +103,11 @@ module Langchain::Vectorsearch
103
103
  raise NotImplementedError, "#{self.class.name} does not support creating a default schema"
104
104
  end
105
105
 
106
+ # Method supported by Vectorsearch DB to delete the default schema
107
+ def destroy_default_schema
108
+ raise NotImplementedError, "#{self.class.name} does not support deleting a default schema"
109
+ end
110
+
106
111
  # Method supported by Vectorsearch DB to add a list of texts to the index
107
112
  def add_texts(...)
108
113
  raise NotImplementedError, "#{self.class.name} does not support adding texts"
@@ -67,6 +67,11 @@ module Langchain::Vectorsearch
67
67
  ::Chroma::Resources::Collection.create(index_name)
68
68
  end
69
69
 
70
+ # TODO: Uncomment and add the spec
71
+ # def destroy_default_schema
72
+ # ::Chroma::Resources::Collection.delete(index_name)
73
+ # end
74
+
70
75
  # Search for similar texts
71
76
  # @param query [String] The text to search for
72
77
  # @param k [Integer] The number of results to return
@@ -53,6 +53,8 @@ module Langchain::Vectorsearch
53
53
  client.save_index(path_to_index)
54
54
  end
55
55
 
56
+ # TODO: Add update_texts method
57
+
56
58
  #
57
59
  # Search for similar texts
58
60
  #
@@ -39,6 +39,8 @@ module Langchain::Vectorsearch
39
39
  )
40
40
  end
41
41
 
42
+ # TODO: Add update_texts method
43
+
42
44
  # Create default schema
43
45
  # @return [Hash] The response from the server
44
46
  def create_default_schema
@@ -77,6 +79,8 @@ module Langchain::Vectorsearch
77
79
  )
78
80
  end
79
81
 
82
+ # TODO: Add destroy_default_schema method
83
+
80
84
  def similarity_search(query:, k: 4)
81
85
  embedding = llm.embed(text: query)
82
86
 
@@ -69,6 +69,8 @@ module Langchain::Vectorsearch
69
69
  )
70
70
  end
71
71
 
72
+ # TODO: Add destroy_default_schema method
73
+
72
74
  # Search for similar texts in the index
73
75
  # @param query [String] The text to search for
74
76
  # @param k [Integer] The number of top results to return
@@ -79,6 +79,12 @@ module Langchain::Vectorsearch
79
79
  )
80
80
  end
81
81
 
82
+ # Delete the index
83
+ # @return [Hash] The response from the server
84
+ def destroy_default_schema
85
+ client.delete_index(index_name)
86
+ end
87
+
82
88
  # Search for similar texts
83
89
  # @param query [String] The text to search for
84
90
  # @param k [Integer] The number of results to return
@@ -51,6 +51,12 @@ module Langchain::Vectorsearch
51
51
  add_texts(texts: texts, ids: ids)
52
52
  end
53
53
 
54
+ # Deletes the default schema
55
+ # @return [Hash] The response from the server
56
+ def destroy_default_schema
57
+ client.collections.delete(collection_name: index_name)
58
+ end
59
+
54
60
  # Create the index with the default schema
55
61
  # @return [Hash] The response from the server
56
62
  def create_default_schema
@@ -72,6 +72,7 @@ module Langchain::Vectorsearch
72
72
  end
73
73
 
74
74
  # Create default schema
75
+ # @return [Hash] The response from the server
75
76
  def create_default_schema
76
77
  client.schema.create(
77
78
  class_name: index_name,
@@ -84,6 +85,12 @@ module Langchain::Vectorsearch
84
85
  )
85
86
  end
86
87
 
88
+ # Delete the index
89
+ # @return [Boolean] Whether the index was deleted
90
+ def destroy_default_schema
91
+ client.schema.delete(class_name: index_name)
92
+ end
93
+
87
94
  # Return documents similar to the query
88
95
  # @param query [String] The query to search for
89
96
  # @param k [Integer|String] The number of results to return
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Langchain
4
- VERSION = "0.6.2"
4
+ VERSION = "0.6.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: langchainrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Bondarev