Viewing File: /home/ubuntu/codegamaai-test/efimarket_bot/src/mongo_main.py

from pymongo import MongoClient
from src.constants import *
client = MongoClient(host=host, port=port, username=username, password=password, authSource=auth_db)


db = client[db_name]
collection_name = db[user_config_collection]
def config_main(data):
    existing_record = collection_name.find_one({"user_id": data["user_id"], "bot_id": data['bot_id']})
    if existing_record:
        # If record exists, use the existing data from the database
        result = existing_record
    else:
        # If record doesn't exist, insert the new data into the database
        data['chunk_size'] = 2000
        data['chunk_overlap'] = 0
        data['method_id'] = "method_1"
        data['model_name']= "gpt-3.5-turbo"
        data['token_limit']= 6000
        data['n_history_questions'] = 0
        data['n_doc_retirve'] = 3
        data['lambda_mult'] = 0.30
        data['algo'] = "similarity_score_threshold"
        collection_name.insert_one(data)
        result = data
    return result
Back to Directory File Manager