Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ channels:
- defaults
dependencies:
- python=3.10.0
- openai
- openai=0.28.0
- python-dotenv
- pip
- pandas=2.3.2
- pip:
- azure-ai-inference
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
__pycache__/
*.py[cod]
*$py.class

*.env
.env
# C extensions
*.so

Expand Down
293 changes: 283 additions & 10 deletions 04-prompt-engineering-fundamentals/python/aoai-assignment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,161 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[198, 41, 20089, 374, 279, 18172, 11841, 505, 279, 8219, 323, 279, 7928, 304, 279, 25450, 744, 13, 1102, 374, 264, 6962, 14880, 449, 264, 3148, 832, 7716, 52949, 339, 430, 315, 279, 8219, 11, 719, 1403, 9976, 7561, 34902, 3115, 430, 315, 682, 279, 1023, 33975, 304, 279, 25450, 744, 11093, 13, 50789, 374, 832, 315, 279, 72021, 6302, 9621, 311, 279, 19557, 8071, 304, 279, 3814, 13180, 11, 323, 706, 1027, 3967, 311, 14154, 86569, 2533, 1603, 12715, 3925, 13, 1102, 374, 7086, 1306, 279, 13041, 10087, 50789, 8032, 777, 60, 3277, 19894, 505, 9420, 11, 50789, 649, 387, 10107, 3403, 369, 1202, 27000, 3177, 311, 6445, 9621, 35612, 17706, 508, 60, 323, 374, 389, 5578, 279, 4948, 1481, 1315, 478, 5933, 1665, 304, 279, 3814, 13180, 1306, 279, 17781, 323, 50076, 627]\n"
]
},
{
"data": {
"text/plain": [
"[b'\\n',\n",
" b'J',\n",
" b'upiter',\n",
" b' is',\n",
" b' the',\n",
" b' fifth',\n",
" b' planet',\n",
" b' from',\n",
" b' the',\n",
" b' Sun',\n",
" b' and',\n",
" b' the',\n",
" b' largest',\n",
" b' in',\n",
" b' the',\n",
" b' Solar',\n",
" b' System',\n",
" b'.',\n",
" b' It',\n",
" b' is',\n",
" b' a',\n",
" b' gas',\n",
" b' giant',\n",
" b' with',\n",
" b' a',\n",
" b' mass',\n",
" b' one',\n",
" b'-th',\n",
" b'ousand',\n",
" b'th',\n",
" b' that',\n",
" b' of',\n",
" b' the',\n",
" b' Sun',\n",
" b',',\n",
" b' but',\n",
" b' two',\n",
" b'-and',\n",
" b'-a',\n",
" b'-half',\n",
" b' times',\n",
" b' that',\n",
" b' of',\n",
" b' all',\n",
" b' the',\n",
" b' other',\n",
" b' planets',\n",
" b' in',\n",
" b' the',\n",
" b' Solar',\n",
" b' System',\n",
" b' combined',\n",
" b'.',\n",
" b' Jupiter',\n",
" b' is',\n",
" b' one',\n",
" b' of',\n",
" b' the',\n",
" b' brightest',\n",
" b' objects',\n",
" b' visible',\n",
" b' to',\n",
" b' the',\n",
" b' naked',\n",
" b' eye',\n",
" b' in',\n",
" b' the',\n",
" b' night',\n",
" b' sky',\n",
" b',',\n",
" b' and',\n",
" b' has',\n",
" b' been',\n",
" b' known',\n",
" b' to',\n",
" b' ancient',\n",
" b' civilizations',\n",
" b' since',\n",
" b' before',\n",
" b' recorded',\n",
" b' history',\n",
" b'.',\n",
" b' It',\n",
" b' is',\n",
" b' named',\n",
" b' after',\n",
" b' the',\n",
" b' Roman',\n",
" b' god',\n",
" b' Jupiter',\n",
" b'.[',\n",
" b'19',\n",
" b']',\n",
" b' When',\n",
" b' viewed',\n",
" b' from',\n",
" b' Earth',\n",
" b',',\n",
" b' Jupiter',\n",
" b' can',\n",
" b' be',\n",
" b' bright',\n",
" b' enough',\n",
" b' for',\n",
" b' its',\n",
" b' reflected',\n",
" b' light',\n",
" b' to',\n",
" b' cast',\n",
" b' visible',\n",
" b' shadows',\n",
" b',[',\n",
" b'20',\n",
" b']',\n",
" b' and',\n",
" b' is',\n",
" b' on',\n",
" b' average',\n",
" b' the',\n",
" b' third',\n",
" b'-b',\n",
" b'right',\n",
" b'est',\n",
" b' natural',\n",
" b' object',\n",
" b' in',\n",
" b' the',\n",
" b' night',\n",
" b' sky',\n",
" b' after',\n",
" b' the',\n",
" b' Moon',\n",
" b' and',\n",
" b' Venus',\n",
" b'.\\n']"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# EXERCISE:\n",
"# 1. Run the exercise as is first\n",
Expand Down Expand Up @@ -72,9 +224,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Your text is the opening line of \"The Star-Spangled Banner,\" which is the national anthem of the United States of America. The lyrics come from a poem written in 1814 by Francis Scott Key, called \"Defence of Fort M'Henry.\" Key wrote the poem after witnessing the bombardment of Fort McHenry by British ships in Baltimore Harbor during the War of 1812. The poem was later set to the tune of a popular British song by John Stafford Smith for the Anacreontic Society, a men's social club in London, and it gradually became one of the most famous American patriotic songs.\n"
]
}
],
"source": [
"# The OpenAI SDK was updated on Nov 8, 2023 with new guidance for migration\n",
"# See: https://github.com/openai/openai-python/discussions/742\n",
Expand All @@ -86,8 +246,14 @@
"load_dotenv()\n",
"\n",
"client = AzureOpenAI(\n",
<<<<<<< HEAD
" api_key=os.environ['AZURE_OPENAI_API_KEY'], # this is also the default, it can be omitted\n",
" api_version = \"2023-05-15\"\n",
=======
" api_key=os.environ['AZURE_OPENAI_KEY'], # this is also the default, it can be omitted\n",
" api_version = \"2023-05-15\",\n",
" azure_endpoint=\"https://nsf-openai-dev.openai.azure.com/\"\n",
>>>>>>> main
" )\n",
"\n",
"deployment=os.environ['AZURE_OPENAI_DEPLOYMENT']\n",
Expand Down Expand Up @@ -130,9 +296,100 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"### Lesson Plan: The Martian War of 2076\n",
"\n",
"#### Objective:\n",
"Students will understand the causes, key events, and outcomes of the Martian War of 2076, as well as its impact on interplanetary relations and the future of human colonization in space.\n",
"\n",
"#### Grade Level:\n",
"High School (Grades 9-12)\n",
"\n",
"#### Materials Needed:\n",
"- Interactive timeline software or poster board and markers\n",
"- Access to multimedia resources (videos, articles, virtual reality simulations)\n",
"- Debate preparation materials\n",
"- Quiz creation tools (online or paper-based)\n",
"\n",
"#### Lesson Duration:\n",
"5 Days (1 week), 45 minutes each day\n",
"\n",
"---\n",
"\n",
"### Day 1: Introduction to the Martian War of 2076\n",
"\n",
"#### Activities:\n",
"1. **Warm-Up Discussion (10 minutes):** Start with a brief discussion on human space exploration history leading up to the colonization of Mars.\n",
"2. **Presentation (20 minutes):** Introduce the Martian War of 2076 through a multimedia presentation that covers the background, including the colonization of Mars, the buildup of tensions between Earth and Martian colonies, and the initial skirmishes.\n",
"3. **Group Activity (15 minutes):** Divide students into small groups and assign each group to research one aspect of the pre-war tensions. Each group will present their findings to the class.\n",
"\n",
"#### Homework:\n",
"Students will write a one-page essay on why they believe Mars was colonized and how this colonization led to tensions between Earth and Mars.\n",
"\n",
"---\n",
"\n",
"### Day 2: Key Events of the Martian War\n",
"\n",
"#### Activities:\n",
"1. **Interactive Timeline Creation (30 minutes):** Using interactive timeline software or poster board, students will work in groups to add key events of the Martian War of 2076, including major battles, diplomatic efforts, and turning points.\n",
"2. **Discussion (15 minutes):** Review the timeline as a class, discussing the significance of each event and how it influenced the course of the war.\n",
"\n",
"#### Homework:\n",
"Students will choose one event from the timeline and research it in more depth, preparing a short presentation for the class.\n",
"\n",
"---\n",
"\n",
"### Day 3: Technologies and Tactics\n",
"\n",
"#### Activities:\n",
"1. **Research Presentation (20 minutes):** Students present their findings on the key events of the war, focusing on the technologies and tactics used by both sides.\n",
"2. **Virtual Reality Simulation (20 minutes):** If available, use VR simulations to give students a first-person experience of the war's key battles or scenarios. Alternatively, watch a documentary segment on futuristic warfare.\n",
"3. **Discussion (5 minutes):** Discuss how technology influenced the war's outcome and the ethical considerations of using such technologies.\n",
"\n",
"#### Homework:\n",
"Students will design their own futuristic military technology that could have changed the outcome of the Martian War of 2076, including a description and illustration.\n",
"\n",
"---\n",
"\n",
"### Day 4: The Aftermath and Impact\n",
"\n",
"#### Activities:\n",
"1. **Group Discussion (15 minutes):** Discuss the immediate aftermath of the war, including the peace treaty, the casualties, and the economic impact on both Earth and Mars.\n",
"2. **Long-Term Impact Analysis (15 minutes):** In groups, students analyze the long-term impacts of the war on interplanetary relations, human colonization, and technological advancements.\n",
"3. **Presentation (15 minutes):** Each group presents their analysis of the war's long-term impacts.\n",
"\n",
"#### Homework:\n",
"Students will write a reflection on how the Martian War of 2076 could influence future human space exploration and interplanetary relations.\n",
"\n",
"---\n",
"\n",
"### Day 5: Debate and Assessment\n",
"\n",
"#### Activities:\n",
"1. **Debate (30 minutes):** Organize a debate on the following topic: \"Was the Martian War of 2076 inevitable?\" Divide the class into two groups, pro and con, and allow time for preparation and presentation of arguments.\n",
"2. **Quiz (15 minutes):** Administer a quiz covering the key points of the Martian War of 2076, including causes, events, technologies, and aftermath.\n",
"\n",
"#### Homework:\n",
"Students will submit a final essay arguing whether humanity has learned from the Martian War of 2076 and how those lessons can be applied to future space exploration and colonization efforts.\n",
"\n",
"---\n",
"\n",
"### Assessment:\n",
"- Participation in discussions and group activities\n",
"- Quality of presentations and essays\n",
"- Performance on the final quiz\n",
"- Contribution to the debate and final essay insights\n",
"\n",
"This lesson plan aims to not only educate students about a pivotal moment in future human history but also to encourage critical thinking about space exploration, technological ethics, and the importance of diplomacy in interplanetary relations.\n"
]
}
],
"source": [
"\n",
"## Set the text for simple prompt or primary content\n",
Expand Down Expand Up @@ -163,9 +420,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Jupiter is a super big planet, the biggest one we have in our Solar System, and it's the fifth one away from the Sun. It's made mostly of gas and is way heavier than all the other planets put together. People have known about Jupiter for a really, really long time, even before they wrote things down, and they named it after a powerful god from old stories. When you look up at the night sky, Jupiter is one of the brightest spots you can see without a telescope, and sometimes it shines so bright that it can make shadows on Earth. It's usually the third brightest thing in the night sky after the Moon and Venus.\n"
]
}
],
"source": [
"# Test Example\n",
"# https://platform.openai.com/playground/p/default-summarize\n",
Expand Down Expand Up @@ -210,9 +475,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Oh, you know, just a little place called Globe Life Field in Arlington, Texas. No big deal, just the first time in history the World Series was played at a neutral site. Nothing to see here!\n"
]
}
],
"source": [
"response = client.chat.completions.create(\n",
" model=deployment,\n",
Expand Down
6 changes: 3 additions & 3 deletions 06-text-generation-apps/python/aoai-app-recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

# configure Azure OpenAI service client
client = AzureOpenAI(
azure_endpoint = os.environ["AZURE_OPENAI_ENDPOINT"],
api_key=os.environ['AZURE_OPENAI_API_KEY'],
azure_endpoint = "https://nsf-openai-dev.openai.azure.com/",
api_key="",
api_version = "2023-10-01-preview"
)

deployment=os.environ['AZURE_OPENAI_DEPLOYMENT']
deployment="nsf-gpt-4"

no_recipes = input("No of recipes (for example, 5: ")

Expand Down
9 changes: 4 additions & 5 deletions 06-text-generation-apps/python/aoai-app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@

# configure Azure OpenAI service client
client = AzureOpenAI(
azure_endpoint = os.environ["AZURE_OPENAI_ENDPOINT"],
api_key=os.environ['AZURE_OPENAI_API_KEY'],
api_version = "2024-02-01"
# api_version = "2023-05-15"
azure_endpoint = "https://nsf-openai-dev.openai.azure.com/",
api_key="",
api_version = "2023-10-01-preview"
)

deployment=os.environ['AZURE_OPENAI_DEPLOYMENT']
deployment="nsf-gpt-4"

# add your completion code
prompt = "Complete the following: Once upon a time there was a"
Expand Down
Loading