MCPcopy Create free account
hub / github.com/InternScience/InternAgent / parse_session

Function parse_session

tasks/AutoMem/run_0/code/load_dataset.py:59–77  ·  view source on GitHub ↗

Parse a single session's data, including turns with images by using their captions.

(session_data: List[dict], session_id: int, date_time: str)

Source from the content-addressed store, hash-verified

57 session_summary: Dict[str, str]
58
59def 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
79def parse_conversation(conv_data: dict) -> Conversation:
80 """Parse conversation data."""

Callers 1

parse_conversationFunction · 0.70

Calls 3

TurnClass · 0.70
SessionClass · 0.70
getMethod · 0.45

Tested by

no test coverage detected