Repository: stanford-oval/storm
File: knowledge_storm/utils.py (Python)

Code before:
            batch_size: int = 64,
            chunk_size: int = 500,
            chunk_overlap: int = 100,
            collection_name: str = "my_documents",
            vector_store_path: str = None,
            url: str =  None,
            qdrant_api_key: str = None,
            embedding_model: str = 'BAAI/bge-m3',
            device: str = "mps",
    ):
        """
        Takes a CSV file where each row is a document and has columns for content, title, url, and description.
        Then it converts all these documents in the content column to vectors and add them the Qdrant collection.

        Args:
            vector_store_path (str): Path to the directory where the vector store is stored or will be stored. 
            vector_db_mode (str): Mode of the Qdrant vector store (offline or online).
            file_path (str): Path to the CSV file.
            content_column (str): Name of the column containing the content.
            title_column (str): Name of the column containing the title. Default is "title".
            url_column (str): Name of the column containing the URL. Default is "url".
            desc_column (str): Name of the column containing the description. Default is "description".
            batch_size (int): Batch size for adding documents to the collection.
            chunk_size: Size of each chunk if you need to build the vector store from documents.
            chunk_overlap: Overlap between chunks if you need to build the vector store from documents.
            collection_name: Name of the Qdrant collection.
            embedding_model: Name of the Hugging Face embedding model.
            device: Device to run the embeddings model on, can be "mps", "cuda", "cpu".
            qdrant_api_key: API key for the Qdrant server (Only required if the Qdrant server is online).
        """

        model_kwargs = {"device": device}
        encode_kwargs = {"normalize_embeddings": True}
        model = HuggingFaceEmbeddings(
            model_name=embedding_model, model_kwargs=model_kwargs, encode_kwargs=encode_kwargs
        )

        if file_path is None:
            raise ValueError("Please provide a file path.")
        # check if the file is a csv file
        if not file_path.endswith('.csv'):
            raise ValueError(f"Not valid file format. Please provide a csv file.")
        if content_column is None:
            raise ValueError("Please provide the name of the content column.")
        if url_column is None:
            raise ValueError("Please provide the name of the url column.")

        # try to initialize the Qdrant client
        qdrant = None
        if vector_db_mode == 'online':
            qdrant = VectorStoreManager._init_online_vector_db(

Review comment (suggestion):
Nit: The `collection_name` seems to be the key parameter here, suggest reordering it as the first parameter for this function and do not provide default value.

Code after:
            vector_db_mode: str,
            file_path: str,
            content_column: str,
            title_column: str = "title",
            url_column: str = "url",
            desc_column: str = "description",
            batch_size: int = 64,
            chunk_size: int = 500,
            chunk_overlap: int = 100,
            vector_store_path: str = None,
            url: str =  None,
            qdrant_api_key: str = None,
            embedding_model: str = 'BAAI/bge-m3',
            device: str = "mps",
    ):
        """
        Takes a CSV file and adds each row in the CSV file to the Qdrant collection.
        
        This function expects each row of the CSV file as a document.
        The CSV file should have columns for "content", "title", "URL", and "description".

        Args:
            collection_name: Name of the Qdrant collection.
            vector_store_path (str): Path to the directory where the vector store is stored or will be stored. 
            vector_db_mode (str): Mode of the Qdrant vector store (offline or online).
            file_path (str): Path to the CSV file.
            content_column (str): Name of the column containing the content.
            title_column (str): Name of the column containing the title. Default is "title".
            url_column (str): Name of the column containing the URL. Default is "url".
            desc_column (str): Name of the column containing the description. Default is "description".
            batch_size (int): Batch size for adding documents to the collection.
            chunk_size: Size of each chunk if you need to build the vector store from documents.
            chunk_overlap: Overlap between chunks if you need to build the vector store from documents.
            embedding_model: Name of the Hugging Face embedding model.
            device: Device to run the embeddings model on, can be "mps", "cuda", "cpu".
            qdrant_api_key: API key for the Qdrant server (Only required if the Qdrant server is online).
        """
        # check if the collection name is provided
        if collection_name is None:
            raise ValueError("Please provide a collection name.")
        
        model_kwargs = {"device": device}
        encode_kwargs = {"normalize_embeddings": True}
        model = HuggingFaceEmbeddings(
            model_name=embedding_model, model_kwargs=model_kwargs, encode_kwargs=encode_kwargs
        )

        if file_path is None:
            raise ValueError("Please provide a file path.")
        # check if the file is a csv file
        if not file_path.endswith('.csv'):