Skip to content

Commit 9cbc83b

Browse files
author
Dinesh Sajwan
committed
feat(visualqa): defect fixes
1 parent 7d4d3a1 commit 9cbc83b

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lambda/aws-qa-appsync-opensearch/question_answering/src/qa_agent/helper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def get_presigned_url(bucket,key) -> str:
196196

197197
def download_file(bucket,key )-> str:
198198
try:
199-
file_path = os.path.join(tempfile.gettempdir(), os.path.basename(image_file))
199+
file_path = os.path.join(tempfile.gettempdir(), os.path.basename(key))
200200
s3.download_file(bucket, key,file_path)
201201
logger.info(f"file downloaded {file_path}")
202202
return file_path

lambda/aws-qa-appsync-opensearch/question_answering/src/qa_agent/image_qa.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,10 @@ def get_image_from_semantic_search_in_os(input_params,status_variables):
156156
# if filename is given then filter the source_document for specfic file
157157
logger.info(f'output_file_name is :: {output_file_name}')
158158
if output_file_name:
159-
source_documents = [doc for doc in source_documents if doc.metadata['source'] == output_file_name]
159+
source_documents = [doc for doc in source_documents if doc.metadata['filename'] == output_file_name]
160160
status_variables['sources'] = list(set(doc.metadata['source'] for doc in source_documents))
161161

162-
# get new presigned url for RAG from source metadata
163-
if source_documents is not None:
162+
if source_documents is not None and len(source_documents) != 0:
164163
filename = source_documents[0].metadata['filename']
165164
status_variables['filename']=filename
166165

0 commit comments

Comments
 (0)