-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: Implement indexed file saving to populate url and remove b64 da… #4963
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
Conversation
…ta before saving it to db
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Optimizes image handling in chat responses by replacing base64 data storage with URL references to saved files.
- Introduces
IndexedData
andIndexedResult
infile_store/utils.py
to maintain order while saving multiple files concurrently - Adds
cleaned_image_responses
field toAnswerPostInfo
model for storing optimized image URLs - Centralizes tool name constants in new
constants.py
file for better maintainability - Modifies
image_generation_tool.py
to support both URL and base64 formats based on configuration - Implements helper functions in
process_message.py
for separate handling of URL and base64 content
7 files reviewed, 2 comments
Edit PR Review Bot Settings | Greptile
# Store cleaned image responses with URLs for later tool_result cleaning | ||
cleaned_image_responses: list[Any] | None = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: This field should use a more specific type than 'Any' to ensure type safety. Consider creating a dedicated type/class for image responses or at minimum use a type like 'list[dict[str, str]]' to better document the expected structure.
# Combine all tasks with their indices | ||
funcs: list[ | ||
tuple[ | ||
Callable[[IndexedData | None, IndexedData | None], IndexedResult], | ||
tuple[IndexedData | None, IndexedData | None], | ||
] | ||
] = [(save_file_indexed, (indexed_url, None)) for indexed_url in indexed_urls] + [ | ||
(save_file_indexed, (None, indexed_base64)) | ||
for indexed_base64 in indexed_base64_files | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Type hints for funcs could be simplified with type alias to improve readability
This PR is stale because it has been open 75 days with no activity. Remove stale label or comment or this will be closed in 15 days. |
This PR was closed because it has been stalled for 90 days with no activity. |
Description
Replacing base64 data with the URL of the newly created file in the image tool result.
How Has This Been Tested?
From UI and confirmed in the DB.
Backporting (check the box to trigger backport action)
Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.