Fixed validation error when credentials_profile_name, or region_name is not passed (#7629)

## Summary
This PR corrects the checks for credentials_profile_name, and
region_name attributes. This was causing validation exceptions when
either of these values were missing during creation of the retriever
class.

Fixes #7571 

#### Requested reviewers:
@baskaryan
This commit is contained in:
Piyush Jain 2023-07-12 20:47:35 -07:00 committed by GitHub
parent 0e1d7a27c6
commit f11d845dee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -213,14 +213,14 @@ class AmazonKendraRetriever(BaseRetriever):
try:
import boto3
if values["credentials_profile_name"] is not None:
if values.get("credentials_profile_name"):
session = boto3.Session(profile_name=values["credentials_profile_name"])
else:
# use default credentials
session = boto3.Session()
client_params = {}
if values["region_name"] is not None:
if values.get("region_name"):
client_params["region_name"] = values["region_name"]
values["client"] = session.client("kendra", **client_params)