reflex-dev / reflex-examples

A repository full of Reflex example apps.
456 stars 352 forks source link

GPT example should not need OPENAI_API_KEY at export time. #177

Open jackie-pc opened 10 months ago

jackie-pc commented 10 months ago

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()
masenf commented 10 months ago

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?

jackie-pc commented 10 months ago

Agree we should update examples.