Parse a single session's data, including turns with images by using their captions.
(session_data: List[dict], session_id: int, date_time: str)
| 57 | session_summary: Dict[str, str] |
| 58 | |
| 59 | def parse_session(session_data: List[dict], session_id: int, date_time: str) -> Session: |
| 60 | """Parse a single session's data, including turns with images by using their captions.""" |
| 61 | turns = [] |
| 62 | for turn in session_data: |
| 63 | # For turns with images, combine caption and text |
| 64 | text = turn.get("text", "") |
| 65 | if "img_url" in turn and "blip_caption" in turn: |
| 66 | caption_text = f"[Image: {turn['blip_caption']}]" |
| 67 | if text: |
| 68 | text = f"{caption_text} {text}" |
| 69 | else: |
| 70 | text = caption_text |
| 71 | |
| 72 | turns.append(Turn( |
| 73 | speaker=turn["speaker"], |
| 74 | dia_id=turn["dia_id"], |
| 75 | text=text |
| 76 | )) |
| 77 | return Session(session_id=session_id, date_time=date_time, turns=turns) |
| 78 | |
| 79 | def parse_conversation(conv_data: dict) -> Conversation: |
| 80 | """Parse conversation data.""" |
no test coverage detected