I am creating a streamlit app directly in my snowflake account. I need to import openai. So I have packed the python library and openai in a zip file, uploaded as a stage of a schema, and selected this zip file under the package stage package within the streamlit app. However, I still get the error message: module not found ‘openai’.
Hi @Winnie, welcome to the forum!
The good news is that there’s an easier solution, just type ‘openai’ into the find packages, and it should be available from there
Thanks @blackary for your quick reply!
Now I run into one more problem. I would like to create a chatbot. There are two python scripts included if I run in locally. If I want to run it in streamlit app within my Snowflake account (to take the advantage of SSO and access), two ways I tried but failed. First option, I upload the prompts python script in the stage package of the same streamlit app. Second option, I include both scripts in one streamlit app. My question: is streamlit app in Snowflake capable to call the function from another streamlit app?
and, I just realize that, the version of openai I am using locally is 1.35.3. But in streamlit app, the module is only 1.25.0. It seems that there is an issue with openai.ChatCompletion.
And, I also got this error message, likely something to do with the version of snowflake.snowpark.python package.
ImportError: cannot import name ‘BAD_REQUEST_GS_CODE’ from ‘snowflake.connector.network’
Re: issues accessing openai
You will probably find this helpful Getting Started with Generative AI in Snowflake and Streamlit
Re: multiple files
Yes, you can have multiple python files, but you should just upload them to the stage directly, not zipped, and not as a package – just upload them to the same stage as the streamlit app. You can do this more easily by utilizing snowcli – here are some docs about using snowcli to upload a multi-file streamlit app to snowflake Deploying a Streamlit app | Snowflake Documentation