SamVidur commited on
Commit
e806ae8
·
unverified ·
1 Parent(s): a4f2d89

Update tp_final.py

Browse files
Files changed (1) hide show
  1. tp_final.py +6 -10
tp_final.py CHANGED
@@ -216,12 +216,14 @@ except Exception as e:
216
 
217
  # --- Pydantic Models for Request/Response ---
218
  class AnalysisRequest(BaseModel):
219
- username: str = "sameer" # Default as per your code
 
220
  user_journal: str
221
  # Add other fields here if you need to pass user_journal dynamically later
222
 
223
  class AnalysisResponse(BaseModel):
224
  status: str
 
225
  username: str
226
  guidelines: Dict[str, Any]
227
  recommended_tasks: List[str]
@@ -235,14 +237,7 @@ async def cron_test():
235
 
236
  @app.post("/analyze-tasks", response_model=AnalysisResponse)
237
  def generate_analysis(request: AnalysisRequest):
238
- """
239
- Executes the analysis pipeline:
240
- 1. Identifies direct/indirect problems via Groq.
241
- 2. Generates guidelines via Groq.
242
- 3. Matches problems to Yoga tasks using TF-IDF/Cosine Similarity.
243
- 4. Saves to MongoDB.
244
- """
245
-
246
  example = get_file_data("example.json")
247
  direcindirecprompt = f'''
248
  I'll be giving you a journal entry written by a user. Your task is to extract out problems being faced by the user in the following format:
@@ -421,7 +416,8 @@ def generate_analysis(request: AnalysisRequest):
421
  guidelines_obj = {"raw_text": guidegroq_response}
422
 
423
  chat_document = {
424
- "user_id": request.username,
 
425
  "timestamp": datetime.now(),
426
  "problemdesc": direcindirecgroq_response, # Storing raw response string as per original code
427
  "guidelines": guidegroq_response, # Storing raw response string as per original code
 
216
 
217
  # --- Pydantic Models for Request/Response ---
218
  class AnalysisRequest(BaseModel):
219
+ user_id: str
220
+ username: str # Default as per your code
221
  user_journal: str
222
  # Add other fields here if you need to pass user_journal dynamically later
223
 
224
  class AnalysisResponse(BaseModel):
225
  status: str
226
+ user_id: str
227
  username: str
228
  guidelines: Dict[str, Any]
229
  recommended_tasks: List[str]
 
237
 
238
  @app.post("/analyze-tasks", response_model=AnalysisResponse)
239
  def generate_analysis(request: AnalysisRequest):
240
+
 
 
 
 
 
 
 
241
  example = get_file_data("example.json")
242
  direcindirecprompt = f'''
243
  I'll be giving you a journal entry written by a user. Your task is to extract out problems being faced by the user in the following format:
 
416
  guidelines_obj = {"raw_text": guidegroq_response}
417
 
418
  chat_document = {
419
+ "user_id": request.user_id,
420
+ "username": request.username,
421
  "timestamp": datetime.now(),
422
  "problemdesc": direcindirecgroq_response, # Storing raw response string as per original code
423
  "guidelines": guidegroq_response, # Storing raw response string as per original code