FortiShield
commited on
Commit
•
4dfeb54
1
Parent(s):
1f570ef
Create L1_Your_First_AI_Agent.ipynb
Browse files- L1_Your_First_AI_Agent.ipynb +47 -0
L1_Your_First_AI_Agent.ipynb
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Lesson 1: Your First AI Agent
|
2 |
+
|
3 |
+
Welcome to Lesson 1.
|
4 |
+
|
5 |
+
To access the `requirements.txt` file, please go to the `File` menu and select`Open...`.
|
6 |
+
|
7 |
+
I hope you enjoy this course!
|
8 |
+
|
9 |
+
## Setup
|
10 |
+
|
11 |
+
import os
|
12 |
+
import pandas as pd
|
13 |
+
from IPython.display import Markdown, HTML, display
|
14 |
+
|
15 |
+
## Connect to the Azure OpenAI endpoint
|
16 |
+
|
17 |
+
**Note**: The pre-configured cloud resource grants you access to the Azure OpenAI GPT model. The key and endpoint provided below are intended for teaching purposes only. Your notebook environment is already set up with the necessary keys, which may differ from those used by the instructor during the filming.
|
18 |
+
|
19 |
+
```
|
20 |
+
openai_api_version="2023-05-15"
|
21 |
+
azure_deployment="gpt-4-1106"
|
22 |
+
azure_endpoint="https://testadri.openai.azure.com"
|
23 |
+
|
24 |
+
```
|
25 |
+
|
26 |
+
## 1. Leveraging Langchain
|
27 |
+
|
28 |
+
from langchain.schema import HumanMessage
|
29 |
+
from langchain_openai import AzureChatOpenAI
|
30 |
+
|
31 |
+
model = AzureChatOpenAI(
|
32 |
+
openai_api_version="2024-04-01-preview",
|
33 |
+
azure_deployment="gpt-4-1106",
|
34 |
+
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
|
35 |
+
)
|
36 |
+
|
37 |
+
## 2. Preparing your prompt
|
38 |
+
|
39 |
+
message = HumanMessage(
|
40 |
+
content="Translate this sentence from English "
|
41 |
+
"to French and Spanish. I like red cars and "
|
42 |
+
"blue houses, but my dog is yellow."
|
43 |
+
)
|
44 |
+
|
45 |
+
## 3. Engaging the model to receive a response
|
46 |
+
|
47 |
+
model.invoke([message])
|