weaviate-python-client
weaviate-python-client copied to clipboard
Proposal: Set external API keys through functions
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.)
@tsmith023 @databyjp Can I work on this issue?
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
Hey @ankur0904 fantastic!
The initial implementation should include support for keys for cohere
, huggingface
, openai
and palm
imo.