Spaces:
Runtime error
Runtime error
from pymongo import MongoClient | |
import datetime | |
import os | |
class ResponseDb: | |
def __init__(self): | |
# Set up the connection | |
mongodb_username=os.environ['mongodb_username'] | |
mongodb_pw=os.environ['mongodb_pw'] | |
mongodb_cluster_url=os.environ['mongodb_cluster_url'] | |
self.client = MongoClient(f"mongodb+srv://{mongodb_username}:{mongodb_pw}@{mongodb_cluster_url}/?retryWrites=true&w=majority") | |
self.db = self.client['vqa-game'] | |
self.collection = self.db['vqa-game'] | |
def add(self, dialogue_id, task_id, turn, question, response): | |
curr_datetime = datetime.datetime.now() | |
document = {"dialogue_id":dialogue_id, | |
"task_id":task_id, | |
"turn":turn, | |
"question":question, | |
"response":response, | |
"datetime":curr_datetime} | |
result = self.collection.insert_one(document) | |
def get(self): | |
return self.collection.find() | |