Spaces:
Running
Running
added more stuff
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
from io import BytesIO
|
2 |
from dotenv import load_dotenv
|
3 |
import os
|
4 |
-
from utils import google_search,split_text_into_chunks,insert_embeddings_into_pinecone_database,query_vector_database,generate_embedding_for_user_resume,delete_vector_namespace,create_user,login_user
|
5 |
from fastapi import FastAPI, File, UploadFile
|
6 |
from fastapi.responses import JSONResponse
|
7 |
import docx
|
@@ -241,6 +241,8 @@ Parameters:
|
|
241 |
|
242 |
"""
|
243 |
)
|
|
|
|
|
244 |
course_info = extract_course_info(response.text)
|
245 |
courses = get_course_func(query=course_info.CourseName)
|
246 |
return {"CourseInfo":course_info,"Courses":courses}
|
|
|
1 |
from io import BytesIO
|
2 |
from dotenv import load_dotenv
|
3 |
import os
|
4 |
+
from utils import google_search,split_text_into_chunks,insert_embeddings_into_pinecone_database,query_vector_database,generate_embedding_for_user_resume,delete_vector_namespace,create_user,login_user,create_questionaire
|
5 |
from fastapi import FastAPI, File, UploadFile
|
6 |
from fastapi.responses import JSONResponse
|
7 |
import docx
|
|
|
241 |
|
242 |
"""
|
243 |
)
|
244 |
+
questions=request.model_dump()
|
245 |
+
create_questionaire(db_uri=MONGO_URI,db_name="crayonics",collection_name="questionaire",document=questions)
|
246 |
course_info = extract_course_info(response.text)
|
247 |
courses = get_course_func(query=course_info.CourseName)
|
248 |
return {"CourseInfo":course_info,"Courses":courses}
|
utils.py
CHANGED
@@ -142,6 +142,34 @@ def create_user(db_uri: str, db_name: str, collection_name: str, document: dict)
|
|
142 |
|
143 |
# Close the connection
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
|
147 |
|
|
|
142 |
|
143 |
# Close the connection
|
144 |
|
145 |
+
|
146 |
+
def create_questionaire(db_uri: str, db_name: str, collection_name: str, document: dict) -> str:
|
147 |
+
"""
|
148 |
+
Inserts a new document into the specified MongoDB collection.
|
149 |
+
|
150 |
+
Parameters:
|
151 |
+
db_uri (str): MongoDB connection URI.
|
152 |
+
db_name (str): Name of the database.
|
153 |
+
collection_name (str): Name of the collection.
|
154 |
+
document (dict): The document to insert.
|
155 |
+
|
156 |
+
Returns:
|
157 |
+
str: The ID of the inserted document.
|
158 |
+
"""
|
159 |
+
# Connect to MongoDB
|
160 |
+
client = MongoClient(db_uri)
|
161 |
+
db = client[db_name]
|
162 |
+
collection = db[collection_name]
|
163 |
+
|
164 |
+
# Insert the document
|
165 |
+
result = collection.insert_one(document)
|
166 |
+
client.close()
|
167 |
+
return str(result.inserted_id)
|
168 |
+
|
169 |
+
|
170 |
+
# Close the connection
|
171 |
+
|
172 |
+
|
173 |
|
174 |
|
175 |
|