langchainrb 0.6.2 → 0.6.3
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +41 -7
- data/lib/langchain/active_record/hooks.rb +1 -1
- data/lib/langchain/vectorsearch/base.rb +5 -0
- data/lib/langchain/vectorsearch/chroma.rb +5 -0
- data/lib/langchain/vectorsearch/hnswlib.rb +2 -0
- data/lib/langchain/vectorsearch/milvus.rb +4 -0
- data/lib/langchain/vectorsearch/pgvector.rb +2 -0
- data/lib/langchain/vectorsearch/pinecone.rb +6 -0
- data/lib/langchain/vectorsearch/qdrant.rb +6 -0
- data/lib/langchain/vectorsearch/weaviate.rb +7 -0
- data/lib/langchain/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73f980d6a7dd67d0112038a8266a05f8b5697e05c98e61a94598d38406de7c8b
|
4
|
+
data.tar.gz: 8abc93ad6da8ad05d76ac35eff9aaab963c33549acb94bda4dd83daddeb71f4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b5450e51ee732a1e2414e3db5f8a46d113d0b537b561f95556756e2854c9bb9175c898388acc2bb8672b2479e647625d3166580b7b1b25eb6cdc86ff6d42aee
|
7
|
+
data.tar.gz: b5843004533f952782946e6a753aa5306c6ad4a5f97887416f8f10f4192ca1f88d00d30624cd62581022314649e5d291d9c1ab46f2bab31f9455860fc533c83d
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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://
|
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
|
-
##
|
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
|
-
|
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
|
+
[](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).
|
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
|
@@ -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
|
|
@@ -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
|
data/lib/langchain/version.rb
CHANGED