feat(max): add image attachments#12
Open
lordspline wants to merge 2 commits into
Open
Conversation
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
| attachment_ids=serializer.validated_data.get("attachment_ids", []), | ||
| ) | ||
| except AttachmentNotFoundError as error: | ||
| raise serializers.ValidationError({"attachment_ids": str(error)}) from error |
| except AttachmentNotFoundError as error: | ||
| raise serializers.ValidationError({"attachment_ids": str(error)}) from error | ||
| except AttachmentValidationError as error: | ||
| raise serializers.ValidationError({"attachment_ids": str(error)}) from error |
| attachment_ids=serializer.validated_data.get("attachment_ids", []), | ||
| ) | ||
| except AttachmentNotFoundError as error: | ||
| raise serializers.ValidationError({"attachment_ids": str(error)}) from error |
| except AttachmentNotFoundError as error: | ||
| raise serializers.ValidationError({"attachment_ids": str(error)}) from error | ||
| except AttachmentValidationError as error: | ||
| raise serializers.ValidationError({"attachment_ids": str(error)}) from error |
| uploaded_file=uploaded_file, | ||
| ) | ||
| except AttachmentValidationError as error: | ||
| raise serializers.ValidationError({"file": str(error)}) from error |
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Users need to share screenshots with PostHog AI for context about their data, dashboards, or error states. The existing attachment system (
UploadedMedia) is public/unauthenticated and unsuitable for AI conversations, which may contain private product data.Changes
Backend
ConversationAttachmentmodel with team/user/conversation scoping, status tracking, and indexes for efficient queries/api/projects/:team_id/conversation_attachments/endpoints for multipart upload and delete with authorization checksposthog/storage/object_storagewrappersModel conversion
HumanMessageschema withattachmentsfield carrying small authorized references$ai_generationtraces)Frontend
QuestionInputcomponent with visual preview chipsmaxThreadLogicwith upload progress, error handling, and retry logicconversationAttachmentsCreate,conversationAttachmentsDestroy) from OpenAPIOther
0004_conversation_attachments.pyContentType.IMAGE_PNG,ContentType.IMAGE_JPEG)How did you test this code?
ee/hogai/utils/test/test_anthropic.py,ee/hogai/utils/test/test_openai.py,ee/api/test/test_conversation.py,products/posthog_ai/backend/api/test_conversation_attachments.py,ee/hogai/core/test/test_ai_event_truncation.py— 134 passedfrontend/src/scenes/max/maxThreadLogic.test.ts,frontend/src/scenes/max/components/QuestionInput.test.tsx— 113 passed, TypeScript check passedhas_image=truein/v1/messages?beta=truerequest👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Automatic notifications
Docs update
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented safe v1 PNG/JPEG screenshot attachments for PostHog AI per issue PostHog#62926. Key architectural decisions:
ConversationAttachmentmodel) instead of reusingUploadedMedia, which is intentionally public/unauthenticated$ai_generationtracesenabled: false) because file upload is a user UI capability, not an agent tool capabilityAll generated schema/API/MCP artifacts were regenerated from the backend changes. Tests cover the full lifecycle from UI upload through model gateway.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.