a9 commited on
Commit
fe0078f
·
verified ·
1 Parent(s): 02db71e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -7
app.py CHANGED
@@ -5,7 +5,11 @@ from pydantic import BaseModel
5
  from typing import Optional, List
6
  import os
7
  from google import genai
8
- from google.genai import types
 
 
 
 
9
 
10
  Api_key = os.getenv('API_KEY')
11
  client = genai.Client(api_key=Api_key)
@@ -72,23 +76,30 @@ def call_gemini(history: List[types.Content]):
72
  except Exception as e:
73
  print(f"GenAI Error: {e}")
74
  raise HTTPException(status_code=500, detail="AI Generation Failed")
75
-
76
 
 
 
77
  @app.post("/gen/task")
78
  def generate_tasks(req: TaskRequest):
79
  project_notes = [n for n in req.notes if n.type == "project"]
80
  random_notes = [n for n in req.notes if n.type == "random"]
81
 
82
- userPrompt = ""
 
 
 
 
 
 
83
  for note in project_notes:
84
- userPrompt = userPrompt + note.details
85
 
86
  for note in random_notes:
87
- userPrompt = userPrompt + note.details
88
 
89
  history = [
90
- types.Content(role="system", parts=[types.Part(text= sysPrompt)]),
91
- types.Content(role="user", parts=[types.Part(text= userPrompt)])
92
  ]
93
 
94
  text = call_gemini(history)
 
5
  from typing import Optional, List
6
  import os
7
  from google import genai
8
+ from google.genai import types
9
+
10
+ from datetime import datetime
11
+ import pytz
12
+
13
 
14
  Api_key = os.getenv('API_KEY')
15
  client = genai.Client(api_key=Api_key)
 
76
  except Exception as e:
77
  print(f"GenAI Error: {e}")
78
  raise HTTPException(status_code=500, detail="AI Generation Failed")
 
79
 
80
+
81
+ # Inside your generate_tasks function:
82
  @app.post("/gen/task")
83
  def generate_tasks(req: TaskRequest):
84
  project_notes = [n for n in req.notes if n.type == "project"]
85
  random_notes = [n for n in req.notes if n.type == "random"]
86
 
87
+ # Get current date in India (IST)
88
+ tz = pytz.timezone('Asia/Kolkata')
89
+ current_date = datetime.now(tz).strftime("%A, %B %d, %Y")
90
+
91
+ # Initialize prompt with today's date context
92
+ userPrompt = f"Today's Date: {current_date}\n\n"
93
+
94
  for note in project_notes:
95
+ userPrompt = userPrompt + note.details + "\n"
96
 
97
  for note in random_notes:
98
+ userPrompt = userPrompt + note.details + "\n"
99
 
100
  history = [
101
+ types.Content(role="system", parts=[types.Part(text=sysPrompt)]),
102
+ types.Content(role="user", parts=[types.Part(text=userPrompt)])
103
  ]
104
 
105
  text = call_gemini(history)