Forum in maintenance, we will back soon 🙂
Building UIs With Streamlit - The Base Template errors
Hello,
the function def openAI_generate_text(prompt, model, api_key): provided @ https://learnwithhasan.com/lessons/the-base-template/ is still outdated.
To rectify, first run
pip install --upgrade openai
then replace
completion = openai.ChatCompletion.create(
with
completion = openai.chat.completions.create(
Worked for me.
This aside, @admin Hasan, in the OpenAI migration guide , they mentioned using a new Initialization like the one below:
# old import openai openai.api_key = os.environ['OPENAI_API_KEY'] # new from openai import OpenAI client = OpenAI( api_key=os.environ['OPENAI_API_KEY'], # this is also the default, it can be omitted )
So is it better practice to initial openai in the new way? Or is my understanding lacking? How does this affect calling the api_key in our scripts?
I also believe this part is important? But I cannot fully comprehend yet given my level. 😥 😥Â
Â
Posted by: @dfby999Hello,
the function def openAI_generate_text(prompt, model, api_key): provided @ https://learnwithhasan.com/lessons/the-base-template/ is still outdated.
To rectify, first run
pip install --upgrade openaithen replace
completion = openai.ChatCompletion.create(with
completion = openai.chat.completions.create(Worked for me.
This aside, @admin Hasan, in the OpenAI migration guide , they mentioned using a new Initialization like the one below:
# old import openai openai.api_key = os.environ['OPENAI_API_KEY'] # new from openai import OpenAI client = OpenAI( api_key=os.environ['OPENAI_API_KEY'], # this is also the default, it can be omitted )So is it better practice to initial openai in the new way? Or is my understanding lacking? How does this affect calling the api_key in our scripts?
I also believe this part is important? But I cannot fully comprehend yet given my level. 😥 😥Â
-- attachment is not available --
Â
Â
Or downgrade the openai module to 0.28 like so
pip install --upgrade openai==0.28
this will allow the code to run without changing the code.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
Thanks for your feedback, I will update this code soon.
and yes, I will be also using the new Initialization in my new updates