from database.milvus_api import Milvus_Database
import os

class Save_Markdown_to_Milvus():
    def __init__(self,database_name, collection_name):
        self.database_name = database_name
        self.collection_name = collection_name
        # self.milvus_database = Milvus_Database(database_name=self.database_name).client
        self.milvus_database = Milvus_Database(uri=os.getenv("Milvus_URI"))
    def save_md(self,data):
    # milvus_database = Milvus_Database("JXTest")
        self.milvus_database.using_database(self.database_name)
        result = self.milvus_database.insert(collection_name=self.collection_name,params=data)
        return result
    def save_hybrid_md(self,data):
        self.milvus_database.using_database(self.database_name)
        result = self.milvus_database.hybrid_insert(collection_name=self.collection_name,params=data,database_name=self.database_name)
        return result
    def close(self):
        self.milvus_database.close()