Learn AI The Best Way Bite Size
Tags: aws, bedrock, ai, anthropic
Published: 2024-07-05 18:37:50

**Learn AI From My Own Product Development Experience.If You Do That The Entire Silicon Valley Will Open For You. I will post  technical articles here and will give you everything you need. I will share my entire git repo with you. Prerequiste: Python Proficiency. I can give you a free book in the future. I am too busy for that now.**

**What you will learn.**

1. Prompt Engineering - The real Deep Dive not any Kindle book vodoo " Learn 100 prompts that will make you rich" You have seen such hypes all over. If it is that simple, trust me I would be flying in my private jet by now.
2. Lang Chain
3. Vector Database. Pinecone as well as MongoDB Atlas
4. Amazon Bedrock
5. Amazon Q
6. Amazon CodeWhisperer
7. Amazon Lambda

Once you learn and master all these then comes how you can build a product. I will share my real life experience on that. Wait Dude, not so fast. You need to have engineering reasoning and critical thinking skills to be an innovator. So, watch this first. I know you are busy but spend next 5 minutes and watch this for an important message. [https://www.youtube.com/watch?v=_7hIqf7skiQ]

Here is your first lesson on prompt engineering. You can run this on Google Colab or any Jupyter Notebook.

!pip install openai

from openai import OpenAI
client = OpenAI(
    api_key = 'your openai apikey',
)
**

**Define the prompt for the language model**

prompt = 'Write an essay about the History of the Silicon Valley and how this place literally changed the world'

**# Call the OpenAI API with the specified model, prompt, maximum token length, and temperature**

output = client.completions.create(
    model="gpt-3.5-turbo-instruct",
    prompt=prompt,
    max_tokens=1000,
    temperature=0.5 )


**# Print the generated text**
print(output.choices[0].text)
**
Here is a line-by-line explanation of the code:**
1. “import openai” - This line imports the OpenAI library into your Python environment. This library allows our program to interact with OpenAI's APIs, which include language models like GPT-3.

2. “secret_key” = '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'` - This line sets your OpenAI API secret key to a variable named `secret_key`. You will need to replace this with your actual secret key. I have used my secret_key here to show you how to use it. I will delete this secret key as soon I publish this here.

3. “openai.api_key” = secret_key - This line assigns the secret key to the OpenAI API key. This authenticates your application with OpenAI's servers.

4. “prompt” = 'Write an essay about the History of the Silicon Valley and how this place literally changed the world'` - This line sets the variable 'prompt` to the text that will be used to prompt the language model.

5. “output” = openai.Completion.create( )- This line starts the call to OpenAI's API to create a new text completion. The result of this call will be stored in the `output` variable. openai.Completion.create() function generates text based on the provided prompt using the specified engine.

6. “model”="gpt-3.5-turbo-instruct",` - This specifies the language model to be used for the text generation task. In this case, the "gpt-3.5-turbo-instruct" model is being used.

7. “prompt=prompt” - This feeds in the `prompt` variable defined earlier to the language model.

8. “max_tokens=1000” - This line tells the API to limit the response to 1000 tokens (a token can be as short as one character or as long as one word).

9. “temperature=0.5” - This sets the randomness of the output. Lower values (closer to 0) make the output more deterministic and focused, while higher values (closer to 1) produce more diverse and creative outputs.

10. “print(output.choices[0].text)” - This line prints the generated text. The API returns a list of choices (though by default it is only one choice). This command prints the text field of the first choice.

By running this single program, you have achieved many critical tasks. You learned to:
•	Import the OpenAI API library
•	Assign your API key to a variable
•	Set the OpenAI API key for authentication
•	Define the prompt for the language model
•	Call the OpenAI API with the specified model, prompt, maximum 
        token length, and temperature
•	Print the generated text
This is a monumental accomplishment!

**Please make your comments. I need your feedback. Stay here for regular new code uploads. Once you master this you can join my tribe of start up entrepreneurs or get a job at Silicon Valley. Who knows! AWS might hire you. **

**Do you know the famous motivational speaker Tony Robins always says "Live with passion". Hey Tony, with all due respect dude you are wrong! My mantra is "You will have to be obsessed with something to become unstoppable"**

I am obsessed with AI and AWS as well. Are you?