diff --git a/llm_claude_3.py b/llm_claude_3.py index 1e817d1..049f177 100644 --- a/llm_claude_3.py +++ b/llm_claude_3.py @@ -139,6 +139,7 @@ def build_messages(self, prompt, conversation) -> List[dict]: } for attachment in response.attachments ] + content.append({"type": "text", "text": response.prompt.prompt}) else: content = response.prompt.prompt messages.extend( @@ -151,24 +152,26 @@ def build_messages(self, prompt, conversation) -> List[dict]: ] ) if prompt.attachments: + content = [ + { + "type": ( + "document" + if attachment.resolve_type() == "application/pdf" + else "image" + ), + "source": { + "data": attachment.base64_content(), + "media_type": attachment.resolve_type(), + "type": "base64", + }, + } + for attachment in prompt.attachments + ] + content.append({"type": "text", "text": prompt.prompt}) messages.append( { "role": "user", - "content": [ - { - "type": ( - "document" - if attachment.resolve_type() == "application/pdf" - else "image" - ), - "source": { - "data": attachment.base64_content(), - "media_type": attachment.resolve_type(), - "type": "base64", - }, - } - for attachment in prompt.attachments - ], + "content": content, } ) else: