Skip to content
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

Ensure all tools have default initialize params #875

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/assistant_chat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
)

Expand Down
2 changes: 1 addition & 1 deletion lib/langchain/tool/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Database
# @param tables [Array<Symbol>] The tables to use. Will use all if empty.
# @param except_tables [Array<Symbol>] 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?
Expand Down
2 changes: 1 addition & 1 deletion lib/langchain/tool/google_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/langchain/tool/tavily.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/langchain/tool/vectorsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/langchain/tool/weather.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down