Skip to content

Commit 1baa66f

Browse files
author
yashksaini-coder
committed
fix: update GROQ API key environment variable and enhance health check endpoint
1 parent 6d54474 commit 1baa66f

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

app.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
from topStocks import get_top_stocks
88
from agents import multi_ai
99
from 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")
1514
groq_client = groq.Client(api_key=GROQ_API_KEY)
1615

1716
if 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")
4166
def chat(query: str):

0 commit comments

Comments
 (0)