aboutsummaryrefslogtreecommitdiff
path: root/call_transcript_utils.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2023-10-13 23:50:10 -0600
committerNavan Chauhan <navanchauhan@gmail.com>2023-10-13 23:50:10 -0600
commit9f914f8d479d58d7ccc045784fe614dfea9a1219 (patch)
treedb5a58ae9bdae7a7aa139c6220e048c359657298 /call_transcript_utils.py
parent6edba6384b42fa03785ac5887e91eb310e876ced (diff)
langchain
Diffstat (limited to 'call_transcript_utils.py')
-rw-r--r--call_transcript_utils.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/call_transcript_utils.py b/call_transcript_utils.py
new file mode 100644
index 0000000..ce0764c
--- /dev/null
+++ b/call_transcript_utils.py
@@ -0,0 +1,32 @@
+import os
+from typing import Optional
+
+CALL_TRANSCRIPTS_DIR = os.path.join(os.path.dirname(__file__), "call_transcripts")
+
+
+def add_transcript(conversation_id: str, transcript: str) -> None:
+ transcript_path = os.path.join(
+ CALL_TRANSCRIPTS_DIR, "{}.txt".format(conversation_id)
+ )
+ with open(transcript_path, "a") as f:
+ f.write(transcript)
+
+
+def get_transcript(conversation_id: str) -> Optional[str]:
+ transcript_path = os.path.join(
+ CALL_TRANSCRIPTS_DIR, "{}.txt".format(conversation_id)
+ )
+ if os.path.exists(transcript_path):
+ with open(transcript_path, "r") as f:
+ return f.read()
+ return None
+
+
+def delete_transcript(conversation_id: str) -> bool:
+ transcript_path = os.path.join(
+ CALL_TRANSCRIPTS_DIR, "{}.txt".format(conversation_id)
+ )
+ if os.path.exists(transcript_path):
+ os.remove(transcript_path)
+ return True
+ return False