@monikash1131 can you scroll down to the end of the of the error section and share the screenshot. There the exact error message will be mentioned.
please elaborate not able to understand.
@monikash1131 In you previous screenshot, on the window on the right hand side the error is displayed. Its a long error. If you can scroll down in that window at the end the error message will be get present Share that screenshot. Also scroll to the beginning of the window and take a screenshot and share as well.
@pranav.kundaikar I have tried it by making a new Gmail Account with new phone number. I am getting the output but not in the desired format.
@kumari.mansi003
We have explained how to format the output and get the information in the training topic “Getting output”. Please refer to this topic. You will be able to get the output in the proper formatting.
If you face any issues let me know.
i have tried but still getting error
code : import openai
import os
import sys
openai.api_key = os.environ[‘OPENAI_API_KEY’]
if openai.api_key == “”:
sys.stderr.write(“”"
You haven’t set up your API key yet.
If you don’t have an API key yet, visit:
https://platform.openai.com/signup
- Make an account or sign in
- Click “View API Keys” from the top right menu.
- Click “Create new secret key”
Then, open the Secrets Tool and add OPENAI_API_KEY as a secret.
“”")
exit(1)
response = openai.chat.completions.create(
model=“gpt-3.5-turbo”,
messages=[{
“role”: “system”,
“content”: “You are a helpful assistant.”
}, {
“role”: “user”,
“content”: “Who won the world series in 2020?”
}, {
“role”:
“assistant”,
“content”:
“The Los Angeles Dodgers won the World Series in 2020.”
}, {
“role”: “user”,
“content”: “Where was it played?”
}])
print(response)
error:
@monikash1131 As the error mentions you have exceeded the free credits quota provided by OpenAI. Please create new account with a different email and different phone number. You will get free credits for the new account. You can replace the API key from the new account in your code to continue with your learning.
sir this issue is resolved, now i have an error in
import openai
import os
import sys
openai.api_key = os.environ[‘OPENAI_API_KEY’]
if openai.api_key == “”:
sys.stderr.write(“”"
You haven’t set up your API key yet.
If you don’t have an API key yet, visit:
https://platform.openai.com/signup
- Make an account or sign in
- Click “View API Keys” from the top right menu.
- Click “Create new secret key”
Then, open the Secrets Tool and add OPENAI_API_KEY as a secret.
“”")
exit(1)
response = openai.chat.completions.create(
model=“gpt-3.5-turbo”,
messages=[{
“role”: “system”,
“content”: “You are a helpful assistant.”},
# {
# “role”: “user”,
# “content”: “Who won the world series in 2020?”
# }, {
# “role”:
# “assistant”,
# “content”:
# “The Los Angeles Dodgers won the World Series in 2020.”
# },
{ “role”: “user”,
“content”: “Where was it played?”
}])
output = response[‘choices’][0][‘message’].get(‘content’)
print(output)
@monikash1131 can you replace output = response[‘choices’][0][‘message’].get(‘content’)
with the below line an try
output = response.choices[0].message.content
OK SIR THANKYOU
It is working fine