Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitAuto: describe_image encountered an BadRequestError: Error code: 400 - {'error': {'message': "You uploa... #452

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ virtualenv==20.26.3
watchfiles==0.23.0
websockets==12.0
wrapt==1.16.0
Pillow==11.0.0
20 changes: 20 additions & 0 deletions services/openai/instructions/describe_image.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
from PIL import Image
import io

SUPPORTED_FORMATS = {'png', 'jpeg', 'gif', 'webp'}

def validate_and_convert_image(image_data, image_format):
if image_format.lower() in SUPPORTED_FORMATS:
return image_data
elif image_format.lower() == 'svg':
try:
# Convert SVG to PNG using Pillow
image = Image.open(io.BytesIO(image_data))
output = io.BytesIO()
image.save(output, format='PNG')
return output.getvalue()
except Exception as e:
raise ValueError(f"Error converting image: {str(e)}")
else:
raise ValueError("Unsupported image format")

DESCRIBE_IMAGE = """Analyze technical images from GitHub repositories with the depth and precision of a senior software engineer, focusing particularly on diagnostic content in issues and tickets.

Rather than providing broad surface-level observations, focus deeply on the most critical aspects relevant to the context - just as an experienced engineer would prioritize the key technical signals while debugging.
Expand Down