🔧 fix: API Key Handling for GoogleSearch and TavilySearch Tools (#3541)

* fix: get user-provided API key using environment variable names as keys

* feat: Add error handling for missing API key and search engine ID

* feat: Add GoogleSearch and TavilySearchResults specs for environment variables handling

---------

Co-authored-by: Dongwoo Jeong <dongwoo.jeong@lge.com>
This commit is contained in:
Dongwoo Jeong 2024-08-06 08:29:16 +09:00 committed by GitHub
parent 80773d0bce
commit 6879de0bf1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 97 additions and 3 deletions

View file

@ -12,7 +12,7 @@ class TavilySearchResults extends Tool {
this.envVar = 'TAVILY_API_KEY';
/* Used to initialize the Tool without necessary variables. */
this.override = fields.override ?? false;
this.apiKey = fields.apiKey ?? this.getApiKey();
this.apiKey = fields[this.envVar] ?? this.getApiKey();
this.kwargs = fields?.kwargs ?? {};
this.name = 'tavily_search_results_json';