feat(schema): add FacialEmotionOutput for multimodal engine integration#26
Open
Kunal-Somani wants to merge 1 commit into
Open
feat(schema): add FacialEmotionOutput for multimodal engine integration#26Kunal-Somani wants to merge 1 commit into
Kunal-Somani wants to merge 1 commit into
Conversation
Adds schemas/multimodal_output_schema.py — a Pydantic wrapper around
GetEmotionPercentagesResponse that standardizes the facial API output
for consumption by the MultimodalSentimentEngine in sentiment-analysis-api.
Key additions:
- FacialEmotionOutput.from_response(): converts GetEmotionPercentagesResponse
into a validated Pydantic model with field-level range constraints (0-100%)
- to_multimodal_dict(): produces the {emotion_label: percentage} dict
format expected by MultimodalSentimentEngine.analyze(facial_emotions=...)
- dominant_emotion(): returns the top emotion and its confidence as a
(label, float) tuple — useful for logging and single-label summaries
This is the integration boundary between the two RUXAILAB sentiment repos:
the facial API produces GetEmotionPercentagesResponse, FacialEmotionOutput
converts it, and the multimodal engine fuses it with text and prosody.
Closes the gap identified in PR ruxailab#21 and ruxailab#22 where the two pipelines
had no shared contract.
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.
Summary
The facial-sentiment-analysis-api and sentiment-analysis-api currently have no shared contract — the facial API returns a
GetEmotionPercentagesResponse Pydantic model but there is no standardized way to convert that into the format the MultimodalSentimentEngine expects.
This PR adds that conversion layer.
New File —
schemas/multimodal_output_schema.pyFacialEmotionOutputis a Pydantic wrapper aroundGetEmotionPercentagesResponsethat exposes two conversion methods:from_response(response)Converts a
GetEmotionPercentagesResponseinto a validatedFacialEmotionOutputwith field-level range constraints (0.0–100.0 per emotion). Fails fast on out-of-range values rather than silently passing bad data downstream.to_multimodal_dict()Produces the
{emotion_label: percentage}dict format expected byMultimodalSentimentEngine.analyze(facial_emotions=...)in the sentiment-analysis-api repo (PR #39).dominant_emotion()Returns
(label, percentage)for the highest-scoring emotion — useful for logging and single-label summaries without reimplementingmax()at every call site.Integration Boundary
Example
Relation to GSoC 2026
This is the integration boundary between both RUXAILAB sentiment repos for the Multimodal Sentiment Analysis Engine project. PR #21 and #22 established consistent logging across both repos. This PR establishes the data contract between them.