generative-ai-on-aws-immersion-day icon indicating copy to clipboard operation
generative-ai-on-aws-immersion-day copied to clipboard

Lab 4 - Lambda fails to call Kendra

Open mmeidlinger opened this issue 1 year ago • 3 comments

Getting Internal Server errors image

Checking the Lambda function logs, it looks like Lambda can't call Kendra. Kendra index is populated with the docs and I verified Lambda has the correct index id.

[ERROR] KeyError: 'client'
Traceback (most recent call last):
  File "/var/task/rag_app.py", line 85, in lambda_handler
    retriever = AmazonKendraRetriever(
  File "/var/task/langchain/load/serializable.py", line 74, in __init__
    super().__init__(**kwargs)
  File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__
    values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
  File "pydantic/main.py", line 1050, in pydantic.main.validate_model
    input_data = validator(cls_, input_data)
  File "/var/task/langchain/retrievers/kendra.py", line 191, in create_client
    if values["client"] is not None:

mmeidlinger avatar Jul 07 '23 09:07 mmeidlinger

Hey @mmeidlinger The lambda should have environment variable set with the Kendra index id in KENDRA_INDEX_ID, along with SM_ENDPOINT_NAME, and SM_MODEL_TYPE

You can set them in the CF template, and run sam build, sam deploy or go to the lambda environment variable configuration, and edit it there.

omerh avatar Jul 12 '23 11:07 omerh

I did set these, I don't think this is a config issue: image image

mmeidlinger avatar Jul 14 '23 07:07 mmeidlinger

Can you please pull latest changes, build and update the Lambda. We are now using Langchain for using Kendra retrieve API

omerh avatar Jul 18 '23 13:07 omerh