Skip to content

Ensure all tools have default initialize params #875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mattlindsey
Copy link
Contributor

@andreibondarev andreibondarev requested a review from Copilot April 17, 2025 18:20
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the initialization parameters for several tools to pull default values from environment variables, reducing the need for manual configuration.

  • Update Weather, Tavily, GoogleSearch, and Database tools to use ENV variables as defaults.
  • Modify the example usage and README to reflect the new default parameter behavior.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/langchain/tool/weather.rb Sets default api_key from ENV["OPEN_WEATHER_API_KEY"].
lib/langchain/tool/vectorsearch.rb Sets default vectorsearch from ENV["VECTORSEARCH_URL"].
lib/langchain/tool/tavily.rb Sets default api_key from ENV["TAVILY_API_KEY"].
lib/langchain/tool/google_search.rb Sets default api_key from ENV["SERPAPI_API_KEY"].
lib/langchain/tool/database.rb Sets default connection_string from ENV["DATABASE_URL"].
examples/assistant_chat.rb Removes redundant ENV param for Weather tool instantiation.
README.md Updates TMDB tool initialization to use ENV["TMDB_API_KEY"].

@@ -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
Copy link
Preview

Copilot AI Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value from ENV['VECTORSEARCH_URL'] is a string while the documentation suggests a Langchain::Vectorsearch::Base instance is expected. Please ensure that this ENV variable is transformed into or replaced with an appropriate object.

Suggested change
@vectorsearch = vectorsearch
@vectorsearch = if vectorsearch.is_a?(String)
Langchain::Vectorsearch::Chroma.new(url: vectorsearch, index_name: "default_index", llm: nil)
else
vectorsearch
end

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant