forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.py
More file actions
38 lines (38 loc) · 1.3 KB
/
Copy pathrouter.py
File metadata and controls
38 lines (38 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# import json
# import os
#
# from fastapi import APIRouter
# from mem0 import MemoryClient
#
# from models import Conversation, EndpointResponse
#
# router = APIRouter()
#
#
# # **************************************************
# # ************ On Conversation Created Plugin ************
# # **************************************************
#
#
# @router.post("/mem0", response_model=EndpointResponse, tags=["mem0"])
# def mem0_add(conversation: Conversation, uid: str):
# transcript_segments = conversation.transcript_segments
# messages = []
# for segment in transcript_segments:
# messages.append(
# {
# "role": "user" if segment.is_user else "assistant",
# "content": segment.text,
# }
# )
# # Had to move here because initialization causes issues with modal
# if not messages:
# return {"message": "No messages found"}
#
# mem0 = MemoryClient(api_key=os.getenv("MEM0_API_KEY"))
# mem0.add(messages, user_id=uid)
# memories = mem0.search(json.dumps(messages), user_id=uid)
# response = [row["memory"] for row in memories]
# response_str = "\n".join(response)
# # TODO: make response 10-15 words. This will be triggered as notification.
# return {"message": f"User memories: {response_str}"}