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

Filter out b64-encoded data before sending to LLM #870

Merged
merged 1 commit into from
Sep 4, 2024
Merged
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
6 changes: 3 additions & 3 deletions pydatalab/pydatalab/apps/chat/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ def _prepare_item_json_for_chat(self, item_id: str):
item_filenames = {
str(file["immutable_id"]): file["name"] for file in item_info.get("files", [])
}
for block in item_info.get("blocks_obj", {}).values():
block.pop("bokeh_plot_data", None)

block_fields_to_remove = ["item_id", "block_id"]
big_data_keys = ["bokeh_plot_data", "b64_encoded_image"]
for block in item_info.get("blocks_obj", {}).values():
block_fields_to_remove = ["item_id", "block_id", "collection_id"] + big_data_keys
[block.pop(field, None) for field in block_fields_to_remove]

# nmr block fields to remove (need a more general way to do this)
Expand Down