alaselababatunde commited on
Commit
b7b4178
·
1 Parent(s): 84bcecf
Files changed (2) hide show
  1. main.py +4 -4
  2. static/main.css +7 -3
main.py CHANGED
@@ -124,15 +124,15 @@ def get_ai_response(question: str) -> str:
124
 
125
  @app.get("/", response_class=HTMLResponse)
126
  async def index(request: Request):
127
- device_id = request.cookies.get("device_id")
128
- if not device_id:
129
- device_id = str(uuid.uuid4())
130
 
131
  if device_id not in chat_sessions:
132
  chat_sessions[device_id] = []
133
 
134
  response = templates.TemplateResponse("index.html", {"request": request, "chat_history": chat_sessions[device_id]})
135
- response.set_cookie(key="device_id", value=device_id)
 
136
  return response
137
 
138
  @app.post("/ask")
 
124
 
125
  @app.get("/", response_class=HTMLResponse)
126
  async def index(request: Request):
127
+ # Forcing a new session on page refresh as requested
128
+ device_id = str(uuid.uuid4())
 
129
 
130
  if device_id not in chat_sessions:
131
  chat_sessions[device_id] = []
132
 
133
  response = templates.TemplateResponse("index.html", {"request": request, "chat_history": chat_sessions[device_id]})
134
+ # Set the cookie with a short max_age or just as a session cookie
135
+ response.set_cookie(key="device_id", value=device_id, httponly=True)
136
  return response
137
 
138
  @app.post("/ask")
static/main.css CHANGED
@@ -18,20 +18,23 @@
18
  }
19
 
20
  body {
21
- height: 100vh;
22
  width: 100vw;
23
  background: var(--theo-green);
24
  background-image: var(--bg-gradient);
 
25
  display: flex;
26
  align-items: center;
27
  justify-content: center;
28
- overflow: hidden;
 
29
  }
30
 
31
  .chat-container {
32
  width: 100%;
33
  max-width: 900px;
34
- height: 90vh;
 
35
  background: var(--glass);
36
  backdrop-filter: blur(20px);
37
  -webkit-backdrop-filter: blur(20px);
@@ -42,6 +45,7 @@ body {
42
  overflow: hidden;
43
  border: 1px solid var(--glass-border);
44
  position: relative;
 
45
  }
46
 
47
  .chat-header {
 
18
  }
19
 
20
  body {
21
+ min-height: 100vh;
22
  width: 100vw;
23
  background: var(--theo-green);
24
  background-image: var(--bg-gradient);
25
+ background-attachment: fixed;
26
  display: flex;
27
  align-items: center;
28
  justify-content: center;
29
+ overflow-y: auto;
30
+ padding: 20px 0;
31
  }
32
 
33
  .chat-container {
34
  width: 100%;
35
  max-width: 900px;
36
+ height: 85vh;
37
+ min-height: 500px;
38
  background: var(--glass);
39
  backdrop-filter: blur(20px);
40
  -webkit-backdrop-filter: blur(20px);
 
45
  overflow: hidden;
46
  border: 1px solid var(--glass-border);
47
  position: relative;
48
+ margin: 20px;
49
  }
50
 
51
  .chat-header {