Skip to content

Commit

Permalink
use filename not extension
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEdmondson1234 committed Dec 4, 2024
1 parent 2bc96b7 commit ddcee50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

version = '0.113.1'
version = '0.113.2'

setup(
name='sunholo',
Expand Down
8 changes: 5 additions & 3 deletions sunholo/gcs/add_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def handle_base64_image(base64_data: str, vector_name: str, extension: str):
raise ValueError(f"Invalid Base64 image data: Missing metadata header {base64_data}")

if model.startswith("openai"): # pass it to gpt directly
return base64_data, base64_data.split(",", 1)
mime_type = base64_data.split(",", 1)
log.info(f"Returning directly as openai - mime_type: {mime_type}")
return base64_data, mime_type

try:
header, encoded = base64_data.split(",", 1)
Expand All @@ -58,8 +60,8 @@ def handle_base64_image(base64_data: str, vector_name: str, extension: str):
image_uri = add_file_to_gcs(filename, vector_name)
os.remove(filename) # Clean up the saved file

# Determine MIME type based on extension
mime_type = guess_mime_type(extension) or "application/octet-stream"
# Determine MIME type based on filename
mime_type = guess_mime_type(filename) or "application/octet-stream"

return image_uri, mime_type
except Exception as e:
Expand Down

0 comments on commit ddcee50

Please sign in to comment.