Spaces:
Sleeping
Sleeping
Nagesh Muralidhar
commited on
Commit
·
b66dccc
1
Parent(s):
3f968e0
midterm-submission
Browse files- server/workflow.py +0 -42
server/workflow.py
CHANGED
|
@@ -12,48 +12,6 @@ logger = logging.getLogger(__name__)
|
|
| 12 |
# Load environment variables
|
| 13 |
load_dotenv()
|
| 14 |
|
| 15 |
-
# Create transcripts directory if it doesn't exist
|
| 16 |
-
TRANSCRIPTS_DIR = os.path.join(os.path.dirname(__file__), "transcripts")
|
| 17 |
-
os.makedirs(TRANSCRIPTS_DIR, exist_ok=True)
|
| 18 |
-
TRANSCRIPTS_FILE = os.path.join(TRANSCRIPTS_DIR, "podcasts.json")
|
| 19 |
-
|
| 20 |
-
def save_transcript(podcast_script: str, user_query: str) -> None:
|
| 21 |
-
"""Save podcast transcript to JSON file."""
|
| 22 |
-
# Create new transcript entry
|
| 23 |
-
transcript = {
|
| 24 |
-
"id": str(uuid.uuid4()),
|
| 25 |
-
"podcastScript": podcast_script,
|
| 26 |
-
"topic": user_query
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
try:
|
| 30 |
-
# Load existing transcripts
|
| 31 |
-
if os.path.exists(TRANSCRIPTS_FILE):
|
| 32 |
-
try:
|
| 33 |
-
with open(TRANSCRIPTS_FILE, 'r') as f:
|
| 34 |
-
transcripts = json.load(f)
|
| 35 |
-
if not isinstance(transcripts, list):
|
| 36 |
-
transcripts = []
|
| 37 |
-
except json.JSONDecodeError:
|
| 38 |
-
transcripts = []
|
| 39 |
-
else:
|
| 40 |
-
transcripts = []
|
| 41 |
-
|
| 42 |
-
# Append new transcript
|
| 43 |
-
transcripts.append(transcript)
|
| 44 |
-
|
| 45 |
-
# Save updated transcripts
|
| 46 |
-
with open(TRANSCRIPTS_FILE, 'w') as f:
|
| 47 |
-
json.dump(transcripts, f, indent=2)
|
| 48 |
-
|
| 49 |
-
except Exception as e:
|
| 50 |
-
print(f"Error saving transcript: {str(e)}")
|
| 51 |
-
# Create directory if it doesn't exist
|
| 52 |
-
os.makedirs(os.path.dirname(TRANSCRIPTS_FILE), exist_ok=True)
|
| 53 |
-
# Try to save just this transcript
|
| 54 |
-
with open(TRANSCRIPTS_FILE, 'w') as f:
|
| 55 |
-
json.dump([transcript], f, indent=2)
|
| 56 |
-
|
| 57 |
class AgentState(TypedDict):
|
| 58 |
messages: List[Dict[str, Any]]
|
| 59 |
current_agent: str
|
|
|
|
| 12 |
# Load environment variables
|
| 13 |
load_dotenv()
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
class AgentState(TypedDict):
|
| 16 |
messages: List[Dict[str, Any]]
|
| 17 |
current_agent: str
|