def add_prompt_to_db()

in web-backend/backendUtils/db.py [0:0]


def add_prompt_to_db(prompt_data: dict):
    """
    Create a new prompt document in the prompts container.
    Assumes the document's 'id' is either provided or generated.
    """
    try:
        created_item = prompts_container.create_item(body=prompt_data)
        logging.info(f"Prompt created with id: {created_item['id']}")
        return created_item
    except exceptions.CosmosHttpResponseError as e:
        logging.error(f"Error creating prompt: {str(e)}")
        return None