mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-05 04:55:14 +00:00
Avoid copying runs (#26689)
Also, re-unify run trees. Use a single shared client.
This commit is contained in:
@@ -24,6 +24,18 @@ class FinancialDatasetsAPIWrapper(BaseModel):
|
||||
data, "financial_datasets_api_key", "FINANCIAL_DATASETS_API_KEY"
|
||||
)
|
||||
|
||||
@property
|
||||
def _api_key(self) -> str:
|
||||
if self.financial_datasets_api_key is None:
|
||||
raise ValueError(
|
||||
"API key is required for the FinancialDatasetsAPIWrapper. "
|
||||
"Please provide the API key by either:\n"
|
||||
"1. Manually specifying it when initializing the wrapper: "
|
||||
"FinancialDatasetsAPIWrapper(financial_datasets_api_key='your_api_key')\n"
|
||||
"2. Setting it as an environment variable: FINANCIAL_DATASETS_API_KEY"
|
||||
)
|
||||
return self.financial_datasets_api_key
|
||||
|
||||
def get_income_statements(
|
||||
self,
|
||||
ticker: str,
|
||||
@@ -47,7 +59,7 @@ class FinancialDatasetsAPIWrapper(BaseModel):
|
||||
)
|
||||
|
||||
# Add the api key to the headers
|
||||
headers = {"X-API-KEY": self.financial_datasets_api_key}
|
||||
headers = {"X-API-KEY": self._api_key}
|
||||
|
||||
# Execute the request
|
||||
response = requests.get(url, headers=headers)
|
||||
@@ -78,7 +90,7 @@ class FinancialDatasetsAPIWrapper(BaseModel):
|
||||
)
|
||||
|
||||
# Add the api key to the headers
|
||||
headers = {"X-API-KEY": self.financial_datasets_api_key}
|
||||
headers = {"X-API-KEY": self._api_key}
|
||||
|
||||
# Execute the request
|
||||
response = requests.get(url, headers=headers)
|
||||
@@ -110,7 +122,7 @@ class FinancialDatasetsAPIWrapper(BaseModel):
|
||||
)
|
||||
|
||||
# Add the api key to the headers
|
||||
headers = {"X-API-KEY": self.financial_datasets_api_key}
|
||||
headers = {"X-API-KEY": self._api_key}
|
||||
|
||||
# Execute the request
|
||||
response = requests.get(url, headers=headers)
|
||||
|
Reference in New Issue
Block a user