zilliztech / GPTCache

Semantic cache for LLMs. Fully integrated with LangChain and llama_index.
https://gptcache.readthedocs.io
MIT License
7.21k stars 502 forks source link

[Feature]: Support for specifying database name in Milvus #647

Open tvvignesh opened 2 months ago

tvvignesh commented 2 months ago

Is your feature request related to a problem? Please describe.

I have a multi tenant system built with Milvus, Langchain, etc. and this works with each bot having its own database in Milvus with different collections within. I integrated GPTCache with Milvus and Postgres. While it works fine and returns back responses from the cache, I am looking to specify the database name where the Vectors are to be stored using GPTCache but I don't have a provision for that as of today.

This is how I specify the DB name typically in Milvus using the db_name parameter:

vectorstore = Milvus(
            embeddings,
            collection_name=collection_name,
            auto_id=True,
            connection_args={
                "user": self.user,
                "password": self.password,
                "host": self.host,
                "port": self.port,
                "db_name": self.db_name,
            },
            index_params={},
            drop_old=shouldDrop
        )

This is what I can specify in GPTCache today

vector_base=VectorBase(
                    name='milvus',
                    host=os.getenv("MILVUS_DB_HOST"),
                    port=os.getenv("MILVUS_DB_PORT"),
                    user=os.getenv("MILVUS_DB_USERNAME"),
                    password=os.getenv("MILVUS_DB_PASSWORD"),
                    collection_name=<my_collection_name>,
                    dimension=768
                )

Describe the solution you'd like.

Requesting to add connection_args parameter for specifying db_name

Describe an alternate solution.

No response

Anything else? (Additional Context)

No response

SimFG commented 1 month ago

@tvvignesh i will develop this feature asap

tvvignesh commented 1 month ago

Thanks

tvvignesh commented 1 month ago

@SimFG Just a quick update - since Milvus supports only 64 databases per instance, we decided to move to partition keys in Milvus to implement multi-tenancy as suggested in the docs - if GPTCache can support that as well in addition to providing DB name, that would be great.

This is how langchain does allow you to specify partition keys (for your reference): https://python.langchain.com/docs/integrations/vectorstores/milvus/#per-user-retrieval

Its all discussed here: https://milvus.io/docs/multi_tenancy.md

SimFG commented 1 month ago

@tvvignesh got it. I'm very sorry that I haven't finished this feature for so long, because I'm currently developing other features of milvus and encountered some tricky problems.