Skip to content

Commit

Permalink
fix: regext empty prompt in Gemini Pro Vision (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovik authored Jan 15, 2024
1 parent 1de1c1d commit dbe4401
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions aidial_adapter_vertexai/llm/gemini_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ async def parse_vision(
if image_count == 0:
return UserError("No image inputs were found", usage_message)

if any(msg.has_empty_content() for msg in download_result):
return UserError(
"Messages with empty prompts are not allowed", usage_message
)

history = list(map(to_content, download_result))
return cls(history=history[:-1], prompt=history[-1].parts)

Expand Down
3 changes: 3 additions & 0 deletions aidial_adapter_vertexai/llm/process_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class MessageWithInputs(BaseModel):
message: Message
image_inputs: List[ImageDataURL]

def has_empty_content(self) -> bool:
return (self.message.content or "").strip() == ""


class DownloadErrors(BaseModel):
"""Download errors for a particular message"""
Expand Down

0 comments on commit dbe4401

Please sign in to comment.