Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -20,9 +20,15 @@ class Mentor(Base):
|
|
20 |
|
21 |
id = Column(Integer, primary_key=True)
|
22 |
mentor_name = Column(String)
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
verified = Column(Boolean, default=False)
|
27 |
|
28 |
engine = create_engine(connection_string)
|
@@ -130,9 +136,23 @@ def get_mentor():
|
|
130 |
# Query verified mentors
|
131 |
verified_mentors = session.query(Mentor).filter_by(verified=True).all()
|
132 |
|
133 |
-
mentor_list = [
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
session.close()
|
138 |
|
@@ -261,6 +281,37 @@ def get_certificate():
|
|
261 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=False, return_full_text=False)
|
262 |
return jsonify({"ans": stream})
|
263 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
|
265 |
@app.route('/get_competition', methods=['POST'])
|
266 |
def get_competition():
|
|
|
20 |
|
21 |
id = Column(Integer, primary_key=True)
|
22 |
mentor_name = Column(String)
|
23 |
+
profile_photo = Column(LargeBinary) # Store mentor's profile photo as binary data
|
24 |
+
description = Column(String)
|
25 |
+
highest_degree = Column(String)
|
26 |
+
expertise = Column(String)
|
27 |
+
recent_project = Column(String)
|
28 |
+
meeting_time = Column(String)
|
29 |
+
fees = Column(String)
|
30 |
+
stream = Column(String)
|
31 |
+
country = Column(String)
|
32 |
verified = Column(Boolean, default=False)
|
33 |
|
34 |
engine = create_engine(connection_string)
|
|
|
136 |
# Query verified mentors
|
137 |
verified_mentors = session.query(Mentor).filter_by(verified=True).all()
|
138 |
|
139 |
+
mentor_list = []
|
140 |
+
for mentor in verified_mentors:
|
141 |
+
mentor_info = {
|
142 |
+
"id": mentor.id,
|
143 |
+
"mentor_name": mentor.mentor_name,
|
144 |
+
"profile_photo": mentor.profile_photo.decode('utf-8'), # Decode binary photo to string
|
145 |
+
"description": mentor.description,
|
146 |
+
"highest_degree": mentor.highest_degree,
|
147 |
+
"expertise": mentor.expertise,
|
148 |
+
"recent_project": mentor.recent_project,
|
149 |
+
"meeting_time": mentor.meeting_time,
|
150 |
+
"fees": mentor.fees,
|
151 |
+
"stream": mentor.stream,
|
152 |
+
"country": mentor.country,
|
153 |
+
"verified": mentor.verified
|
154 |
+
}
|
155 |
+
mentor_list.append(mentor_info)
|
156 |
|
157 |
session.close()
|
158 |
|
|
|
281 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=False, return_full_text=False)
|
282 |
return jsonify({"ans": stream})
|
283 |
|
284 |
+
@app.route('/get_three_streams', methods=['POST'])
|
285 |
+
def get_three_streams():
|
286 |
+
temperature = 0.9
|
287 |
+
max_new_tokens = 256
|
288 |
+
top_p = 0.95
|
289 |
+
repetition_penalty = 1.0
|
290 |
+
|
291 |
+
content = request.json
|
292 |
+
user_degree = content.get('degree') # Uncomment this line
|
293 |
+
|
294 |
+
|
295 |
+
generate_kwargs = dict(
|
296 |
+
temperature=temperature,
|
297 |
+
max_new_tokens=max_new_tokens,
|
298 |
+
top_p=top_p,
|
299 |
+
repetition_penalty=repetition_penalty,
|
300 |
+
do_sample=True,
|
301 |
+
seed=42,
|
302 |
+
)
|
303 |
+
prompt = f""" prompt:
|
304 |
+
You need to act like as recommendation engine for stream recommendation for a student based on user degree. Below are details.
|
305 |
+
Degree: {user_degree}
|
306 |
+
Based on above degree details recommend only 3 the streams
|
307 |
+
Note: Output should be list in below format:
|
308 |
+
[stream1, stream2, stream2]
|
309 |
+
Return only answer not prompt and unnecessary stuff, also dont add any special characters or punctuation marks
|
310 |
+
"""
|
311 |
+
formatted_prompt = format_prompt(prompt)
|
312 |
+
|
313 |
+
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=False, details=False, return_full_text=False)
|
314 |
+
return jsonify({"ans": stream})
|
315 |
|
316 |
@app.route('/get_competition', methods=['POST'])
|
317 |
def get_competition():
|