diff --git a/week1/day1.ipynb b/week1/day1.ipynb index 0a3668c..1353f66 100644 --- a/week1/day1.ipynb +++ b/week1/day1.ipynb @@ -90,7 +90,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "4e2a9393-7767-488e-a8bf-27c12dca35bd", "metadata": {}, "outputs": [], @@ -131,10 +131,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "7b87cadb-d513-4303-baee-a37b6f938e4d", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "API key found and looks good so far!\n" + ] + } + ], "source": [ "# Load environment variables in a file called .env\n", "\n", @@ -155,7 +163,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "019974d9-f3ad-4a8a-b5f9-0a3719aea2d3", "metadata": {}, "outputs": [], @@ -198,7 +206,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "c5e793b2-6775-426a-a139-4848291d0463", "metadata": {}, "outputs": [], @@ -228,10 +236,65 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "2ef960cf-6dc2-4cda-afb3-b38be12f4c97", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Home - Edward Donner\n", + "Home\n", + "Connect Four\n", + "Outsmart\n", + "An arena that pits LLMs against each other in a battle of diplomacy and deviousness\n", + "About\n", + "Posts\n", + "Well, hi there.\n", + "I’m Ed. I like writing code and experimenting with LLMs, and hopefully you’re here because you do too. I also enjoy DJing (but I’m badly out of practice), amateur electronic music production (\n", + "very\n", + "amateur) and losing myself in\n", + "Hacker News\n", + ", nodding my head sagely to things I only half understand.\n", + "I’m the co-founder and CTO of\n", + "Nebula.io\n", + ". We’re applying AI to a field where it can make a massive, positive impact: helping people discover their potential and pursue their reason for being. Recruiters use our product today to source, understand, engage and manage talent. I’m previously the founder and CEO of AI startup untapt,\n", + "acquired in 2021\n", + ".\n", + "We work with groundbreaking, proprietary LLMs verticalized for talent, we’ve\n", + "patented\n", + "our matching model, and our award-winning platform has happy customers and tons of press coverage.\n", + "Connect\n", + "with me for more!\n", + "January 23, 2025\n", + "LLM Workshop – Hands-on with Agents – resources\n", + "December 21, 2024\n", + "Welcome, SuperDataScientists!\n", + "November 13, 2024\n", + "Mastering AI and LLM Engineering – Resources\n", + "October 16, 2024\n", + "From Software Engineer to AI Data Scientist – resources\n", + "Navigation\n", + "Home\n", + "Connect Four\n", + "Outsmart\n", + "An arena that pits LLMs against each other in a battle of diplomacy and deviousness\n", + "About\n", + "Posts\n", + "Get in touch\n", + "ed [at] edwarddonner [dot] com\n", + "www.edwarddonner.com\n", + "Follow me\n", + "LinkedIn\n", + "Twitter\n", + "Facebook\n", + "Subscribe to newsletter\n", + "Type your email…\n", + "Subscribe\n" + ] + } + ], "source": [ "# Let's try one out. Change the website and add print statements to follow along.\n", "\n", @@ -260,7 +323,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "abdb8417-c5dc-44bc-9bee-2e059d162699", "metadata": {}, "outputs": [], @@ -274,7 +337,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "f0275b1b-7cfe-4f9d-abfa-7650d378da0c", "metadata": {}, "outputs": [], @@ -292,10 +355,109 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, + "id": "5322efd4-4802-4a94-a8c1-692a67000869", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'You are an assistant that analyzes the contents of a website and provides a short summary, ignoring text that might be navigation related. Respond in markdown.'" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "system_prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "ea3f7ea8-3362-43e3-8d95-e8271ac4f721", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'You are looking at a website titled Home - Edward Donner\\nThe contents of this website is as follows; please provide a short summary of this website in markdown. If it includes news or announcements, then summarize these too.\\n\\nHome\\nConnect Four\\nOutsmart\\nAn arena that pits LLMs against each other in a battle of diplomacy and deviousness\\nAbout\\nPosts\\nWell, hi there.\\nI’m Ed. I like writing code and experimenting with LLMs, and hopefully you’re here because you do too. I also enjoy DJing (but I’m badly out of practice), amateur electronic music production (\\nvery\\namateur) and losing myself in\\nHacker News\\n, nodding my head sagely to things I only half understand.\\nI’m the co-founder and CTO of\\nNebula.io\\n. We’re applying AI to a field where it can make a massive, positive impact: helping people discover their potential and pursue their reason for being. Recruiters use our product today to source, understand, engage and manage talent. I’m previously the founder and CEO of AI startup untapt,\\nacquired in 2021\\n.\\nWe work with groundbreaking, proprietary LLMs verticalized for talent, we’ve\\npatented\\nour matching model, and our award-winning platform has happy customers and tons of press coverage.\\nConnect\\nwith me for more!\\nJanuary 23, 2025\\nLLM Workshop – Hands-on with Agents – resources\\nDecember 21, 2024\\nWelcome, SuperDataScientists!\\nNovember 13, 2024\\nMastering AI and LLM Engineering – Resources\\nOctober 16, 2024\\nFrom Software Engineer to AI Data Scientist – resources\\nNavigation\\nHome\\nConnect Four\\nOutsmart\\nAn arena that pits LLMs against each other in a battle of diplomacy and deviousness\\nAbout\\nPosts\\nGet in touch\\ned [at] edwarddonner [dot] com\\nwww.edwarddonner.com\\nFollow me\\nLinkedIn\\nTwitter\\nFacebook\\nSubscribe to newsletter\\nType your email…\\nSubscribe'" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "user_prompt_for(ed)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, "id": "26448ec4-5c00-4204-baec-7df91d11ff2e", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You are looking at a website titled Home - Edward Donner\n", + "The contents of this website is as follows; please provide a short summary of this website in markdown. If it includes news or announcements, then summarize these too.\n", + "\n", + "Home\n", + "Connect Four\n", + "Outsmart\n", + "An arena that pits LLMs against each other in a battle of diplomacy and deviousness\n", + "About\n", + "Posts\n", + "Well, hi there.\n", + "I’m Ed. I like writing code and experimenting with LLMs, and hopefully you’re here because you do too. I also enjoy DJing (but I’m badly out of practice), amateur electronic music production (\n", + "very\n", + "amateur) and losing myself in\n", + "Hacker News\n", + ", nodding my head sagely to things I only half understand.\n", + "I’m the co-founder and CTO of\n", + "Nebula.io\n", + ". We’re applying AI to a field where it can make a massive, positive impact: helping people discover their potential and pursue their reason for being. Recruiters use our product today to source, understand, engage and manage talent. I’m previously the founder and CEO of AI startup untapt,\n", + "acquired in 2021\n", + ".\n", + "We work with groundbreaking, proprietary LLMs verticalized for talent, we’ve\n", + "patented\n", + "our matching model, and our award-winning platform has happy customers and tons of press coverage.\n", + "Connect\n", + "with me for more!\n", + "January 23, 2025\n", + "LLM Workshop – Hands-on with Agents – resources\n", + "December 21, 2024\n", + "Welcome, SuperDataScientists!\n", + "November 13, 2024\n", + "Mastering AI and LLM Engineering – Resources\n", + "October 16, 2024\n", + "From Software Engineer to AI Data Scientist – resources\n", + "Navigation\n", + "Home\n", + "Connect Four\n", + "Outsmart\n", + "An arena that pits LLMs against each other in a battle of diplomacy and deviousness\n", + "About\n", + "Posts\n", + "Get in touch\n", + "ed [at] edwarddonner [dot] com\n", + "www.edwarddonner.com\n", + "Follow me\n", + "LinkedIn\n", + "Twitter\n", + "Facebook\n", + "Subscribe to newsletter\n", + "Type your email…\n", + "Subscribe\n" + ] + } + ], "source": [ "print(user_prompt_for(ed))" ] @@ -321,7 +483,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "id": "f25dcd35-0cd0-4235-9f64-ac37ed9eaaa5", "metadata": {}, "outputs": [], @@ -355,7 +517,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "0134dfa4-8299-48b5-b444-f2a8c3403c88", "metadata": {}, "outputs": [], @@ -371,10 +533,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "36478464-39ee-485c-9f3f-6a4e458dbc9c", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[{'role': 'system',\n", + " 'content': 'You are an assistant that analyzes the contents of a website and provides a short summary, ignoring text that might be navigation related. Respond in markdown.'},\n", + " {'role': 'user',\n", + " 'content': 'You are looking at a website titled Home - Edward Donner\\nThe contents of this website is as follows; please provide a short summary of this website in markdown. If it includes news or announcements, then summarize these too.\\n\\nHome\\nConnect Four\\nOutsmart\\nAn arena that pits LLMs against each other in a battle of diplomacy and deviousness\\nAbout\\nPosts\\nWell, hi there.\\nI’m Ed. I like writing code and experimenting with LLMs, and hopefully you’re here because you do too. I also enjoy DJing (but I’m badly out of practice), amateur electronic music production (\\nvery\\namateur) and losing myself in\\nHacker News\\n, nodding my head sagely to things I only half understand.\\nI’m the co-founder and CTO of\\nNebula.io\\n. We’re applying AI to a field where it can make a massive, positive impact: helping people discover their potential and pursue their reason for being. Recruiters use our product today to source, understand, engage and manage talent. I’m previously the founder and CEO of AI startup untapt,\\nacquired in 2021\\n.\\nWe work with groundbreaking, proprietary LLMs verticalized for talent, we’ve\\npatented\\nour matching model, and our award-winning platform has happy customers and tons of press coverage.\\nConnect\\nwith me for more!\\nJanuary 23, 2025\\nLLM Workshop – Hands-on with Agents – resources\\nDecember 21, 2024\\nWelcome, SuperDataScientists!\\nNovember 13, 2024\\nMastering AI and LLM Engineering – Resources\\nOctober 16, 2024\\nFrom Software Engineer to AI Data Scientist – resources\\nNavigation\\nHome\\nConnect Four\\nOutsmart\\nAn arena that pits LLMs against each other in a battle of diplomacy and deviousness\\nAbout\\nPosts\\nGet in touch\\ned [at] edwarddonner [dot] com\\nwww.edwarddonner.com\\nFollow me\\nLinkedIn\\nTwitter\\nFacebook\\nSubscribe to newsletter\\nType your email…\\nSubscribe'}]" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Try this out, and then try for a few more websites\n", "\n", @@ -391,7 +567,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "905b9919-aba7-45b5-ae65-81b3d1d78e34", "metadata": {}, "outputs": [], @@ -409,17 +585,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "id": "05e38d41-dfa4-4b20-9c96-c46ea75d9fb5", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "\"# Summary of Edward Donner's Website\\n\\nEdward Donner's website serves as a personal space for sharing his interests in coding, experimenting with large language models (LLMs), and his background in AI technology. As the co-founder and CTO of Nebula.io, he focuses on leveraging AI to assist individuals in discovering their potential. The site briefly mentions his previous venture, untapt, which was acquired in 2021.\\n\\n## Featured Areas\\n- **Connect Four**: A game or feature related to LLMs.\\n- **Outsmart**: An arena designed for competitive LLM interactions.\\n\\n## Recent Announcements\\n- **January 23, 2025**: Introduction of resources for an LLM Workshop focused on hands-on experience with agents.\\n- **December 21, 2024**: Welcome message for a group named SuperDataScientists.\\n- **November 13, 2024**: Release of resources for a program called Mastering AI and LLM Engineering.\\n- **October 16, 2024**: Provision of resources for transitioning from a Software Engineer to an AI Data Scientist.\\n\\nFor those interested in connecting further, there are options to get in touch via email or through social media platforms.\"" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "summarize(\"https://edwarddonner.com\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "3d926d59-450e-4609-92ba-2d6f244f1342", "metadata": {}, "outputs": [], @@ -433,10 +620,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "3018853a-445f-41ff-9560-d925d1774b2f", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/markdown": [ + "# Summary of Edward Donner's Website\n", + "\n", + "The website belongs to Edward Donner, a programmer and co-founder of Nebula.io, a company focused on using AI to assist individuals in discovering their potential. Ed shares his interests in writing code, experimenting with large language models (LLMs), and DJing. He has a background as the founder and CEO of the AI startup untapt, which was acquired in 2021.\n", + "\n", + "## Recent News and Announcements\n", + "- **January 23, 2025**: Announcement of an LLM Workshop focusing on hands-on experience with agents, providing resources for participants.\n", + "- **December 21, 2024**: A welcoming message to SuperDataScientists, likely referring to a community or initiative he supports.\n", + "- **November 13, 2024**: Release of resources for \"Mastering AI and LLM Engineering.\"\n", + "- **October 16, 2024**: Provision of resources for transitioning from Software Engineer to AI Data Scientist. \n", + "\n", + "Overall, the site serves as a platform for Ed to connect with others interested in LLMs and AI while sharing knowledge and resources." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "display_summary(\"https://edwarddonner.com\")" ] @@ -511,30 +721,58 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "00743dac-0e70-45b7-879a-d7293a6f68a6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "```markdown\n", + "Subject: Application for Software Engineer Position at XYZ.Inc\n", + "```\n" + ] + } + ], "source": [ "# Step 1: Create your prompts\n", "\n", - "system_prompt = \"something here\"\n", + "system_prompt = \"You are an assistant that analyzes the contents of a email \\\n", + "and provides a short subject line. \\\n", + "Respond in markdown.\"\n", "user_prompt = \"\"\"\n", - " Lots of text\n", - " Can be pasted here\n", + " The contents of the email is as follows. Please Suggest an appropriate short subject line for this.\n", + " Dear Hiring Manager, I am writing to apply for the Software Engineer role at XYZ.Inc that was advertised on Indeed. I was impressed with XYZ's reputation as a leading player in the Tech field, and I believe my skills and experience would be a strong asset to your team.\n", + "\n", + "In my current role as Software Engineer at ABC.Inc, I have gained valuable experience in C# and Angular, which I believe would be a valuable contribution to your team. Additionally, my skills has enabled me to deliver ground breaking projects.\n", + "\n", + "Please find attached my CV for your review. I would be happy to provide additional information or references upon request.\n", + "\n", + "Thank you for your consideration, and I look forward to the opportunity to discuss my application further.\n", + "\n", + "Sincerely,\n", + "\n", + "Applicant Name.\n", "\"\"\"\n", "\n", "# Step 2: Make the messages list\n", "\n", - "messages = [] # fill this in\n", + "messages = [\n", + " { \"role\": \"system\", \"content\": system_prompt},\n", + " { \"role\": \"user\", \"content\": user_prompt}\n", + "] # fill this in\n", "\n", "# Step 3: Call OpenAI\n", "\n", - "response =\n", + "response = openai.chat.completions.create(\n", + " model = \"gpt-4o-mini\",\n", + " messages = messages\n", + ")\n", "\n", "# Step 4: print the result\n", "\n", - "print(" + "print(response.choices[0].message.content)" ] }, { diff --git a/week1/day2 EXERCISE.ipynb b/week1/day2 EXERCISE.ipynb index 2c079f1..f19a464 100644 --- a/week1/day2 EXERCISE.ipynb +++ b/week1/day2 EXERCISE.ipynb @@ -68,7 +68,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "4e2a9393-7767-488e-a8bf-27c12dca35bd", "metadata": {}, "outputs": [], @@ -82,7 +82,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "29ddd15d-a3c5-4f4e-a678-873f56162724", "metadata": {}, "outputs": [], @@ -96,7 +96,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "dac0a679-599c-441f-9bf2-ddc73d35b940", "metadata": {}, "outputs": [], @@ -110,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "7bb9c624-14f0-4945-a719-8ddb64f66f47", "metadata": {}, "outputs": [], @@ -124,10 +124,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "479ff514-e8bd-4985-a572-2ea28bb4fa40", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[?25lpulling manifest ⠋ \u001b[?25h\u001b[?25l\u001b[2K\u001b[1Gpulling manifest ⠙ \u001b[?25h\u001b[?25l\u001b[2K\u001b[1Gpulling manifest ⠹ \u001b[?25h\u001b[?25l\u001b[2K\u001b[1Gpulling manifest ⠸ \u001b[?25h\u001b[?25l\u001b[2K\u001b[1Gpulling manifest ⠼ \u001b[?25h\u001b[?25l\u001b[2K\u001b[1Gpulling manifest ⠴ \u001b[?25h\u001b[?25l\u001b[2K\u001b[1Gpulling manifest ⠦ \u001b[?25h\u001b[?25l\u001b[2K\u001b[1Gpulling manifest \n", + "pulling dde5aa3fc5ff... 100% ▕████████████████▏ 2.0 GB \n", + "pulling 966de95ca8a6... 100% ▕████████████████▏ 1.4 KB \n", + "pulling fcc5a6bec9da... 100% ▕████████████████▏ 7.7 KB \n", + "pulling a70ff7e570d9... 100% ▕████████████████▏ 6.0 KB \n", + "pulling 56bb8bd477a5... 100% ▕████████████████▏ 96 B \n", + "pulling 34bb5ab01051... 100% ▕████████████████▏ 561 B \n", + "verifying sha256 digest \n", + "writing manifest \n", + "success \u001b[?25h\n" + ] + } + ], "source": [ "# Let's just make sure the model is loaded\n", "\n", @@ -136,10 +153,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "42b9f644-522d-4e05-a691-56e7658c0ea9", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Generative AI has numerous business applications across various industries, including:\n", + "\n", + "1. **Content Generation**: Generate high-quality content such as articles, social media posts, product descriptions, and more, saving time and resources for content creation teams.\n", + "2. **Image and Video Creation**: Use generative models to create visually appealing images, videos, and 3D models for marketing campaigns, advertising, and entertainment.\n", + "3. **Chatbots and Virtual Assistants**: Develop conversational interfaces that can understand and respond to customer inquiries, providing 24/7 support and improving customer satisfaction.\n", + "4. **Product Design and Development**: Utilize generative design tools to create innovative product designs, reducing the need for physical prototypes and accelerating the product development cycle.\n", + "5. **Marketing Automation**: Leverage generative AI to personalize marketing campaigns, predict customer behavior, and optimize sales funnels.\n", + "6. **Financial Modeling and Analysis**: Use generative models to build complex financial models, forecast market trends, and identify potential investment opportunities.\n", + "7. **Customer Segmentation and Profiling**: Develop advanced customer segmentation models that can identify high-value customers and provide personalized recommendations.\n", + "8. **Language Translation**: Generate human-like translations for text, speech, and audio content, breaking language barriers and facilitating global communication.\n", + "9. **Music and Audio Generation**: Create unique music tracks, sound effects, and voiceovers for film, TV, and advertising productions.\n", + "10. **Data Augmentation**: Use generative models to augment existing datasets, increasing the size and diversity of training data, improving model performance, and reducing data bias.\n", + "\n", + "Some specific business use cases include:\n", + "\n", + "* **Product Recommendation Engine**: Develop a platform that recommends products based on customer behavior, preferences, and purchase history.\n", + "* **Social Media Content Calendar**: Generate social media content in advance using generative models, ensuring consistent branding and messaging across platforms.\n", + "* **Personalized Email Marketing**: Create customized email campaigns that address individual customers' interests, preferences, and behavior.\n", + "* **Automated Customer Service**: Develop chatbots that can understand and respond to customer inquiries, providing 24/7 support and improving customer satisfaction.\n", + "\n", + "These are just a few examples of the many business applications of Generative AI. As the technology continues to evolve, we can expect to see even more innovative use cases emerge across various industries.\n" + ] + } + ], "source": [ "# If this doesn't work for any reason, try the 2 versions in the following cells\n", "# And double check the instructions in the 'Recap on installation of Ollama' at the top of this lab\n", @@ -163,10 +208,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "7745b9c4-57dc-4867-9180-61fa5db55eb8", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Generative AI has numerous business applications across various industries, including:\n", + "\n", + "1. **Content Generation**: Generative AI can create high-quality content such as blog posts, social media posts, product descriptions, and more. This can help businesses save time and resources while maintaining a consistent tone and style.\n", + "2. **Image and Video Creation**: Generative AI can generate images and videos for various purposes, including marketing materials, product demonstrations, and entertainment. For example, AI-generated videos can be used to create explainer content or social media clips.\n", + "3. **Chatbots and Virtual Assistants**: Generative AI can power chatbots and virtual assistants that provide customer support, answer frequently asked questions, and help with tasks such as booking appointments or making reservations.\n", + "4. **Product Design and Development**: Generative AI can assist in the design and development of new products by generating 3D models, prototypes, and even entire product lines. This can help businesses reduce costs and speed up product development.\n", + "5. **Marketing Automation**: Generative AI can automate marketing tasks such as email campaigns, social media advertising, and lead generation. This can help businesses personalize their marketing efforts and reach a wider audience.\n", + "6. **Predictive Maintenance**: Generative AI can analyze data from sensors and machines to predict when maintenance is required, reducing downtime and increasing overall efficiency.\n", + "7. **Customer Segmentation**: Generative AI can analyze customer data and behavior patterns to identify new segments and tailor marketing efforts to specific groups.\n", + "8. **Data Visualization**: Generative AI can create interactive visualizations of complex data sets, helping businesses communicate insights and trends more effectively.\n", + "9. **Sales Forecasting**: Generative AI can analyze historical sales data and market trends to predict future sales performance, enabling businesses to make more informed decisions.\n", + "10. **Language Translation**: Generative AI can translate text and speech in real-time, breaking down language barriers and enabling global communication.\n", + "\n", + "Some specific business applications of Generative AI include:\n", + "\n", + "* **Amazon's Product Recommendations**: Amazon uses Generative AI to create personalized product recommendations based on customer behavior and preferences.\n", + "* **Google's Search Results**: Google's search results are influenced by Generative AI, which helps rank relevant content and provide more accurate answers to user queries.\n", + "* **Salesforce's Chatbots**: Salesforce uses Generative AI-powered chatbots to provide customer support and answer frequently asked questions.\n", + "* **Netflix's Content Recommendations**: Netflix uses Generative AI to recommend personalized content to its users based on their viewing history and preferences.\n", + "\n", + "These are just a few examples of the many business applications of Generative AI. As the technology continues to evolve, we can expect to see even more innovative uses across various industries.\n" + ] + } + ], "source": [ "import ollama\n", "\n", @@ -285,9 +358,100 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "6de38216-6d1c-48c4-877b-86d403f4e0f8", "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "# Website Summary\n", + "The website is hosted by Edward Donner, a co-founder and CTO of Nebula.io, an AI startup that applies AI to help people discover their potential. The website appears to be a personal blog or profile page, showcasing his interests in LLMs (Large Language Models) and AI.\n", + "\n", + "### News and Announcements\n", + "\n", + "* **Upcoming Event**: January 23, 2025 - LLM Workshop – Hands-on with Agents – resources\n", + "* **Past Events**:\n", + "\t+ December 21, 2024 - Welcome, SuperDataScientists!\n", + "\t+ November 13, 2024 - Mastering AI and LLM Engineering – Resources\n", + "\t+ October 16, 2024 - From Software Engineer to AI Data Scientist – resources" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import os\n", + "import requests\n", + "from dotenv import load_dotenv\n", + "from bs4 import BeautifulSoup\n", + "from IPython.display import Markdown, display\n", + "from openai import OpenAI\n", + "\n", + "headers = {\n", + " \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36\"\n", + "}\n", + "\n", + "system_prompt = \"You are an assistant that analyzes the contents of a website \\\n", + "and provides a short summary, ignoring text that might be navigation related. \\\n", + "Respond in markdown.\"\n", + "\n", + "def user_prompt_for(website):\n", + " user_prompt = f\"You are looking at a website titled {website.title}\"\n", + " user_prompt += \"\\nThe contents of this website is as follows; \\\n", + "please provide a short summary of this website in markdown. \\\n", + "If it includes news or announcements, then summarize these too.\\n\\n\"\n", + " user_prompt += website.text\n", + " return user_prompt\n", + "\n", + "class Website:\n", + "\n", + " def __init__(self, url):\n", + " \"\"\"\n", + " Create this Website object from the given url using the BeautifulSoup library\n", + " \"\"\"\n", + " self.url = url\n", + " response = requests.get(url, headers=headers)\n", + " soup = BeautifulSoup(response.content, 'html.parser')\n", + " self.title = soup.title.string if soup.title else \"No title found\"\n", + " for irrelevant in soup.body([\"script\", \"style\", \"img\", \"input\"]):\n", + " irrelevant.decompose()\n", + " self.text = soup.body.get_text(separator=\"\\n\", strip=True)\n", + "\n", + "def messages_for(website):\n", + " return [\n", + " {\"role\": \"system\", \"content\": system_prompt},\n", + " {\"role\": \"user\", \"content\": user_prompt_for(website)}\n", + " ]\n", + "\n", + "def generate_payload(website):\n", + " return {\n", + " \"model\": MODEL,\n", + " \"messages\": messages_for(website),\n", + " \"stream\": False\n", + " }\n", + "\n", + "def summarize(url):\n", + " website = Website(url)\n", + " response = requests.post(OLLAMA_API, json=generate_payload(website), headers=HEADERS)\n", + " return response.json()['message']['content']\n", + "\n", + "def display_summary(url):\n", + " summary = summarize(url)\n", + " display(Markdown(summary))\n", + "\n", + "display_summary(\"https://edwarddonner.com\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fc350dae-4666-4627-bd12-668c2399e4aa", + "metadata": {}, "outputs": [], "source": [] }