Nattyboi commited on
Commit
b8433cb
·
1 Parent(s): 37d0d50

completed this shit

Browse files
Files changed (2) hide show
  1. app.py +24 -24
  2. utils.py +4 -2
app.py CHANGED
@@ -247,35 +247,35 @@ Parameters:
247
  loop = asyncio.new_event_loop()
248
  asyncio.set_event_loop(loop)
249
 
250
- # Create the Gemini client after the event loop is set up
251
- client = genai.Client(api_key=GEMINI_API_KEY)
252
-
253
- response = client.models.generate_content(
254
- model="gemini-2.0-flash",
255
- contents=f"""
256
- please respond with a JSON object that contains the following keys as a response:
257
- - "coursename": the name of the recommended course,
258
- - "completiontime": an estimate of how long it would take to complete the course.
259
- Do not include any extra text.
260
- Recommend a course using this information below :
261
- Which of the following best describes you?: {request.employmentStatus}
262
- Would you like to prepare for an interim role to gain experience and income while pursuing your dream job?: {request.interimRole}
263
- What is your desired role?: {request.dreamRole}
264
- Why do you want to achieve this desired role?: {request.motivation}
265
- How do you prefer to learn new skills?: {request.learningPreference}
266
- How many hours per day can you dedicate to learning?: {request.timeCommitmentPerDay}
267
- What are the biggest challenges or obstacles you face in reaching your dream role?: {request.challenges}
268
- What is your ideal timeframe for achieving your dream role?: {request.timeframeToAchieveDreamRole}
269
 
270
 
271
- """
272
- )
273
  questions=request.model_dump()
274
  questions['userId']=decoded_user_id
275
  create_questionaire(db_uri=MONGO_URI,db_name="crayonics",collection_name="Questionaire",document=questions)
276
- course_info = extract_course_info(response.text)
277
- courses = get_course_func(query=course_info.courseName)
278
- return {"courseInfo":course_info,"courses":courses}
279
 
280
 
281
 
 
247
  loop = asyncio.new_event_loop()
248
  asyncio.set_event_loop(loop)
249
 
250
+ # # Create the Gemini client after the event loop is set up
251
+ # client = genai.Client(api_key=GEMINI_API_KEY)
252
+
253
+ # response = client.models.generate_content(
254
+ # model="gemini-2.0-flash",
255
+ # contents=f"""
256
+ # please respond with a JSON object that contains the following keys as a response:
257
+ # - "coursename": the name of the recommended course,
258
+ # - "completiontime": an estimate of how long it would take to complete the course.
259
+ # Do not include any extra text.
260
+ # Recommend a course using this information below :
261
+ # Which of the following best describes you?: {request.employmentStatus}
262
+ # Would you like to prepare for an interim role to gain experience and income while pursuing your dream job?: {request.interimRole}
263
+ # What is your desired role?: {request.dreamRole}
264
+ # Why do you want to achieve this desired role?: {request.motivation}
265
+ # How do you prefer to learn new skills?: {request.learningPreference}
266
+ # How many hours per day can you dedicate to learning?: {request.timeCommitmentPerDay}
267
+ # What are the biggest challenges or obstacles you face in reaching your dream role?: {request.challenges}
268
+ # What is your ideal timeframe for achieving your dream role?: {request.timeframeToAchieveDreamRole}
269
 
270
 
271
+ # """
272
+ # )
273
  questions=request.model_dump()
274
  questions['userId']=decoded_user_id
275
  create_questionaire(db_uri=MONGO_URI,db_name="crayonics",collection_name="Questionaire",document=questions)
276
+ # course_info = extract_course_info(response.text)
277
+ # courses = get_course_func(query=course_info.courseName)
278
+ return {"courseInfo":"course_info","courses":"courses"}
279
 
280
 
281
 
utils.py CHANGED
@@ -171,9 +171,11 @@ def create_questionaire(db_uri: str, db_name: str, collection_name: str, documen
171
 
172
  # Insert the document
173
 
174
- result= collection.find_one_and_replace(filter={"user_id":document.get("user_id")},replacement=document)
175
- if result:
 
176
  result = collection.insert_one(document)
 
177
  return str(result.inserted_id)
178
 
179
  client.close()
 
171
 
172
  # Insert the document
173
 
174
+ result= collection.find_one_and_replace(filter={"userId":document.get("userId")},replacement=document)
175
+ print(result)
176
+ if result==None:
177
  result = collection.insert_one(document)
178
+ print(result)
179
  return str(result.inserted_id)
180
 
181
  client.close()