From 986fde17ef2e19178eb92f583de67bff33308284 Mon Sep 17 00:00:00 2001 From: Matt Lindsey Date: Fri, 15 Nov 2024 07:45:03 -0500 Subject: [PATCH] add default tool initialize params --- README.md | 2 +- examples/assistant_chat.rb | 2 +- lib/langchain/tool/database.rb | 2 +- lib/langchain/tool/google_search.rb | 2 +- lib/langchain/tool/tavily.rb | 2 +- lib/langchain/tool/vectorsearch.rb | 2 +- lib/langchain/tool/weather.rb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ec2442890..283f32614 100644 --- a/README.md +++ b/README.md @@ -568,7 +568,7 @@ class MovieInfoTool property :movie_id, type: "integer", description: "The TMDb ID of the movie", required: true end - def initialize(api_key:) + def initialize(api_key: ENV["TMDB_API_KEY"]) @api_key = api_key end diff --git a/examples/assistant_chat.rb b/examples/assistant_chat.rb index 681c687fd..48f97b928 100644 --- a/examples/assistant_chat.rb +++ b/examples/assistant_chat.rb @@ -11,7 +11,7 @@ llm: openai, instructions: "You are a Meteorologist Assistant that is able to pull the weather for any location", tools: [ - Langchain::Tool::Weather.new(api_key: ENV["OPEN_WEATHER_API_KEY"]) + Langchain::Tool::Weather.new ] ) diff --git a/lib/langchain/tool/database.rb b/lib/langchain/tool/database.rb index ff38107ff..f706b55b4 100644 --- a/lib/langchain/tool/database.rb +++ b/lib/langchain/tool/database.rb @@ -36,7 +36,7 @@ class Database # @param tables [Array] The tables to use. Will use all if empty. # @param except_tables [Array] The tables to exclude. Will exclude none if empty. # @return [Database] Database object - def initialize(connection_string:, tables: [], exclude_tables: []) + def initialize(connection_string: ENV["DATABASE_URL"], tables: [], exclude_tables: []) depends_on "sequel" raise StandardError, "connection_string parameter cannot be blank" if connection_string.empty? diff --git a/lib/langchain/tool/google_search.rb b/lib/langchain/tool/google_search.rb index e4ddb8f13..5d0184eb2 100644 --- a/lib/langchain/tool/google_search.rb +++ b/lib/langchain/tool/google_search.rb @@ -27,7 +27,7 @@ class GoogleSearch # @param api_key [String] Search API key # @return [Langchain::Tool::GoogleSearch] Google search tool # - def initialize(api_key:) + def initialize(api_key: ENV["SERPAPI_API_KEY"]) depends_on "google_search_results" @api_key = api_key diff --git a/lib/langchain/tool/tavily.rb b/lib/langchain/tool/tavily.rb index ff86944ba..fa4c4a7f2 100644 --- a/lib/langchain/tool/tavily.rb +++ b/lib/langchain/tool/tavily.rb @@ -26,7 +26,7 @@ class Tavily end end - def initialize(api_key:) + def initialize(api_key: ENV["TAVILY_API_KEY"]) @api_key = api_key end diff --git a/lib/langchain/tool/vectorsearch.rb b/lib/langchain/tool/vectorsearch.rb index 929a8803b..3742bee76 100644 --- a/lib/langchain/tool/vectorsearch.rb +++ b/lib/langchain/tool/vectorsearch.rb @@ -25,7 +25,7 @@ class Vectorsearch # Initializes the Vectorsearch tool # # @param vectorsearch [Langchain::Vectorsearch::Base] Vectorsearch instance to use - def initialize(vectorsearch:) + def initialize(vectorsearch: ENV["VECTORSEARCH_URL"]) @vectorsearch = vectorsearch end diff --git a/lib/langchain/tool/weather.rb b/lib/langchain/tool/weather.rb index 4f58266ce..8c2675581 100644 --- a/lib/langchain/tool/weather.rb +++ b/lib/langchain/tool/weather.rb @@ -37,7 +37,7 @@ class Weather required: false end - def initialize(api_key:) + def initialize(api_key: ENV["OPEN_WEATHER_API_KEY"]) @api_key = api_key end