reflex-examples icon indicating copy to clipboard operation
reflex-examples copied to clipboard

GPT example should not need OPENAI_API_KEY at export time.

Open jackie-pc opened this issue 2 years ago • 2 comments

openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

Solution is probably just to defer client instantiation by one function call. https://github.com/reflex-dev/reflex-examples/blob/cb3e32c1974e5a533c8507e1820bb643fdde53d0/gpt/gpt/gpt.py#L11 to become

def get_client():
    return OpenAI()

jackie-pc avatar Nov 28 '23 18:11 jackie-pc

We just set something for that var during CI: https://github.com/reflex-dev/reflex-examples/blob/cb3e32c1974e5a533c8507e1820bb643fdde53d0/.github/workflows/check_export.yml#L63

Maybe we should update these examples to use the function-wrapper workaround?

masenf avatar Nov 28 '23 18:11 masenf

Agree we should update examples.

jackie-pc avatar Nov 28 '23 18:11 jackie-pc