#
# Copyright (c) 2025, mstoeck3
# All rights reserved.
#
# This source code is licensed under the BSD-3-Clause license found in the
# LICENSE file in the root directory of this source tree.
#

from qdrant_client import QdrantClient
import dotenv

class QdrantInterface():
    """
    provide a custom interface along with special methods relevant with the semeion application
    """
    standard_vector_size = 1536
    
    
    def __init__(self):
        host = dotenv.get_key(".env", "QDRANT_HOST")
        port_str = dotenv.get_key(".env", "QDRANT_PORT")
        port = int(port_str) if port_str is not None else None
        api_key = dotenv.get_key(".env", "QDRANT_API_KEY")
        self.client = QdrantClient(host=host, port=port, api_key=api_key)
        
    def get_collections(self):
        collections_obj = self.client.get_collections()
        collections = []
        for c in collections_obj.collections:
            collections.append(c.name)
        return collections
    
    def create_semeion_collection(self, collection_name: str):
        self.client.create_collection(collection_name, vector_size=self.standard_vector_size) if not self.client.collection_exists(collection_name) else None
        return self.client.collection_exists(collection_name)
    
    def submit(self, payload):
        pass
    
    def check_health(self):
        pass