Commit
·
e47f5a2
1
Parent(s):
dd28a16
updated app.py
Browse files
app.py
CHANGED
|
@@ -3,8 +3,9 @@ import os
|
|
| 3 |
import copy
|
| 4 |
import sqlite3
|
| 5 |
import operator
|
| 6 |
-
from fastapi import FastAPI, Query
|
| 7 |
from math import ceil
|
|
|
|
|
|
|
| 8 |
from datetime import datetime, timedelta
|
| 9 |
from collections import defaultdict
|
| 10 |
from langchain_openai import ChatOpenAI
|
|
@@ -16,14 +17,6 @@ from langgraph.graph import StateGraph, START, END
|
|
| 16 |
from langgraph.constants import Send
|
| 17 |
from fastapi.responses import HTMLResponse
|
| 18 |
|
| 19 |
-
|
| 20 |
-
# Initialize FastAPI app
|
| 21 |
-
app = FastAPI(
|
| 22 |
-
title="JEE Roadmap Planner API",
|
| 23 |
-
description="API for managing and analyzing JEE Roadmaps",
|
| 24 |
-
version="1.0.0"
|
| 25 |
-
)
|
| 26 |
-
|
| 27 |
# Session State replacement
|
| 28 |
session_state = {
|
| 29 |
"data": None,
|
|
@@ -35,7 +28,8 @@ session_state = {
|
|
| 35 |
|
| 36 |
|
| 37 |
# AGENT 1
|
| 38 |
-
|
|
|
|
| 39 |
try:
|
| 40 |
with open('fourdayRoadmap.json', 'r') as file:
|
| 41 |
data = json.load(file)
|
|
@@ -47,6 +41,15 @@ def load_initial_data():
|
|
| 47 |
except Exception as e:
|
| 48 |
return False
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
# Function to mark tasks as incomplete
|
| 51 |
def process_task_completion_data():
|
| 52 |
data = session_state.data
|
|
|
|
| 3 |
import copy
|
| 4 |
import sqlite3
|
| 5 |
import operator
|
|
|
|
| 6 |
from math import ceil
|
| 7 |
+
from fastapi import FastAPI, Query
|
| 8 |
+
from contextlib import asynccontextmanager
|
| 9 |
from datetime import datetime, timedelta
|
| 10 |
from collections import defaultdict
|
| 11 |
from langchain_openai import ChatOpenAI
|
|
|
|
| 17 |
from langgraph.constants import Send
|
| 18 |
from fastapi.responses import HTMLResponse
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# Session State replacement
|
| 21 |
session_state = {
|
| 22 |
"data": None,
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
# AGENT 1
|
| 31 |
+
@asynccontextmanager
|
| 32 |
+
async def lifespan(app: FastAPI):
|
| 33 |
try:
|
| 34 |
with open('fourdayRoadmap.json', 'r') as file:
|
| 35 |
data = json.load(file)
|
|
|
|
| 41 |
except Exception as e:
|
| 42 |
return False
|
| 43 |
|
| 44 |
+
# Initialize FastAPI app
|
| 45 |
+
app = FastAPI(
|
| 46 |
+
title="JEE Roadmap Planner API",
|
| 47 |
+
description="API for managing and analyzing JEE Roadmaps",
|
| 48 |
+
version="1.0.0",
|
| 49 |
+
lifespan=lifespan
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
# Function to mark tasks as incomplete
|
| 54 |
def process_task_completion_data():
|
| 55 |
data = session_state.data
|