langchainrb 0.15.1 → 0.15.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: a8a7ebf84076b609719daddc97e448f4d4fe987e8ee1eeaddb70df667f163d02
4
- data.tar.gz: d52a9619b5913e8ce51563697e38841f9798e04f3caf294d7f331ff159eb70cb
3
+ metadata.gz: 6c8d4d8e7dd770a724268c97b24f40ba812c1ec2b60e37242ee97da9c83a6c7d
4
+ data.tar.gz: 8b98e726a7079ef750324052ad6681e81f92327ba74d82ea2445ee1212e048f6
5
5
  SHA512:
6
- metadata.gz: 2354d82608942a1744be426f23277b18fee508f539613327c9ed6f784d7da18f317d2266d356f3124eef93ea5052fe237f3fc639ff56db4b86060b08f16df1d2
7
- data.tar.gz: 282873b85e832e9a872f007a5a6bf35400e22639c5c7f26ac535da4f06370f35d6de35a44d434ec81fedfcff1143a448440cf8bf76ae38e01d0ad5ec15f08dc7
6
+ metadata.gz: d5189bbf3830a802aecf9ac67e4723b49bcbd68af5fbba6c107b656eb3658318f9a664a70344d77ae67972c1277bf19f606bf46c338d1d3f6ac4461c2f135d6b
7
+ data.tar.gz: b6afcec28e4228a402dfee5d8f0aefd17a2d6bcbbacece31a6781d4e4c39433d16699c92aad7147a38553a61f63154335f39cbe8240fd5b4b618f25e97d0fb5f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.15.3] - 2024-08-27
4
+ - Fix OpenAI#embed when text-embedding-ada-002 is used
5
+
6
+ ## [0.15.2] - 2024-08-23
7
+ - Add Assistant#add_messages() method and fix Assistant#messages= method
8
+
3
9
  ## [0.15.1] - 2024-08-19
4
10
  - Drop `to_bool` gem in favour of custom util class
5
11
  - Drop `colorize` which is GPL-licensed in favour of `rainbow`
data/README.md CHANGED
@@ -64,7 +64,7 @@ Langchain.rb wraps supported LLMs in a unified interface allowing you to easily
64
64
  | [Cohere](https://cohere.com/?utm_source=langchainrb&utm_medium=github) | ✅ | ✅ | ✅ | ✅ | |
65
65
  | [GooglePalm](https://ai.google/discover/palm2?utm_source=langchainrb&utm_medium=github) | ✅ | ✅ | ✅ | ✅ | |
66
66
  | [GoogleVertexAI](https://cloud.google.com/vertex-ai?utm_source=langchainrb&utm_medium=github) | ✅ | ❌ | ✅ | ❌ | Requires Google Cloud service auth |
67
- | [GoogleGemini](https://cloud.google.com/vertex-ai?utm_source=langchainrb&utm_medium=github) | ✅ | ❌ | ✅ | ❌ | Requires Gemini API Key (Limited to US) |
67
+ | [GoogleGemini](https://cloud.google.com/vertex-ai?utm_source=langchainrb&utm_medium=github) | ✅ | ❌ | ✅ | ❌ | Requires Gemini API Key ([get key](https://ai.google.dev/gemini-api/docs/api-key)) |
68
68
  | [HuggingFace](https://huggingface.co/?utm_source=langchainrb&utm_medium=github) | ✅ | ❌ | ❌ | ❌ | |
69
69
  | [MistralAI](https://mistral.ai/?utm_source=langchainrb&utm_medium=github) | ✅ | ❌ | ✅ | ❌ | |
70
70
  | [Ollama](https://ollama.ai/?utm_source=langchainrb&utm_medium=github) | ✅ | ✅ | ✅ | ✅ | |
@@ -415,7 +415,7 @@ Assistants are Agent-like objects that leverage helpful instructions, LLMs, tool
415
415
  | "google_search" | A wrapper around Google Search | `ENV["SERPAPI_API_KEY"]` (https://serpapi.com/manage-api-key) | `gem "google_search_results", "~> 2.0.0"` |
416
416
  | "news_retriever" | A wrapper around NewsApi.org | `ENV["NEWS_API_KEY"]` (https://newsapi.org/) | |
417
417
  | "tavily" | A wrapper around Tavily AI | `ENV["TAVILY_API_KEY"]` (https://tavily.com/) | |
418
- | "weather" | Calls Open Weather API to retrieve the current weather | `ENV["OPEN_WEATHER_API_KEY"]` (https://home.openweathermap.org/api_keys) | `gem "open-weather-ruby-client", "~> 0.3.0"` |
418
+ | "weather" | Calls Open Weather API to retrieve the current weather | `ENV["OPEN_WEATHER_API_KEY"]` (https://home.openweathermap.org/api_keys) | |
419
419
  | "wikipedia" | Calls Wikipedia API to retrieve the summary | | `gem "wikipedia-client", "~> 1.17.0"` |
420
420
 
421
421
  ### Demos
@@ -13,7 +13,7 @@ module Langchain
13
13
  # )
14
14
  class Assistant
15
15
  extend Forwardable
16
- def_delegators :thread, :messages, :messages=
16
+ def_delegators :thread, :messages
17
17
 
18
18
  attr_reader :llm, :thread, :instructions, :state
19
19
  attr_reader :total_prompt_tokens, :total_completion_tokens, :total_tokens
@@ -69,6 +69,25 @@ module Langchain
69
69
  messages
70
70
  end
71
71
 
72
+ # Set multiple messages to the thread
73
+ #
74
+ # @param messages [Array<Hash>] The messages to set
75
+ # @return [Array<Langchain::Message>] The messages in the thread
76
+ def messages=(messages)
77
+ clear_thread!
78
+ add_messages(messages: messages)
79
+ end
80
+
81
+ # Add multiple messages to the thread
82
+ #
83
+ # @param messages [Array<Hash>] The messages to add
84
+ # @return [Array<Langchain::Message>] The messages in the thread
85
+ def add_messages(messages:)
86
+ messages.each do |message_hash|
87
+ add_message(**message_hash.slice(:content, :role, :tool_calls, :tool_call_id))
88
+ end
89
+ end
90
+
72
91
  # Run the assistant
73
92
  #
74
93
  # @param auto_tool_execution [Boolean] Whether or not to automatically run tools
@@ -80,6 +80,9 @@ module Langchain::LLM
80
80
  parameters[:dimensions] = EMBEDDING_SIZES[model]
81
81
  end
82
82
 
83
+ # dimensions parameter not supported by text-embedding-ada-002 model
84
+ parameters.delete(:dimensions) if model == "text-embedding-ada-002"
85
+
83
86
  response = with_api_error_handling do
84
87
  client.embeddings(parameters: parameters)
85
88
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Langchain
4
- VERSION = "0.15.1"
4
+ VERSION = "0.15.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.15.1
4
+ version: 0.15.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-08-19 00:00:00.000000000 Z
11
+ date: 2024-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: baran
@@ -576,14 +576,14 @@ dependencies:
576
576
  requirements:
577
577
  - - "~>"
578
578
  - !ruby/object:Gem::Version
579
- version: 6.4.0
579
+ version: 7.1.0
580
580
  type: :development
581
581
  prerelease: false
582
582
  version_requirements: !ruby/object:Gem::Requirement
583
583
  requirements:
584
584
  - - "~>"
585
585
  - !ruby/object:Gem::Version
586
- version: 6.4.0
586
+ version: 7.1.0
587
587
  - !ruby/object:Gem::Dependency
588
588
  name: safe_ruby
589
589
  requirement: !ruby/object:Gem::Requirement
@@ -798,7 +798,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
798
798
  - !ruby/object:Gem::Version
799
799
  version: '0'
800
800
  requirements: []
801
- rubygems_version: 3.5.14
801
+ rubygems_version: 3.5.11
802
802
  signing_key:
803
803
  specification_version: 4
804
804
  summary: Build LLM-backed Ruby applications with Ruby's Langchain.rb