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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08b38ee39600716a9854a387fc0b54091290f27d7afa88b276a480651049bdd4'
4
- data.tar.gz: 69d4292c129e751d9d4001912f5ab54ba23f9d9944a5e4294f4ba1dd426d401e
3
+ metadata.gz: 0d2eb76b006864583607672a93cd81a5c37b259a34a2760f7d686f8923b60b22
4
+ data.tar.gz: 4e307d737f9e519e68c6adb632ff863ca365907789183756fcabe7bf0a79df4f
5
5
  SHA512:
6
- metadata.gz: 3f7d4403d11076fcff2975c88a236fa8b6ace079d83b774000af1d59c08f36794057eaef56769a51bb8e21ab462bba9dbf9df60d704f285b788af8a67b6977ea
7
- data.tar.gz: 5d14c72130cada67dadfe880b2a0d723b312d8c27e7ef46452aa4ad65dce1055b66d8459b24c4b6d3f1adb5eeacf30c9fdc686b0190809ef051d393c33d3d33d
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.0]
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?
@@ -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: nil
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[:dimension] || EMBEDDING_SIZES.fetch(defaults[:embeddings_model_name])
188
+ @defaults[:dimensions] || EMBEDDING_SIZES.fetch(defaults[:embeddings_model_name])
189
189
  end
190
190
 
191
191
  private
@@ -86,6 +86,10 @@ module Langchain::Vectorsearch
86
86
  client.search_knn(embedding, k)
87
87
  end
88
88
 
89
+ # TODO: Add the ask() method
90
+ # def ask
91
+ # end
92
+
89
93
  private
90
94
 
91
95
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Langchain
4
- VERSION = "0.11.1"
4
+ VERSION = "0.11.2"
5
5
  end
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.1
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-08 00:00:00.000000000 Z
11
+ date: 2024-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport