From d505a4e73ab5341b98b90439bbf6aa2eaf4847fc Mon Sep 17 00:00:00 2001 From: Julien <364924+Bahanix@users.noreply.github.com> Date: Sun, 1 Dec 2024 20:53:56 +0100 Subject: [PATCH 1/2] Langchain::Tool::Database#describe_table with COMMENT Allows LLM to make use of columns' comments. Possible since Sequel 5.87.0. --- Gemfile.lock | 4 ++-- langchain.gemspec | 2 +- lib/langchain/tool/database.rb | 3 ++- lib/langchain/vectorsearch/pgvector.rb | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 96e10349e..d5574e96b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -381,7 +381,7 @@ GEM rubyzip (2.3.2) safe_ruby (1.0.4) childprocess (>= 0.3.9) - sequel (5.68.0) + sequel (5.87.0) signet (0.19.0) addressable (~> 2.8) faraday (>= 0.17.5, < 3.a) @@ -480,7 +480,7 @@ DEPENDENCIES rubocop ruby-openai (~> 7.1.0) safe_ruby (~> 1.0.4) - sequel (~> 5.68.0) + sequel (~> 5.87.0) standard (>= 1.35.1) vcr weaviate-ruby (~> 0.9.2) diff --git a/langchain.gemspec b/langchain.gemspec index f38500d0a..fec9e2ea8 100644 --- a/langchain.gemspec +++ b/langchain.gemspec @@ -71,7 +71,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "roo-xls", "~> 1.2.0" spec.add_development_dependency "ruby-openai", "~> 7.1.0" spec.add_development_dependency "safe_ruby", "~> 1.0.4" - spec.add_development_dependency "sequel", "~> 5.68.0" + spec.add_development_dependency "sequel", "~> 5.87.0" spec.add_development_dependency "weaviate-ruby", "~> 0.9.2" spec.add_development_dependency "wikipedia-client", "~> 1.17.0" spec.add_development_dependency "power_point_pptx", "~> 0.1.0" diff --git a/lib/langchain/tool/database.rb b/lib/langchain/tool/database.rb index ff38107ff..8ff9a98cf 100644 --- a/lib/langchain/tool/database.rb +++ b/lib/langchain/tool/database.rb @@ -5,7 +5,7 @@ module Langchain::Tool # Connects to a SQL database, executes SQL queries, and outputs DB schema for Agents to use # # Gem requirements: - # gem "sequel", "~> 5.68.0" + # gem "sequel", "~> 5.87.0" # # Usage: # database = Langchain::Tool::Database.new(connection_string: "postgres://user:password@localhost:5432/db_name") @@ -115,6 +115,7 @@ def describe_table(table) else primary_key_columns << column[0] end + schema << " COMMENT '#{column[1][:comment]}'" if column[1][:comment] schema << ",\n" unless column == db.schema(table).last && primary_key_column_count == 1 end if primary_key_column_count > 1 diff --git a/lib/langchain/vectorsearch/pgvector.rb b/lib/langchain/vectorsearch/pgvector.rb index 3d7b9ad68..de29224cc 100644 --- a/lib/langchain/vectorsearch/pgvector.rb +++ b/lib/langchain/vectorsearch/pgvector.rb @@ -6,7 +6,7 @@ class Pgvector < Base # The PostgreSQL vector search adapter # # Gem requirements: - # gem "sequel", "~> 5.68.0" + # gem "sequel", "~> 5.87.0" # gem "pgvector", "~> 0.2" # # Usage: From 1bad4a551791828c848dd0984bb3b9caee926ad6 Mon Sep 17 00:00:00 2001 From: Julien <364924+Bahanix@users.noreply.github.com> Date: Tue, 3 Dec 2024 10:41:35 +0100 Subject: [PATCH 2/2] New sequel dependency in Gemfile.lock --- Gemfile.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile.lock b/Gemfile.lock index d5574e96b..711d1a874 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -382,6 +382,7 @@ GEM safe_ruby (1.0.4) childprocess (>= 0.3.9) sequel (5.87.0) + bigdecimal signet (0.19.0) addressable (~> 2.8) faraday (>= 0.17.5, < 3.a)