in chunking/chunkers/multimodal_chunker.py [0:0]
def _generate_caption_for_figure(self, figure):
"""
Generates a caption for the figure using the Azure OpenAI client.
Args:
figure (dict): The figure data containing image information.
Returns:
str: The generated caption for the figure.
"""
try:
caption_prompt = (
"Generate a detailed description of the following figure, including "
"its key elements and context, to optimize it for retrieval purposes. "
"Use no more than 200 words."
)
caption = self.aoai_client.get_completion(
prompt=caption_prompt,
image_base64=figure["image"]
)
logging.debug(f"[multimodal_chunker][{self.filename}] Generated caption for figure {figure.get('id', 'unknown')}: {caption}")
return caption
except Exception as e:
logging.error(f"[multimodal_chunker][{self.filename}] Failed to generate caption for figure {figure.get('id', 'unknown')}: {str(e)}")
return "No caption available."