langchainrb 0.10.2 → 0.10.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: 19b23746583868d1a5eca30d5e8f30bf548cfc253d8cf20fa13c27bb4e03b967
4
- data.tar.gz: 6de6bea0a348b812d09745af6f14c03def1f8d7a4fb7a246ab328de4992b9e8e
3
+ metadata.gz: 14c9c33c905c2df744cc7006735dbc55b86b767cfff4b655b03103072c804bb1
4
+ data.tar.gz: e5076e7322ff375b16463ff14e5c504d7b106e05874f6860f9669a2269346d61
5
5
  SHA512:
6
- metadata.gz: 12e39b5c0c523d7ea798f4fc0729fc53f0e0754db43261ec9c464369a4a01fea18ef7c30bee9d26b45a08add746cd45b0550f1a741dda0f84ae4cd72be9481d1
7
- data.tar.gz: abf235f4d1dffd76d4a73a45a8e3e3af81ed358eadb43189ccef6cd8d3ff7739c8e1fcb38287c786dd56de6edf8944efc16270936cd6d4e4763e2ec4f7c84eea
6
+ metadata.gz: f590a6f2f2adec60ee777a94886e178abfaf0789c0141bbd278d0a008d9ace75cb9f69d6afdf3ae3d58f7307246acfaf7f0fef43d43065bf8c1d83aa0e51562d
7
+ data.tar.gz: 3fef869c24edf5a14ea4ddbdae8af919b2082e8f95b676ca36dd9e606ba67812e88dcd6d67f15156b9cce8daaaab26acd9c8602e3c894199dd7eae43d0926443
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.10.3]
4
+ - Bump dependencies
5
+ - Ollama#complete fix
6
+ - Misc fixes
7
+
3
8
  ## [0.10.2]
4
9
  - New Langchain::LLM::Mistral
5
10
  - Drop Ruby 3.0 support
data/README.md CHANGED
@@ -29,6 +29,7 @@ Available for paid consulting engagements! [Email me](mailto:andrei@sourcelabs.i
29
29
  - [Evaluations](#evaluations-evals)
30
30
  - [Examples](#examples)
31
31
  - [Logging](#logging)
32
+ - [Problems](#problems)
32
33
  - [Development](#development)
33
34
  - [Discord](#discord)
34
35
 
@@ -501,6 +502,12 @@ To show all log messages:
501
502
  Langchain.logger.level = :debug
502
503
  ```
503
504
 
505
+ ## Problems
506
+ If you're having issues installing `unicode` gem required by `pragmatic_segmenter`, try running:
507
+ ```bash
508
+ gem install unicode -- --with-cflags="-Wno-incompatible-function-pointer-types"
509
+ ```
510
+
504
511
  ## Development
505
512
 
506
513
  1. `git clone https://github.com/andreibondarev/langchainrb.git`
@@ -5,7 +5,7 @@ module Langchain::LLM
5
5
  # gem "mistral-ai"
6
6
  #
7
7
  # Usage:
8
- # llm = Langchain::LLM::MistralAI.new(api_key: ENV["OPENAI_API_KEY"])
8
+ # llm = Langchain::LLM::MistralAI.new(api_key: ENV["MISTRAL_AI_API_KEY"])
9
9
  class MistralAI < Base
10
10
  DEFAULTS = {
11
11
  chat_completion_model_name: "mistral-medium",
@@ -18,7 +18,7 @@ module Langchain::LLM
18
18
  depends_on "mistral-ai"
19
19
 
20
20
  @client = Mistral.new(
21
- credentials: {api_key: ENV["MISTRAL_AI_API_KEY"]},
21
+ credentials: {api_key: api_key},
22
22
  options: {server_sent_events: true}
23
23
  )
24
24
 
@@ -131,9 +131,14 @@ module Langchain::LLM
131
131
 
132
132
  req.options.on_data = proc do |chunk, size|
133
133
  chunk.split("\n").each do |line_chunk|
134
- json_chunk = JSON.parse(line_chunk)
134
+ json_chunk = begin
135
+ JSON.parse(line_chunk)
136
+ # In some instance the chunk exceeds the buffer size and the JSON parser fails
137
+ rescue JSON::ParserError
138
+ nil
139
+ end
135
140
 
136
- response += json_chunk.dig("response")
141
+ response += json_chunk.dig("response") unless json_chunk.blank?
137
142
  end
138
143
 
139
144
  yield json_chunk, size if block
@@ -89,6 +89,13 @@ module Langchain::Vectorsearch
89
89
  upsert_texts(texts: texts, ids: ids)
90
90
  end
91
91
 
92
+ # Remove a list of texts from the index
93
+ # @param ids [Array<Integer>] The ids of the texts to remove from the index
94
+ # @return [Integer] The number of texts removed from the index
95
+ def remove_texts(ids:)
96
+ @db[table_name.to_sym].where(id: ids).delete
97
+ end
98
+
92
99
  # Create default schema
93
100
  def create_default_schema
94
101
  db.run "CREATE EXTENSION IF NOT EXISTS vector"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Langchain
4
- VERSION = "0.10.2"
4
+ VERSION = "0.10.3"
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.10.2
4
+ version: 0.10.3
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-03-21 00:00:00.000000000 Z
11
+ date: 2024-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -534,14 +534,14 @@ dependencies:
534
534
  requirements:
535
535
  - - "~>"
536
536
  - !ruby/object:Gem::Version
537
- version: '1.4'
537
+ version: '2.0'
538
538
  type: :development
539
539
  prerelease: false
540
540
  version_requirements: !ruby/object:Gem::Requirement
541
541
  requirements:
542
542
  - - "~>"
543
543
  - !ruby/object:Gem::Version
544
- version: '1.4'
544
+ version: '2.0'
545
545
  - !ruby/object:Gem::Dependency
546
546
  name: pinecone
547
547
  requirement: !ruby/object:Gem::Requirement
@@ -604,14 +604,14 @@ dependencies:
604
604
  requirements:
605
605
  - - "~>"
606
606
  - !ruby/object:Gem::Version
607
- version: 6.3.0
607
+ version: 6.4.0
608
608
  type: :development
609
609
  prerelease: false
610
610
  version_requirements: !ruby/object:Gem::Requirement
611
611
  requirements:
612
612
  - - "~>"
613
613
  - !ruby/object:Gem::Version
614
- version: 6.3.0
614
+ version: 6.4.0
615
615
  - !ruby/object:Gem::Dependency
616
616
  name: safe_ruby
617
617
  requirement: !ruby/object:Gem::Requirement