Skip to content

Commit

Permalink
removed output
Browse files Browse the repository at this point in the history
  • Loading branch information
denniszielke committed Apr 22, 2024
1 parent 591470a commit dadf83f
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 856 deletions.
197 changes: 3 additions & 194 deletions labs/02-integrating-ai/00-PythonModules/pythonmodules.ipynb

Large diffs are not rendered by default.

100 changes: 7 additions & 93 deletions labs/02-integrating-ai/01-AzureOpenAIAPI/azureopenaiapi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found Azure OpenAI API Base Endpoint: https://elsantoropenai.openai.azure.com/\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"import requests\n",
Expand Down Expand Up @@ -60,7 +52,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -77,17 +69,9 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://elsantoropenai.openai.azure.com//openai/deployments/gpt35turbo/chat/completions?api-version=2023-09-01-preview\n"
]
}
],
"outputs": [],
"source": [
"url = RESOURCE_ENDPOINT + \"/openai/deployments/\" + DEPLOYMENT_ID + \"/chat/completions?api-version=\" + API_VERSION\n",
"\n",
Expand All @@ -106,79 +90,9 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"choices\": [\n",
" {\n",
" \"content_filter_results\": {\n",
" \"hate\": {\n",
" \"filtered\": false,\n",
" \"severity\": \"safe\"\n",
" },\n",
" \"self_harm\": {\n",
" \"filtered\": false,\n",
" \"severity\": \"safe\"\n",
" },\n",
" \"sexual\": {\n",
" \"filtered\": false,\n",
" \"severity\": \"safe\"\n",
" },\n",
" \"violence\": {\n",
" \"filtered\": false,\n",
" \"severity\": \"safe\"\n",
" }\n",
" },\n",
" \"finish_reason\": \"stop\",\n",
" \"index\": 0,\n",
" \"message\": {\n",
" \"content\": \"there was a magical land called Elenia. It was a land filled with beautiful forests, crystal clear lakes, and snow-capped mountains. The people of Elenia were kind and welcoming, and they lived in harmony with nature and the creatures that inhabited their land.\\n\\nIn the heart of Elenia was a magnificent castle, where the ruling family lived. King Edward and Queen Olivia were known throughout the land for their kindness and fairness. They had two children, Prince William and Princess Elizabeth, who were beloved by all the people of Elenia.\\n\\nOne day, a terrible curse fell upon Elenia. It was said that a witch, who had been banished from the land years ago, had returned and brought with her a terrible darkness. The forests began to wither, the lakes became murky, and the creatures of the land began to disappear.\\n\\nKing Edward and Queen Olivia were beside themselves with worry. They knew they had to find a way to break the curse and save their beloved land. They consulted with the wisest sorcerers in the land, but none of them could offer a solution.\\n\\nOne day, a young woman appeared at the gates of the castle. She was dressed in rags and looked as if she had been walking for days. The guards thought she was a beggar and tried to turn her away, but she insisted on speaking with the king and queen. When she was brought before them, she explained that she was a witch and that she could help break the curse.\\n\\nKing Edward and Queen Olivia were hesitant at first, but they knew they had no other option. The witch led them to a clearing in the forest and began to cast a spell. As she chanted softly, the darkness began to lift. The trees regained their leaves, the water cleared, and the creatures returned.\\n\\nElenia was saved, and the people rejoiced. The king and queen were so grateful to the witch that they offered her a place in their castle. She declined, saying that she preferred to live in the forest, where she could be close to nature.\\n\\nFrom that day forward, the people of Elenia no longer feared witches. They knew that not all witches were evil and that some could be their greatest allies. The land continued to flourish and prosper, and the legend of the witch who saved Elenia became a beloved tale that parents passed down to their children for generations to come.\",\n",
" \"role\": \"assistant\"\n",
" }\n",
" }\n",
" ],\n",
" \"created\": 1712239507,\n",
" \"id\": \"chatcmpl-9AI0BZBHYwUrhwGnic2Sq9skvYGbX\",\n",
" \"model\": \"gpt-35-turbo\",\n",
" \"object\": \"chat.completion\",\n",
" \"prompt_filter_results\": [\n",
" {\n",
" \"prompt_index\": 0,\n",
" \"content_filter_results\": {\n",
" \"hate\": {\n",
" \"filtered\": false,\n",
" \"severity\": \"safe\"\n",
" },\n",
" \"self_harm\": {\n",
" \"filtered\": false,\n",
" \"severity\": \"safe\"\n",
" },\n",
" \"sexual\": {\n",
" \"filtered\": false,\n",
" \"severity\": \"safe\"\n",
" },\n",
" \"violence\": {\n",
" \"filtered\": false,\n",
" \"severity\": \"safe\"\n",
" }\n",
" }\n",
" }\n",
" ],\n",
" \"system_fingerprint\": null,\n",
" \"usage\": {\n",
" \"completion_tokens\": 489,\n",
" \"prompt_tokens\": 13,\n",
" \"total_tokens\": 502\n",
" }\n",
"}\n"
]
}
],
"outputs": [],
"source": [
"r = requests.post(url, headers={\"api-key\": API_KEY}, json={\"messages\":[{\"role\": \"assistant\", \"content\": \"Once upon a time \"}]})\n",
"\n",
Expand Down
30 changes: 7 additions & 23 deletions labs/02-integrating-ai/02-OpenAIPackages/openai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -39,17 +39,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found Azure OpenAI API Base Endpoint: https://elsantoropenai.openai.azure.com/\n"
]
}
],
"outputs": [],
"source": [
"import os\n",
"from dotenv import load_dotenv\n",
Expand All @@ -70,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -95,17 +87,9 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ChatCompletion(id='chatcmpl-9AI1SLFSvunxHnQE9mwHP3HKrpl9q', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=\"helping people. There's nothing more fulfilling than being able to use my skills, knowledge, and abilities to make a positive impact on someone's life. Whether it's through offering advice, lending a listening ear, or lending a helping hand, I take great pride and joy in being of service to others. It brings me a deep sense of purpose and fulfillment knowing that I am making a difference in someone's life, even in a small way.\", role='assistant', function_call=None, tool_calls=None), content_filter_results={'hate': {'filtered': False, 'severity': 'safe'}, 'self_harm': {'filtered': False, 'severity': 'safe'}, 'sexual': {'filtered': False, 'severity': 'safe'}, 'violence': {'filtered': False, 'severity': 'safe'}})], created=1712239586, model='gpt-35-turbo', object='chat.completion', system_fingerprint=None, usage=CompletionUsage(completion_tokens=90, prompt_tokens=19, total_tokens=109), prompt_filter_results=[{'prompt_index': 0, 'content_filter_results': {'hate': {'filtered': False, 'severity': 'safe'}, 'self_harm': {'filtered': False, 'severity': 'safe'}, 'sexual': {'filtered': False, 'severity': 'safe'}, 'violence': {'filtered': False, 'severity': 'safe'}}}])\n"
]
}
],
"outputs": [],
"source": [
"response = client.chat.completions.create(\n",
" model = os.getenv(\"AZURE_OPENAI_COMPLETION_DEPLOYMENT_NAME\"),\n",
Expand Down Expand Up @@ -184,7 +168,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.12.3"
},
"orig_nbformat": 4
},
Expand Down
73 changes: 11 additions & 62 deletions labs/02-integrating-ai/03-Langchain/langchain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -41,17 +41,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found Azure OpenAI Endpoint: https://elsantoropenai.openai.azure.com/\n"
]
}
],
"outputs": [],
"source": [
"import os\n",
"import openai\n",
Expand All @@ -73,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -95,24 +87,9 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"As an AI language model, I do not have access to real-time data, therefore I cannot provide an accurate answer to this question. However, I can provide the steps one can take to find the answer:\n",
"\n",
"1. Go to a reliable news website or search engine.\n",
"2. Type in the current President of the United States.\n",
"3. Look for their birth year or age.\n",
"4. Subtract their birth year from the current year to determine their age. \n",
"\n",
"For example, if the current President is Joe Biden, his birth year is 1942. If the current year is 2021, his age would be 79 years old.\n"
]
}
],
"outputs": [],
"source": [
"# Define the prompt we want the AI to respond to - the message the Human user is asking\n",
"msg = HumanMessage(content=\"Explain step by step. How old is the president of USA?\")\n",
Expand All @@ -136,7 +113,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -156,7 +133,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -177,7 +154,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -195,37 +172,9 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"As an AI language model, I cannot have personal experiences or preferences, but here are some interesting things that people commonly make with a Raspberry Pi:\n",
"\n",
"1. Media center or streaming device: Use the Raspberry Pi as a media center to stream movies, TV shows, and music.\n",
"\n",
"2. Retro gaming console: Turn the Raspberry Pi into a retro gaming console to play classic games from the 80s and 90s.\n",
"\n",
"3. Home automation system: Use the Raspberry Pi to control your home's lights, temperature, and other appliances.\n",
"\n",
"4. Security camera: Use the Raspberry Pi as a security camera to monitor your home or office.\n",
"\n",
"5. Robotics: Build a robot using the Raspberry Pi as the brain to control its movements and functions.\n",
"\n",
"6. Weather station: Use the Raspberry Pi to collect and display weather data from sensors.\n",
"\n",
"7. Virtual assistant: Create your own virtual assistant like Amazon's Alexa or Apple's Siri using the Raspberry Pi.\n",
"\n",
"8. Desktop computer: Use the Raspberry Pi as a desktop computer by adding a keyboard, mouse, and monitor.\n",
"\n",
"9. Smart mirror: Create a smart mirror that displays the weather, news, and other information.\n",
"\n",
"10. Internet of Things (IoT) projects: Use the Raspberry Pi to create IoT devices like smart thermostats, smart locks, and other smart home devices.\n"
]
}
],
"outputs": [],
"source": [
"# Run the chain only specifying the input variable.\n",
"response = chain.invoke({\"input\": \"raspberry pi\"})\n",
Expand Down
Loading

0 comments on commit dadf83f

Please sign in to comment.