Skip to content

Commit

Permalink
Use system message for attachment content
Browse files Browse the repository at this point in the history
  • Loading branch information
markwaddle committed Oct 23, 2024
1 parent f62b63e commit b5c20d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ async def get_completion_messages_for_attachments(
]

messages.append({
"role": "user",
"role": "system",
"content": content,
})

Expand Down
4 changes: 2 additions & 2 deletions libraries/python/openai-client/openai_client/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ def get_image_dims(image_uri: str) -> tuple[int, int]:
# From https://github.com/openai/openai-cookbook/pull/881/files
if re.match(r"data:image\/\w+;base64", image_uri):
image_uri = re.sub(r"data:image\/\w+;base64,", "", image_uri)
image = Image.open(BytesIO(base64.b64decode(image_uri)))
return image.size
with Image.open(BytesIO(base64.b64decode(image_uri))) as image:
return image.size
else:
raise ValueError("Image must be a base64 string.")

Expand Down

0 comments on commit b5c20d9

Please sign in to comment.