From 7884054b3e31beee581ab18de87edbdd4f9bebb7 Mon Sep 17 00:00:00 2001 From: Joshua Yu Date: Thu, 28 Nov 2024 16:49:57 -0500 Subject: [PATCH] chore: Passes linting and formatting --- .../src/tools/google_finance.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libs/langchain-community/src/tools/google_finance.ts b/libs/langchain-community/src/tools/google_finance.ts index 692b32edd926..37cded658a36 100644 --- a/libs/langchain-community/src/tools/google_finance.ts +++ b/libs/langchain-community/src/tools/google_finance.ts @@ -60,8 +60,7 @@ export class GoogleFinanceAPI extends Tool { super(...arguments); // Retrieve API key from fields or environment variables. - const apiKey = - fields?.apiKey ?? getEnvironmentVariable("SERPAPI_API_KEY"); + const apiKey = fields?.apiKey ?? getEnvironmentVariable("SERPAPI_API_KEY"); // Throw an error if no API key is found. if (!apiKey) { @@ -83,10 +82,10 @@ export class GoogleFinanceAPI extends Tool { const url = `https://serpapi.com/search.json?q=${encodeURIComponent( input )}&engine=google_finance&api_key=05f88ace01a07cc3ca26bd86664b5d2e579d2a5db45407f55a39d86ac7d47d1b`; - + // Make an HTTP GET request to the SerpApi service. const response = await fetch(url); - + // Handle non-OK responses by extracting the error message. if (!response.ok) { let message; @@ -102,15 +101,15 @@ export class GoogleFinanceAPI extends Tool { `Got ${response.status}: ${response.statusText} error from SerpApi: ${message}` ); } - + // Parse the JSON response from SerpApi. const json = await response.json(); - + // Remove metadata and search parameters from result. if (json.search_metadata) delete json.search_metadata; if (json.search_parameters) delete json.search_parameters; - + // Return the results as a formatted JSON string. return JSON.stringify(json, null, 2); } -} \ No newline at end of file +}