langchainrb 0.11.1 → 0.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/lib/langchain/assistants/assistant.rb +24 -0
- data/lib/langchain/llm/openai.rb +2 -2
- data/lib/langchain/vectorsearch/hnswlib.rb +4 -0
- 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: 0d2eb76b006864583607672a93cd81a5c37b259a34a2760f7d686f8923b60b22
|
4
|
+
data.tar.gz: 4e307d737f9e519e68c6adb632ff863ca365907789183756fcabe7bf0a79df4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 757e6fd5733b0365eb5b4309589f8dfab8659f451a8f31e922c7ded5ca1d974ab6d6a9b8178aa773f2b812058ea51db2f1560d18215beb4364c15b953f57648d
|
7
|
+
data.tar.gz: 8c7ffe8b7f94c32a0e1afedff943871a097811266981e5cb0e3353b66f7eebdb387565f3d2292dda665d69dac2ad29584cad14c07c90b9c2def768ec93a403ea
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
-
## [0.11.
|
3
|
+
## [0.11.2]
|
4
|
+
- New `Langchain::Assistant#clear_thread!` and `Langchain::Assistant#instructions=` methods
|
5
|
+
|
6
|
+
## [0.11.1]
|
4
7
|
- Langchain::Tool::Vectorsearch that wraps Langchain::Vectorsearch::* classes. This allows the Assistant to call the tool and inject data from vector DBs.
|
5
8
|
|
6
9
|
## [0.11.0]
|
@@ -125,12 +125,36 @@ module Langchain
|
|
125
125
|
add_message(role: "tool", content: output, tool_call_id: tool_call_id)
|
126
126
|
end
|
127
127
|
|
128
|
+
# Delete all messages in the thread
|
129
|
+
#
|
130
|
+
# @return [Array] Empty messages array
|
131
|
+
def clear_thread!
|
132
|
+
thread.messages = []
|
133
|
+
end
|
134
|
+
|
135
|
+
# Set new instructions
|
136
|
+
#
|
137
|
+
# @param [String] New instructions that will be set as a system message
|
138
|
+
# @return [Array<Langchain::Message>] The messages in the thread
|
139
|
+
def instructions=(new_instructions)
|
140
|
+
@instructions = new_instructions
|
141
|
+
|
142
|
+
# Find message with role: "system" in thread.messages and delete it from the thread.messages array
|
143
|
+
thread.messages.delete_if(&:system?)
|
144
|
+
|
145
|
+
# Set new instructions by adding new system message
|
146
|
+
message = build_message(role: "system", content: new_instructions)
|
147
|
+
thread.messages.unshift(message)
|
148
|
+
end
|
149
|
+
|
128
150
|
private
|
129
151
|
|
130
152
|
# Call to the LLM#chat() method
|
131
153
|
#
|
132
154
|
# @return [Langchain::LLM::BaseResponse] The LLM response object
|
133
155
|
def chat_with_llm
|
156
|
+
Langchain.logger.info("Sending a call to #{llm.class}", for: self.class)
|
157
|
+
|
134
158
|
params = {messages: thread.openai_messages}
|
135
159
|
|
136
160
|
if tools.any?
|
data/lib/langchain/llm/openai.rb
CHANGED
@@ -54,7 +54,7 @@ module Langchain::LLM
|
|
54
54
|
model: defaults[:embeddings_model_name],
|
55
55
|
encoding_format: nil,
|
56
56
|
user: nil,
|
57
|
-
dimensions:
|
57
|
+
dimensions: @defaults[:dimensions]
|
58
58
|
)
|
59
59
|
raise ArgumentError.new("text argument is required") if text.empty?
|
60
60
|
raise ArgumentError.new("model argument is required") if model.empty?
|
@@ -185,7 +185,7 @@ module Langchain::LLM
|
|
185
185
|
end
|
186
186
|
|
187
187
|
def default_dimension
|
188
|
-
@defaults[:
|
188
|
+
@defaults[:dimensions] || EMBEDDING_SIZES.fetch(defaults[:embeddings_model_name])
|
189
189
|
end
|
190
190
|
|
191
191
|
private
|
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.11.
|
4
|
+
version: 0.11.2
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|