Find answers from the community

Updated 2 years ago

Credentials

At a glance

The community members are discussing how to pass credentials when creating a model's context. One community member suggests passing the credentials directly to the LLM or embedding model, while another mentions getting an error when not setting the globals. The discussion then focuses on the Azure library, with community members noting that it is poorly designed and requires additional configuration, such as setting the api_type to "azure" and handling errors related to missing parameters. Eventually, a community member finds a solution that involves disabling certain checks and passing additional parameters, and they share their findings with the group.

I feel as though it should be possible to only have to pass the credentials when creating the model's context
L
i
33 comments
Yea you can pass credentials in directly to the llm or embed model

llm = OpenAI(..., api_key="...")

embed_model = OpenAIEmbedding(api_key="...")
I seem to get an error when starting the project if I don't set the globals...maybe i'm missing something
does it have to be passed anywhere else?
Hmm, just those two, and those go into the service context, and the service context goes into everything πŸ˜…
my brain is indexing what you said
let me retry that
yes i understand
also, my bad, meant to put this in #❓py-issues-and-help
appreciate the help nonetheless
OK, can confirm that is not the case
Thought I was hallucinating...pun not intended
Oh you are using azure ..
Probably the worst designed library in existence
you haven't seen my work
if i go ahead and disable that check, will everything break πŸ™‚
i assume azure do things in an annoying way hence the globals
You can try disabling it, and passing in all those other things as additional_kwargs ?
But tbh no idea if it will work
well, worth the try innit
if it does work, I can patch the library tomorrow morning πŸ‘
yep, i'm off to sleep... sweet dreams!
i'll check this then hit the bed
Works, but, some notes:

  • default api_type should be "azure" when using the Azure model
  • if you forget api_version, engine_api_resource.py class_url throws an error because raise error.InvalidRequestError is missing a required param param
  • if you don't set api_type for the embedding model or regular model, the api key style of azure will throw an error expecting an OpenAI key
πŸ™‚
Cool makes sense! Thanks for reporting back!
Well use this to make some improvements πŸ’ͺ
ah, andddd validate_openai_api_key requires openai_api_key to be set, even if it's azure πŸ˜›
Add a reply
Sign up and join the conversation on Discord