Hi Community,
I’m trying to run command in colab research google:
Blockquote
text = f"“”
You should express what you want a model to do by
providing instructions that are as clear and
specific as you can possibly make them.
This will guide the model towards the desired output,
and reduce the chances of receiving irrelevant
or incorrect responses. Don’t confuse writing a
clear prompt with writing a short prompt.
In many cases, longer prompts provide more clarity
and context for the model, which can lead to
more detailed and relevant outputs.
“”"
prompt = f"“”
Summarize the text delimited by triple backticks
into a single sentence. {text}
“”"
response = get_completion(prompt)
print(response)
no, I have not created any .env file
You mean, I need to generate API key as described here OpenAI API and put it in .env file? If it is, what directory should I place .env file then?
The simplest fix is just stick your key into your code. they don’t do it in the video so people can’t copy their private key. No .env, no import os, no install dotenv…
+1 @Juan_Olano but just to be completely clear for the newer programmers,we treat it as a Python string literal. So use the single or double quotes, not angle brackets <…>
openai.api_key = “paste_here_your_api_key”
as is demonstrated in the Guidelines for Prompting video just at the 2:00 mark
thank you @ai_curious and @Juan_Olano
I started to use built-in notebooks and everything works correctly, but at the same time I tried to use 'openai.api_key = “sk-…” ’ in colab google for curiosity and does not work
@vladizero8, it’s very strange. I have just created a new notebook in Collab with only one cell:
!pip install openai
import openai
openai.api_key = '<put-here-your-api-key>'
def get_completion(prompt, model="gpt-3.5-turbo"):
messages = [{"role": "user", "content": prompt}]
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=0, # this is the degree of randomness of the model's output
)
return response.choices[0].message["content"]
text = f"""
You should express what you want a model to do by \
providing instructions that are as clear and \
specific as you can possibly make them. \
This will guide the model towards the desired output, \
and reduce the chances of receiving irrelevant \
or incorrect responses. Don't confuse writing a \
clear prompt with writing a short prompt. \
In many cases, longer prompts provide more clarity \
and context for the model, which can lead to \
more detailed and relevant outputs.
"""
prompt = f"""
Summarize the text delimited by triple backticks \
into a single sentence.
```{text}```
"""
response = get_completion(prompt)
print(response)
And it works (of course I need to put my API key).
thanks @juanjonavarro
I tried to put my api key and after a few iteration it worked. Unfortunately, I did it manually - copy and paste does not work in colab
Either use the course Jupyter notebook (you do need your own open API key). else use your open API key if you are using your own jupyter notebook. Do not mix and match and I reccomend the use of Course Jupyter notebook
i’m usign jupyter and i’m stuck on the first step. I install correctly the !pip install openai, but qhe i try to use the command “Import openai” it gives me this error:
Did you do the pip install of openai first? If not, you need to do that first (it’s a one time thing - once you do it you won’t have to do it every time). You can run the command on the first line of the Jupyter notebook as the instructor shows, or you can do it on the mac terminal (not sure how you do it if you use Windows)
To explore and experiment with the API, all new users get $5 worth of free tokens. These tokens expire after 3 months.
After the quota has passed you can choose to enter billing information to upgrade to a paid plan and continue your use of the API on pay-as-you-go basis. If no billing information is entered you will still have login access, but will be unable to make any further API requests.
Please see the pricing page for the latest information on pay-as-you-go pricing.