File tree Expand file tree Collapse file tree 1 file changed +31
-6
lines changed
Expand file tree Collapse file tree 1 file changed +31
-6
lines changed Original file line number Diff line number Diff line change 77from topStocks import get_top_stocks
88from agents import multi_ai
99from agno .agent import RunResponse
10+ import datetime
11+ import requests
1012
11-
12- load_dotenv (dotenv_path = ".env" )
13- GROQ_API_KEY = os .getenv ("api_key" )
14-
13+ GROQ_API_KEY = os .getenv ("GROQ_API_KEY" )
1514groq_client = groq .Client (api_key = GROQ_API_KEY )
1615
1716if not GROQ_API_KEY :
@@ -34,8 +33,34 @@ async def read_top_stocks():
3433 return stock_info
3534
3635@app .get ("/" )
37- def read_root ():
38- return {"message" : "Welcome to Investo!" }
36+ async def read_root ():
37+ return {"message" : "Welcome to the Investo-glow Backend API!" }
38+
39+
40+ @app .get ("health/" ) # Changed to GET since it's retrieving status
41+ async def health_check ():
42+ try :
43+ return {
44+ "status" : "healthy" ,
45+ "timestamp" : datetime .datetime .now ().isoformat (),
46+ "uptime" : "OK" ,
47+ "api" : {
48+ "groq_api" : "connected" if GROQ_API_KEY else "not configured" ,
49+ },
50+ "ip" : requests .client .host ,
51+ "services" : {
52+ "top_stocks" : app .url_path_for ("read_top_stocks" ),
53+ "chat" : app .url_path_for ("chat" ),
54+ "agent" : app .url_path_for ("ask" ),
55+ },
56+ }
57+
58+ except Exception as e :
59+ return {
60+ "status" : "unhealthy" ,
61+ "timestamp" : datetime .datetime .now ().isoformat (),
62+ "error" : str (e )
63+ }
3964
4065@app .get ("/chat" )
4166def chat (query : str ):
You can’t perform that action at this time.
0 commit comments