class MeetingMemoryBot:
def __init__(self, group_id: str, group_name: str):
self.group_id = group_id
self.group_name = group_name
self.bot_id = "bot_meeting_assistant"
def setup_meeting(self, participants: list, meeting_topic: str):
"""Initialize meeting with participants."""
all_participants = participants + [
{"user_id": self.bot_id, "name": "Meeting Bot", "role": "assistant"}
]
setup_group_chat(self.group_id, self.group_name, all_participants)
# Store meeting context
self._store_message(
f"Meeting started. Topic: {meeting_topic}. "
f"Participants: {', '.join(p['name'] for p in participants)}"
)
def _store_message(self, content: str, sender_id: str = None, sender_name: str = None):
"""Store a message from meeting."""
message = {
"group_id": self.group_id,
"group_name": self.group_name,
"message_id": str(uuid.uuid4()),
"create_time": datetime.now().isoformat() + "Z",
"sender": sender_id or self.bot_id,
"sender_name": sender_name or "Meeting Bot",
"content": content
}
requests.post(f"{BASE_URL}/api/v0/memories", json=message, headers=headers)
def record_discussion(self, speaker_id: str, speaker_name: str, content: str):
"""Record a discussion point."""
self._store_message(content, speaker_id, speaker_name)
def get_relevant_context(self, topic: str) -> str:
"""Retrieve context relevant to current discussion."""
# Search across this group's history
search_params = {
"group_ids": [self.group_id],
"query": topic,
"retrieve_method": "hybrid",
"top_k": 5,
"memory_types": ["episodic_memory"]
}
response = requests.get(f"{BASE_URL}/api/v0/memories/search", json=search_params, headers=headers)
memories = response.json().get("result", {}).get("memories", [])
if not memories:
return "No relevant past discussions found."
context_parts = ["Relevant past discussions:"]
for mem in memories:
context_parts.append(f"- {mem.get('memory_content', '')}")
return "\n".join(context_parts)
def generate_summary(self) -> str:
"""Generate meeting summary from recent memories."""
search_params = {
"group_ids": [self.group_id],
"query": "meeting discussion decisions action items",
"retrieve_method": "hybrid",
"top_k": 10,
"memory_types": ["episodic_memory"]
}
response = requests.get(f"{BASE_URL}/api/v0/memories/search", json=search_params, headers=headers)
memories = response.json().get("result", {}).get("memories", [])
# Use LLM to synthesize summary (placeholder)
return f"Meeting covered {len(memories)} discussion topics. [LLM summary here]"
# Usage
bot = MeetingMemoryBot("meeting_sprint_planning_2024_01", "Sprint Planning")
bot.setup_meeting(
participants=[
{"user_id": "user_alice", "name": "Alice"},
{"user_id": "user_bob", "name": "Bob"},
],
meeting_topic="Q1 Sprint Planning"
)
# During meeting
bot.record_discussion("user_alice", "Alice", "We should prioritize the auth refactor this sprint.")
bot.record_discussion("user_bob", "Bob", "Agreed. I can take the backend portion.")
# Get context when needed
context = bot.get_relevant_context("authentication system")
print(context) # Shows past discussions about auth