langchainrb 0.11.4 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/langchain/llm/base.rb +2 -2
- data/lib/langchain/llm/cohere.rb +1 -1
- data/lib/langchain/llm/google_palm.rb +1 -1
- data/lib/langchain/llm/google_vertex_ai.rb +1 -1
- data/lib/langchain/llm/hugging_face.rb +1 -1
- data/lib/langchain/llm/ollama.rb +2 -2
- data/lib/langchain/llm/openai.rb +1 -1
- data/lib/langchain/llm/replicate.rb +1 -1
- data/lib/langchain/vectorsearch/elasticsearch.rb +1 -1
- data/lib/langchain/vectorsearch/epsilla.rb +2 -2
- data/lib/langchain/vectorsearch/hnswlib.rb +1 -1
- data/lib/langchain/vectorsearch/milvus.rb +1 -1
- data/lib/langchain/vectorsearch/pgvector.rb +2 -2
- data/lib/langchain/vectorsearch/pinecone.rb +1 -1
- data/lib/langchain/vectorsearch/qdrant.rb +1 -1
- data/lib/langchain/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f29aad35bc35dc95eb8673b11578b51c7449a19818989d9da5e640c6fb219c7
|
4
|
+
data.tar.gz: 4d0c4d3d424a82c7f02fb9e49ca52a5bdca5dfbce19fbfa22f2d74ef46d81eb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91b6f4fc5056308eab9119dcfda1be16857e6e9e6e531977148b1e8f31b72090794b67e6855afb95633b8f836b8d20921bc5a069afdc745d1114892143a177e1
|
7
|
+
data.tar.gz: f7a7949ab2efd960eacf3a93f7beaa9104403a93619b8c95ea094901c2d3d19b89980c81d293ae16035c5ff51fe021a09f2e81e2c0ed6854bff87d30e6def925
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.12.0] - 2024-04-22
|
4
|
+
- [BREAKING] Rename `dimension` parameter to `dimensions` everywhere
|
5
|
+
|
3
6
|
## [0.11.4] - 2024-04-19
|
4
7
|
- New `Langchain::LLM::AWSBedrock#chat()` to wrap Bedrock Claude requests
|
5
8
|
- New `Langchain::LLM::OllamaResponse#total_tokens()` method
|
data/lib/langchain/llm/base.rb
CHANGED
@@ -24,8 +24,8 @@ module Langchain::LLM
|
|
24
24
|
# A client for communicating with the LLM
|
25
25
|
attr_reader :client
|
26
26
|
|
27
|
-
def
|
28
|
-
self.class.const_get(:DEFAULTS).dig(:
|
27
|
+
def default_dimensions
|
28
|
+
self.class.const_get(:DEFAULTS).dig(:dimensions)
|
29
29
|
end
|
30
30
|
|
31
31
|
#
|
data/lib/langchain/llm/cohere.rb
CHANGED
@@ -13,7 +13,7 @@ module Langchain::LLM
|
|
13
13
|
class GooglePalm < Base
|
14
14
|
DEFAULTS = {
|
15
15
|
temperature: 0.0,
|
16
|
-
|
16
|
+
dimensions: 768, # This is what the `embedding-gecko-001` model generates
|
17
17
|
completion_model_name: "text-bison-001",
|
18
18
|
chat_completion_model_name: "chat-bison-001",
|
19
19
|
embeddings_model_name: "embedding-gecko-001"
|
@@ -16,7 +16,7 @@ module Langchain::LLM
|
|
16
16
|
DEFAULTS = {
|
17
17
|
temperature: 0.0,
|
18
18
|
embeddings_model_name: "sentence-transformers/all-MiniLM-L6-v2",
|
19
|
-
|
19
|
+
dimensions: 384 # Vector size generated by the above model
|
20
20
|
}.freeze
|
21
21
|
|
22
22
|
#
|
data/lib/langchain/llm/ollama.rb
CHANGED
@@ -41,9 +41,9 @@ module Langchain::LLM
|
|
41
41
|
|
42
42
|
# Returns the # of vector dimensions for the embeddings
|
43
43
|
# @return [Integer] The # of vector dimensions
|
44
|
-
def
|
44
|
+
def default_dimensions
|
45
45
|
# since Ollama can run multiple models, look it up or generate an embedding and return the size
|
46
|
-
@
|
46
|
+
@default_dimensions ||=
|
47
47
|
EMBEDDING_SIZES.fetch(defaults[:embeddings_model_name].to_sym) do
|
48
48
|
embed(text: "test").embedding.size
|
49
49
|
end
|
data/lib/langchain/llm/openai.rb
CHANGED
@@ -54,7 +54,7 @@ module Langchain::Vectorsearch
|
|
54
54
|
@db_path = db_path
|
55
55
|
@table_name = index_name
|
56
56
|
|
57
|
-
@
|
57
|
+
@vector_dimensions = llm.default_dimensions
|
58
58
|
|
59
59
|
super(llm: llm)
|
60
60
|
end
|
@@ -64,7 +64,7 @@ module Langchain::Vectorsearch
|
|
64
64
|
status_code, response = @client.database.create_table(@table_name, [
|
65
65
|
{"name" => "ID", "dataType" => "STRING", "primaryKey" => true},
|
66
66
|
{"name" => "Doc", "dataType" => "STRING"},
|
67
|
-
{"name" => "Embedding", "dataType" => "VECTOR_FLOAT", "dimensions" => @
|
67
|
+
{"name" => "Embedding", "dataType" => "VECTOR_FLOAT", "dimensions" => @vector_dimensions}
|
68
68
|
])
|
69
69
|
raise "Failed to create table: #{response}" if status_code != 200
|
70
70
|
|
@@ -26,7 +26,7 @@ module Langchain::Vectorsearch
|
|
26
26
|
|
27
27
|
super(llm: llm)
|
28
28
|
|
29
|
-
@client = ::Hnswlib::HierarchicalNSW.new(space: DEFAULT_METRIC, dim: llm.
|
29
|
+
@client = ::Hnswlib::HierarchicalNSW.new(space: DEFAULT_METRIC, dim: llm.default_dimensions)
|
30
30
|
@path_to_index = path_to_index
|
31
31
|
|
32
32
|
initialize_index
|
@@ -101,11 +101,11 @@ module Langchain::Vectorsearch
|
|
101
101
|
def create_default_schema
|
102
102
|
db.run "CREATE EXTENSION IF NOT EXISTS vector"
|
103
103
|
namespace_column = @namespace_column
|
104
|
-
|
104
|
+
vector_dimensions = llm.default_dimensions
|
105
105
|
db.create_table? table_name.to_sym do
|
106
106
|
primary_key :id
|
107
107
|
text :content
|
108
|
-
column :vectors, "vector(#{
|
108
|
+
column :vectors, "vector(#{vector_dimensions})"
|
109
109
|
text namespace_column.to_sym, default: nil
|
110
110
|
end
|
111
111
|
end
|
data/lib/langchain/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: langchainrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Bondarev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|