weaviate-python-client icon indicating copy to clipboard operation
weaviate-python-client copied to clipboard

Proposal: Set external API keys through functions

Open databyjp opened this issue 1 year ago • 3 comments

Problem being addressed: The current method of setting API keys by specifying headers can be cumbersome. After client instantiation, changing the key is also quite difficult (not that this happens a lot).

Proposal: Add methods to easily add or change API keys, for example like:

    def set_apikey(self, openai_key: Optional[str] = None, cohere_key: Optional[str] = None):

        if openai_key:
            self._connection._headers["x-openai-api-key"] = openai_key

        if cohere_key:
            self._connection._headers["x-cohere-api-key"] = cohere_key

What do you think?

(They should ideally be attributes too imo so that they can be easily reviewed.)

databyjp avatar Jul 21 '23 09:07 databyjp

@tsmith023 @databyjp Can I work on this issue?

ankur0904 avatar Sep 12 '23 08:09 ankur0904

Hi @ankur0904, that would be great! Thank you for taking it up 😁

My recommendation would be to have the function as a method within the Client class as defined in weaviate/client.py

tsmith023 avatar Sep 12 '23 08:09 tsmith023

Hey @ankur0904 fantastic!

The initial implementation should include support for keys for cohere, huggingface, openai and palm imo.

databyjp avatar Sep 12 '23 10:09 databyjp