diff --git a/week1/Guide to Jupyter.ipynb b/week1/Guide to Jupyter.ipynb index 6b377db..e39bb56 100644 --- a/week1/Guide to Jupyter.ipynb +++ b/week1/Guide to Jupyter.ipynb @@ -32,10 +32,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "33d37cd8-55c9-4e03-868c-34aa9cab2c80", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "4" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Click anywhere in this cell and press Shift + Return\n", "\n", @@ -54,7 +65,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "585eb9c1-85ee-4c27-8dc2-b4d8d022eda0", "metadata": {}, "outputs": [], @@ -66,10 +77,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "07792faa-761d-46cb-b9b7-2bbf70bb1628", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'bananas'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# The result of the last statement is shown after you run it\n", "\n", @@ -78,10 +100,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "a067d2b1-53d5-4aeb-8a3c-574d39ff654a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "My favorite fruit is anything but anything but bananas\n" + ] + } + ], "source": [ "# Use the variable\n", "\n", @@ -90,7 +120,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "4c5a4e60-b7f4-4953-9e80-6d84ba4664ad", "metadata": {}, "outputs": [], @@ -116,10 +146,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "8e5ec81d-7c5b-4025-bd2e-468d67b581b6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "My favorite fruit is anything but anything but bananas\n" + ] + } + ], "source": [ "# Then run this cell twice, and see if you understand what's going on\n", "\n", @@ -144,10 +182,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "84b1e410-5eda-4e2c-97ce-4eebcff816c5", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "My favorite fruit is apples\n" + ] + } + ], "source": [ "print(f\"My favorite fruit is {favorite_fruit}\")" ] diff --git a/week1/day1.ipynb b/week1/day1.ipynb index 33b5616..23726b5 100644 --- a/week1/day1.ipynb +++ b/week1/day1.ipynb @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "4e2a9393-7767-488e-a8bf-27c12dca35bd", "metadata": {}, "outputs": [], @@ -89,10 +89,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "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", @@ -113,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "019974d9-f3ad-4a8a-b5f9-0a3719aea2d3", "metadata": {}, "outputs": [], @@ -127,7 +135,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "c5e793b2-6775-426a-a139-4848291d0463", "metadata": {}, "outputs": [], @@ -146,23 +154,35 @@ " \"\"\"\n", " self.url = url\n", " response = requests.get(url)\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", + " \n", + " \n", " self.text = soup.body.get_text(separator=\"\\n\", strip=True)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "id": "2ef960cf-6dc2-4cda-afb3-b38be12f4c97", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'soup' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[23], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Let's try one out\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m ed \u001b[38;5;241m=\u001b[39m \u001b[43mWebsite\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhttps://jaivikhimalay.com\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;66;03m#ed = Website(\"https://edwarddonner.com\")\u001b[39;00m\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28mprint\u001b[39m(ed\u001b[38;5;241m.\u001b[39mtitle)\n", + "Cell \u001b[0;32mIn[22], line 17\u001b[0m, in \u001b[0;36mWebsite.__init__\u001b[0;34m(self, url)\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39murl \u001b[38;5;241m=\u001b[39m url\n\u001b[1;32m 14\u001b[0m response \u001b[38;5;241m=\u001b[39m requests\u001b[38;5;241m.\u001b[39mget(url)\n\u001b[0;32m---> 17\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtext \u001b[38;5;241m=\u001b[39m \u001b[43msoup\u001b[49m\u001b[38;5;241m.\u001b[39mbody\u001b[38;5;241m.\u001b[39mget_text(separator\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m, strip\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n", + "\u001b[0;31mNameError\u001b[0m: name 'soup' is not defined" + ] + } + ], "source": [ "# Let's try one out\n", "\n", - "ed = Website(\"https://edwarddonner.com\")\n", + "ed = Website(\"https://jaivikhimalay.com\")\n", + "#ed = Website(\"https://edwarddonner.com\")\n", "print(ed.title)\n", "print(ed.text)" ] @@ -187,7 +207,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "abdb8417-c5dc-44bc-9bee-2e059d162699", "metadata": {}, "outputs": [], @@ -201,7 +221,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "f0275b1b-7cfe-4f9d-abfa-7650d378da0c", "metadata": {}, "outputs": [], @@ -219,10 +239,71 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "id": "26448ec4-5c00-4204-baec-7df91d11ff2e", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You are looking at a website titled Jaivik Himalay\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", + "0\n", + "Skip to Content\n", + "Services\n", + "About\n", + "Contact\n", + "Open Menu\n", + "Close Menu\n", + "Services\n", + "About\n", + "Contact\n", + "Open Menu\n", + "Close Menu\n", + "Services\n", + "About\n", + "Contact\n", + "Enhance the accessibility of your products and services to customers\n", + "Application Architecture, Design & Development Services\n", + "Engaging and solving customers’ requirements to automate their business processes, by transforming requirements into a ready to use products.\n", + "Application Refactoring, Performance Improvement & Integration Services\n", + "Keeping clients by leveraging the latest practices and technologies in the industry to transform their outdated and sluggish systems into ones that are incredibly efficient.\n", + "Distribution Services\n", + "Assisting companies in meeting their requirements by sourcing a diverse range of products from both local and global markets.\n", + "Read More\n", + "Services\n", + "Application Architecture, Design & Development Services\n", + "We offer support to small and medium-sized businesses in developing their products or APIs from the initial concept to the launch stage. This encompasses every stage of the product life cycle.\n", + "Application Refactoring , Performance Improvement & Integration Services\n", + "With the support of the experience team, we can transform applications that were created using outdated technology. Applications that don't scale or perform well can also be redesigned, tested, and prepared for launch.\n", + "Distribution Services\n", + "We can assist you in lowering the price of importing or exporting goods to and from the United States and other nations. We are able to transport both domestically and abroad to a large number of businesses.\n", + "About Us\n", + "Group of seasoned experts that have spent the last 20 years working to solve clients' complex issues in the areas of payments, gift cards, logistics, and more.\n", + "We are situated in California's Silicon Valley.\n", + "Contact Us\n", + "Interested in working together? Fill out some info and we will be in touch shortly.\n", + "Name\n", + "*\n", + "First Name\n", + "Last Name\n", + "Email\n", + "*\n", + "Message\n", + "*\n", + "Thank you for contacting us! Will get back to you soon…\n", + "Location\n", + "Dublin, CA, 94568\n", + "Contact\n", + "info@jaivikhimalay.com\n", + "© Copyright 2024\n", + "Jaivik Himalay LLC\n", + ".\n" + ] + } + ], "source": [ "print(user_prompt_for(ed))" ] @@ -246,7 +327,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "id": "0134dfa4-8299-48b5-b444-f2a8c3403c88", "metadata": {}, "outputs": [], @@ -262,10 +343,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "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 Jaivik Himalay\\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\\n0\\nSkip to Content\\nServices\\nAbout\\nContact\\nOpen Menu\\nClose Menu\\nServices\\nAbout\\nContact\\nOpen Menu\\nClose Menu\\nServices\\nAbout\\nContact\\nEnhance the accessibility of your products and services to customers\\nApplication Architecture, Design & Development Services\\nEngaging and solving customers’ requirements to automate their business processes, by transforming requirements into a ready to use products.\\nApplication Refactoring, Performance Improvement & Integration Services\\nKeeping clients by leveraging the latest practices and technologies in the industry to transform their outdated and sluggish systems into ones that are incredibly efficient.\\nDistribution Services\\nAssisting companies in meeting their requirements by sourcing a diverse range of products from both local and global markets.\\nRead More\\nServices\\nApplication Architecture, Design & Development Services\\nWe offer support to small and medium-sized businesses in developing their products or APIs from the initial concept to the launch stage. This encompasses every stage of the product life cycle.\\nApplication Refactoring , Performance Improvement & Integration Services\\nWith the support of the experience team, we can transform applications that were created using outdated technology. Applications that don't scale or perform well can also be redesigned, tested, and prepared for launch.\\nDistribution Services\\nWe can assist you in lowering the price of importing or exporting goods to and from the United States and other nations. We are able to transport both domestically and abroad to a large number of businesses.\\nAbout Us\\nGroup of seasoned experts that have spent the last 20 years working to solve clients' complex issues in the areas of payments, gift cards, logistics, and more.\\nWe are situated in California's Silicon Valley.\\nContact Us\\nInterested in working together? Fill out some info and we will be in touch shortly.\\nName\\n*\\nFirst Name\\nLast Name\\nEmail\\n*\\nMessage\\n*\\nThank you for contacting us! Will get back to you soon…\\nLocation\\nDublin, CA, 94568\\nContact\\ninfo@jaivikhimalay.com\\n© Copyright 2024\\nJaivik Himalay LLC\\n.\"}]" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "messages_for(ed)" ] @@ -280,7 +375,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "905b9919-aba7-45b5-ae65-81b3d1d78e34", "metadata": {}, "outputs": [], @@ -290,6 +385,7 @@ "def summarize(url):\n", " website = Website(url)\n", " response = openai.chat.completions.create(\n", + " \n", " model = \"gpt-4o-mini\",\n", " messages = messages_for(website)\n", " )\n", @@ -298,17 +394,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "05e38d41-dfa4-4b20-9c96-c46ea75d9fb5", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'# Summary of Edward Donner\\'s Website\\n\\nThe website \"Home - Edward Donner\" features Ed, a code enthusiast and LLM (Large Language Model) experimenter. He is the co-founder and CTO of Nebula.io, a company focused on utilizing AI to improve talent discovery and management. Previously, Ed founded the AI startup untapt, which was acquired in 2021.\\n\\n## Key Features:\\n- **Outsmart**: A platform for LLMs to compete in diplomacy and strategy.\\n- **About Ed**: Personal insights about his interests in coding, DJing, and tech news.\\n- **Expertise**: Highlights his work with proprietary LLMs and a patented matching model in the recruitment space.\\n\\n## Recent Announcements and Posts:\\n- **November 13, 2024**: Resources for mastering AI and LLM engineering.\\n- **October 16, 2024**: Resources for transitioning from software engineer to AI data scientist.\\n- **August 6, 2024**: Introduction to the Outsmart LLM arena concept.\\n- **June 26, 2024**: Guidance on choosing the right LLM with a toolkit and resources.'" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "summarize(\"https://edwarddonner.com\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "id": "3d926d59-450e-4609-92ba-2d6f244f1342", "metadata": {}, "outputs": [], @@ -322,10 +429,41 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "3018853a-445f-41ff-9560-d925d1774b2f", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/markdown": [ + "# Website Summary: Edward Donner\n", + "\n", + "Edward Donner's website serves as a personal platform showcasing his passion for coding, experimenting with Large Language Models (LLMs), and his professional background in AI. Ed is the co-founder and CTO of Nebula.io, an AI-driven company focused on talent discovery and management, and he previously founded the startup untapt, which was acquired in 2021.\n", + "\n", + "## Key Highlights:\n", + "\n", + "- **Outsmart**: A featured section dedicated to an arena where LLMs compete in diplomatic and strategic challenges.\n", + " \n", + "- **Professional Background**: \n", + " - Co-founder and CTO of Nebula.io, which utilizes AI to enhance talent engagement.\n", + " - Former CEO of untapt, an AI startup acquired in 2021.\n", + "\n", + "## Recent Posts:\n", + "1. **Mastering AI and LLM Engineering – Resources** (Published on November 13, 2024)\n", + "2. **From Software Engineer to AI Data Scientist – Resources** (Published on October 16, 2024)\n", + "3. **Outsmart LLM Arena – A battle of diplomacy and deviousness** (Published on August 6, 2024)\n", + "4. **Choosing the Right LLM: Toolkit and Resources** (Published on June 26, 2024)\n", + "\n", + "The website presents a blend of personal interests, professional expertise, and resources relevant to those in the field of AI and LLMs." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "display_summary(\"https://edwarddonner.com\")" ] @@ -348,20 +486,81 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "45d83403-a24c-44b5-84ac-961449b4008f", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/markdown": [ + "# Summary of CNN Website\n", + "\n", + "CNN is a comprehensive news platform that offers the latest updates across various categories including US and global news, politics, business, health, entertainment, science, and sports. The website features a mix of articles, videos, and live broadcasts, focusing on breaking news and significant events worldwide.\n", + "\n", + "## Notable Headlines and Topics:\n", + "- **2024 Elections:** Coverage on upcoming elections in the US.\n", + "- **Ukraine-Russia War:** Ongoing updates and live news regarding the conflict.\n", + "- **Israel-Hamas War:** Reports and analyses related to the recent escalation in hostilities.\n", + "- **Black Friday Deals:** Highlighting early promotions and deals from various retailers.\n", + "- **Health:** Articles discussing various health-related topics, including tips and recent studies.\n", + "\n", + "## Recent Event Highlights:\n", + "- **Gaetz Withdrawal:** Matt Gaetz withdrew as Trump’s attorney general pick amid allegations of misconduct.\n", + "- **Sexual Assault Allegations:** Multiple stories covering serious allegations against political figures, including reports linked to Trump's nominees.\n", + "- **Ground Beef Recall:** An issue of possible E. coli contamination affecting consumers.\n", + "- **Air Travel:** Warnings about potential delays for upcoming Thanksgiving air traffic.\n", + "\n", + "CNN also emphasizes their multimedia content, offering access to live streaming, podcasts, and interactive features on trending topics. The site encourages user engagement through feedback on their ads and technical experiences. \n", + "\n", + "Overall, CNN stands as a key source for real-time news and political commentary, ensuring that readers and viewers stay informed on current events." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "display_summary(\"https://cnn.com\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "id": "75e9fd40-b354-4341-991e-863ef2e59db7", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/markdown": [ + "# Anthropic Overview\n", + "\n", + "Anthropic is an AI safety and research company based in San Francisco, focused on developing advanced AI systems that prioritize safety and reliability. The company is known for its interdisciplinary team with expertise in machine learning (ML), physics, policy, and product development.\n", + "\n", + "## Key Offerings\n", + "\n", + "- **Claude 3.5 Sonnet:** The latest and most intelligent AI model launched by Anthropic.\n", + "- **Claude for Enterprise:** A tailored solution for businesses to leverage AI for efficiency and new revenue opportunities.\n", + "- **API Access:** Allows developers and organizations to integrate Claude into their applications.\n", + "\n", + "## Recent Announcements\n", + "\n", + "- **Introduction of Claude 3.5 Sonnet and Claude 3.5 Haiku:** New models released on October 22, 2024, aimed at enhancing AI capabilities.\n", + "- **Core Views on AI Safety:** A deeper discussion on AI safety published on March 8, 2023.\n", + "- **Research Paper on Constitutional AI:** Focuses on the concept of harmlessness derived from AI feedback, published on December 15, 2022.\n", + "\n", + "Anthropic emphasizes the importance of aligning AI systems with human values and creating products that ensure safe interactions with artificial intelligence." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "display_summary(\"https://anthropic.com\")" ] @@ -404,9 +603,52 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "id": "682eff74-55c4-4d4b-b267-703edbc293c7", "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "# Jaivik Himalay Overview\n", + "\n", + "Jaivik Himalay is a company specializing in various services aimed at enhancing business processes, application development, and distribution solutions. The main offerings include:\n", + "\n", + "## Services\n", + "1. **Application Architecture, Design & Development**: Assistance for small to medium-sized businesses in developing products or APIs from concept to launch, covering all stages of the product lifecycle.\n", + " \n", + "2. **Application Refactoring & Performance Improvement**: Transforming outdated applications into efficient, scalable solutions through comprehensive redesign and testing.\n", + "\n", + "3. **Distribution Services**: Support for businesses in sourcing a diverse range of products locally and globally, with a focus on reducing import/export costs.\n", + "\n", + "## About Us\n", + "The company is based in Silicon Valley, California, and comprises a team of seasoned experts with over 20 years of experience in solving complex client issues in payments, gift cards, logistics, and more.\n", + "\n", + "For inquiries or collaboration, contact details are provided, and interested individuals can submit their information through the contact form.\n", + "\n", + "### Contact Information\n", + "- **Location**: Dublin, CA, 94568\n", + "- **Email**: info@jaivikhimalay.com\n", + "\n", + "*Note: The website does not mention any specific news or announcements.*" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "display_summary(\"https://jaivikhimalay.com\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2df0c85f-3815-4c7b-bc17-3fb61aeb75f6", + "metadata": {}, "outputs": [], "source": [] } diff --git a/week1/day2 EXERCISE.ipynb b/week1/day2 EXERCISE.ipynb index 987ef5c..b353341 100644 --- a/week1/day2 EXERCISE.ipynb +++ b/week1/day2 EXERCISE.ipynb @@ -34,7 +34,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "4e2a9393-7767-488e-a8bf-27c12dca35bd", "metadata": {}, "outputs": [], @@ -48,7 +48,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "29ddd15d-a3c5-4f4e-a678-873f56162724", "metadata": {}, "outputs": [], @@ -62,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "dac0a679-599c-441f-9bf2-ddc73d35b940", "metadata": {}, "outputs": [], @@ -76,7 +76,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "7bb9c624-14f0-4945-a719-8ddb64f66f47", "metadata": {}, "outputs": [], @@ -90,10 +90,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "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 Creation**: Generative AI can generate high-quality content such as articles, social media posts, product descriptions, and more. This can help reduce content creation costs and increase efficiency.\n", + "2. **Image and Video Generation**: Generative AI can create realistic images and videos for use in marketing campaigns, advertising, and product demonstrations.\n", + "3. **Customer Service Chatbots**: Generative AI-powered chatbots can be used to provide customer support, answering frequently asked questions, and helping customers with simple issues.\n", + "4. **Personalized Recommendations**: Generative AI algorithms can analyze customer behavior and preferences to generate personalized recommendations for products, services, or content.\n", + "5. **Product Design and Prototyping**: Generative AI can aid in product design and prototyping by generating multiple design options, reducing the need for physical prototypes and speeding up the design process.\n", + "6. **Supply Chain Optimization**: Generative AI can analyze supply chain data to predict demand, optimize inventory levels, and identify potential bottlenecks.\n", + "7. **Marketing Automation**: Generative AI can automate repetitive marketing tasks such as email campaigns, social media posts, and ad targeting.\n", + "8. **Data Analysis and Insights**: Generative AI algorithms can analyze large datasets to identify trends, patterns, and insights that may not be apparent through human analysis alone.\n", + "9. **Financial Modeling and Forecasting**: Generative AI can help forecast sales, revenue, and expenses by analyzing historical data and identifying potential risks and opportunities.\n", + "10. **Cybersecurity Threat Detection**: Generative AI-powered systems can analyze network traffic and identify potential security threats in real-time.\n", + "11. **Creative Writing and Editing**: Generative AI can assist writers with content creation, editing, and proofreading tasks such as suggesting alternative phrases or sentence structures.\n", + "12. **Human Resources Management**: Generative AI can help automate HR tasks such as recruitment, talent management, and performance evaluations.\n", + "\n", + "Some specific business use cases for Generative AI include:\n", + "\n", + "* **Virtual assistants**: Companies like Google and Microsoft are using Generative AI to create virtual assistants that can understand natural language queries and provide personalized responses.\n", + "* **Personalized product recommendations**: Retailers like Amazon and Apple are using Generative AI to generate personalized product recommendations based on customer behavior and preferences.\n", + "* **Automated marketing campaigns**: Marketers are using Generative AI to automate repetitive marketing tasks such as email campaigns, social media posts, and ad targeting.\n", + "* **Predictive maintenance**: Manufacturers are using Generative AI to predict equipment failures and schedule maintenance accordingly, reducing downtime and increasing efficiency.\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.\n" + ] + } + ], "source": [ "response = requests.post(OLLAMA_API, json=payload, headers=HEADERS)\n", "print(response.json()['message']['content'])" @@ -113,10 +143,39 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "7745b9c4-57dc-4867-9180-61fa5db55eb8", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Generative AI has numerous business applications across various industries. Here are some examples:\n", + "\n", + "1. **Content Generation**: Generative AI can be used to generate high-quality content such as blog posts, social media posts, product descriptions, and even entire articles. This can help businesses save time and resources while still producing engaging and relevant content.\n", + "2. **Product Design**: Generative AI can assist in the design of products by generating 3D models, prototypes, and even functional prototypes. This can be particularly useful for companies that require rapid prototyping or have limited in-house design capabilities.\n", + "3. **Marketing Automation**: Generative AI can help automate marketing efforts by generating personalized email campaigns, social media ads, and even lead generation content.\n", + "4. **Customer Service Chatbots**: Generative AI-powered chatbots can provide 24/7 customer support, answering common queries, and helping to resolve simple issues. This can free up human customer service agents to focus on more complex and emotionally charged issues.\n", + "5. **Data Analysis and Insights**: Generative AI can be used to analyze large datasets and identify patterns, trends, and insights that may have gone unnoticed by humans. This can help businesses gain a competitive edge and make data-driven decisions.\n", + "6. **Virtual Assistants**: Generative AI-powered virtual assistants can be integrated into various business systems to provide personalized support and guidance to employees, customers, or partners.\n", + "7. **Supply Chain Optimization**: Generative AI can be used to optimize supply chain operations by predicting demand, managing inventory levels, and identifying potential bottlenecks.\n", + "8. **Risk Management**: Generative AI-powered risk management tools can help businesses identify and mitigate potential risks, such as financial losses, regulatory non-compliance, or reputational damage.\n", + "9. **Financial Analysis**: Generative AI can be used to analyze large datasets of financial transactions, predicting market trends, identifying potential investment opportunities, and detecting fraudulent activity.\n", + "10. **Cybersecurity Threat Detection**: Generative AI-powered threat detection tools can help identify and respond to cybersecurity threats in real-time, reducing the risk of data breaches and other security incidents.\n", + "\n", + "Some specific examples of businesses that are already leveraging Generative AI include:\n", + "\n", + "* Google (using Generative AI for image search and content generation)\n", + "* Amazon (using Generative AI for product recommendations and customer service chatbots)\n", + "* IBM (using Generative AI for marketing automation and sales forecasting)\n", + "* Accenture (using Generative AI for data analysis and insights)\n", + "* NVIDIA (using Generative AI for computer vision and graphics rendering)\n", + "\n", + "These are just a few examples, but the potential applications of Generative AI are vast and continue to expand as the technology advances.\n" + ] + } + ], "source": [ "import ollama\n", "\n", @@ -141,6 +200,282 @@ "\n", "Take the code from day1 and incorporate it here, to build a website summarizer that uses Llama 3.2 running locally instead of OpenAI" ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "00496450-b078-469c-8072-4cb633df9928", + "metadata": {}, + "outputs": [], + "source": [ + "# imports\n", + "\n", + "import requests\n", + "from bs4 import BeautifulSoup\n", + "from IPython.display import Markdown, display" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "37aea1a6-2d35-4c8b-9264-43da5884d069", + "metadata": {}, + "outputs": [], + "source": [ + "# Constants\n", + "MODEL = \"llama3.2\"" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "id": "383f8e2a-c98d-48bc-9c3f-ece4ef077ec9", + "metadata": {}, + "outputs": [], + "source": [ + "# A class to represent a Webpage\n", + "\n", + "class Website:\n", + " \"\"\"\n", + " A utility class to represent a Website that we have scraped\n", + " \"\"\"\n", + " url: str\n", + " title: str\n", + " text: str\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)\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)" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "36e99eba-5758-4471-8860-2f5a42771e6b", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "https://jaivikhimalay.com\n", + "Jaivik Himalay\n", + "0\n", + "Skip to Content\n", + "Services\n", + "About\n", + "Contact\n", + "Open Menu\n", + "Close Menu\n", + "Services\n", + "About\n", + "Contact\n", + "Open Menu\n", + "Close Menu\n", + "Services\n", + "About\n", + "Contact\n", + "Enhance the accessibility of your products and services to customers\n", + "Application Architecture, Design & Development Services\n", + "Engaging and solving customers’ requirements to automate their business processes, by transforming requirements into a ready to use products.\n", + "Application Refactoring, Performance Improvement & Integration Services\n", + "Keeping clients by leveraging the latest practices and technologies in the industry to transform their outdated and sluggish systems into ones that are incredibly efficient.\n", + "Distribution Services\n", + "Assisting companies in meeting their requirements by sourcing a diverse range of products from both local and global markets.\n", + "Read More\n", + "Services\n", + "Application Architecture, Design & Development Services\n", + "We offer support to small and medium-sized businesses in developing their products or APIs from the initial concept to the launch stage. This encompasses every stage of the product life cycle.\n", + "Application Refactoring , Performance Improvement & Integration Services\n", + "With the support of the experience team, we can transform applications that were created using outdated technology. Applications that don't scale or perform well can also be redesigned, tested, and prepared for launch.\n", + "Distribution Services\n", + "We can assist you in lowering the price of importing or exporting goods to and from the United States and other nations. We are able to transport both domestically and abroad to a large number of businesses.\n", + "About Us\n", + "Group of seasoned experts that have spent the last 20 years working to solve clients' complex issues in the areas of payments, gift cards, logistics, and more.\n", + "We are situated in California's Silicon Valley.\n", + "Contact Us\n", + "Interested in working together? Fill out some info and we will be in touch shortly.\n", + "Name\n", + "*\n", + "First Name\n", + "Last Name\n", + "Email\n", + "*\n", + "Message\n", + "*\n", + "Thank you for contacting us! Will get back to you soon…\n", + "Location\n", + "Dublin, CA, 94568\n", + "Contact\n", + "info@jaivikhimalay.com\n", + "© Copyright 2024\n", + "Jaivik Himalay LLC\n", + ".\n" + ] + } + ], + "source": [ + "ed = Website(\"https://jaivikhimalay.com\")\n", + "print(ed.url)\n", + "print(ed.title)\n", + "print(ed.text)" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "id": "793f8c35-fbde-4160-90b5-a2fd8ea5f5e6", + "metadata": {}, + "outputs": [], + "source": [ + "# Define our system prompt - you can experiment with this later, changing the last sentence to 'Respond in markdown in Spanish.\"\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.\"" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "ecbfa0e2-39c2-4467-989b-4ab9810de72d", + "metadata": {}, + "outputs": [], + "source": [ + "# A function that writes a User Prompt that asks for summaries of websites:\n", + "\n", + "def user_prompt_for(website):\n", + " user_prompt = f\"You are looking at a website titled {website.title}\"\n", + " user_prompt += \"The 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" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "cf5a1da8-1628-4bbb-a2f8-e06409fe4e45", + "metadata": {}, + "outputs": [], + "source": [ + "# See how this function creates exactly the format above\n", + "\n", + "def messages_for(website):\n", + " return [\n", + " {\"role\": \"system\", \"content\": system_prompt},\n", + " {\"role\": \"user\", \"content\": user_prompt_for(website)}\n", + " ]" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "fc9040a8-0a62-4658-94d9-0674b9045986", + "metadata": {}, + "outputs": [], + "source": [ + "# And now: call the Ollama function instead of OpenAI\n", + "\n", + "def summarize(url):\n", + " website = Website(url)\n", + " messages = messages_for(website)\n", + " response = ollama.chat(model=MODEL, messages=messages)\n", + " return response['message']['content']" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "fc2aff45-ba1d-44f8-8b5d-f34934eb1ee8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"# Website Summary\\n### Overview\\n\\nJaivik Himalay is a technology consulting firm that offers a range of services to help businesses improve their products and services, automate business processes, and enhance accessibility.\\n\\n### Services\\n\\n* **Application Architecture**: Development of applications from concept to launch for small and medium-sized businesses.\\n* **Refactoring & Integration**: Transformation of outdated applications into efficient ones using the latest industry practices and technologies.\\n* **Distribution Services**: Sourcing diverse products from local and global markets to meet clients' requirements.\\n\\n### About Us\\n\\nJaivik Himalay is a group of seasoned experts with 20 years of experience solving complex issues in various areas, including payments, gift cards, logistics. The company is based in California's Silicon Valley.\\n\\n### Contact Us\\n\\nThe company invites interested individuals to contact them through the provided email address.\"" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "summarize(\"https://jaivikhimalay.com\")" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "ef0e940d-fed4-417b-8d95-4a0fd3b9b3d7", + "metadata": {}, + "outputs": [], + "source": [ + "def display_summary(url):\n", + " summary = summarize(url)\n", + " display(Markdown(summary))" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "086296f1-c748-4747-93d2-554732392400", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "# Jaivik Himalaya Website Summary\n", + "\n", + "## Overview\n", + "\n", + "Jaivik Himalaya is a professional services company specializing in application development, refactoring, and distribution services.\n", + "\n", + "### Key Services\n", + "\n", + "- **Application Architecture**: Designing and developing products or APIs from concept to launch.\n", + "- **Application Refactoring & Performance Improvement**: Transforming outdated systems into efficient ones using latest industry practices and technologies.\n", + "- **Distribution Services**: Sourcing products from local and global markets to assist businesses in meeting their requirements.\n", + "\n", + "### About Us\n", + "\n", + "Jaivik Himalaya is led by a group of experienced experts with 20 years of experience solving complex issues in various domains such as payments, gift cards, logistics, etc. The company is based in Silicon Valley, California.\n", + "\n", + "### Contact Information\n", + "\n", + "- Email: `info@jaivikhimalay.com`\n", + "- Location: Dublin, CA 94568\n", + "- Address: No specific address provided on the website." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "display_summary(\"https://jaivikhimalay.com\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "83e150e1-5b2c-45b7-9154-aae5b55943af", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/week1/solutions/day2 SOLUTION.ipynb b/week1/solutions/day2 SOLUTION.ipynb index 6d688fc..5024f37 100644 --- a/week1/solutions/day2 SOLUTION.ipynb +++ b/week1/solutions/day2 SOLUTION.ipynb @@ -34,7 +34,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 1, "id": "4e2a9393-7767-488e-a8bf-27c12dca35bd", "metadata": {}, "outputs": [], @@ -49,7 +49,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 2, "id": "29ddd15d-a3c5-4f4e-a678-873f56162724", "metadata": {}, "outputs": [], @@ -61,7 +61,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 3, "id": "c5e793b2-6775-426a-a139-4848291d0463", "metadata": {}, "outputs": [], @@ -91,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 4, "id": "2ef960cf-6dc2-4cda-afb3-b38be12f4c97", "metadata": {}, "outputs": [ @@ -121,14 +121,14 @@ "our matching model, and our award-winning platform has happy customers and tons of press coverage.\n", "Connect\n", "with me for more!\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", "August 6, 2024\n", "Outsmart LLM Arena – a battle of diplomacy and deviousness\n", "June 26, 2024\n", "Choosing the Right LLM: Toolkit and Resources\n", - "February 7, 2024\n", - "Fine-tuning an LLM on your texts: a simulation of you\n", "Navigation\n", "Home\n", "Outsmart\n", @@ -176,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 5, "id": "abdb8417-c5dc-44bc-9bee-2e059d162699", "metadata": {}, "outputs": [], @@ -190,7 +190,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 6, "id": "f0275b1b-7cfe-4f9d-abfa-7650d378da0c", "metadata": {}, "outputs": [], @@ -224,7 +224,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 7, "id": "0134dfa4-8299-48b5-b444-f2a8c3403c88", "metadata": {}, "outputs": [], @@ -248,7 +248,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 8, "id": "905b9919-aba7-45b5-ae65-81b3d1d78e34", "metadata": {}, "outputs": [], @@ -264,17 +264,17 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 9, "id": "05e38d41-dfa4-4b20-9c96-c46ea75d9fb5", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'**Summary**\\n\\n* Website belongs to Edward Donner, a co-founder and CTO of Nebula.io.\\n* He is the founder and CEO of AI startup untapt, which was acquired in 2021.\\n\\n**News/Announcements**\\n\\n* October 16, 2024: \"From Software Engineer to AI Data Scientist – resources\" (resource list for career advancement)\\n* August 6, 2024: \"Outsmart LLM Arena – a battle of diplomacy and deviousness\" (introducing the Outsmart arena, a competition between LLMs)\\n* June 26, 2024: \"Choosing the Right LLM: Toolkit and Resources\" (resource list for selecting the right LLM)\\n* February 7, 2024: \"Fine-tuning an LLM on your texts: a simulation of you\" (blog post about simulating human-like conversations with LLMs)'" + "'# Website Summary\\n### Overview\\nThe website \"Home - Edward Donner\" appears to be the personal homepage of Ed, a tech enthusiast and AI expert. The site showcases his interests in writing code, experimenting with Large Language Models (LLMs), DJing, and amateur electronic music production.\\n\\n### Featured Content\\n* **Outsmart LLM Arena**: An arena where LLMs compete against each other in a battle of diplomacy and deviousness.\\n* **News/Announcements**\\n\\t+ Mastering AI and LLM Engineering – Resources (published on November 13, 2024)\\n\\t+ From Software Engineer to AI Data Scientist – resources (published on October 16, 2024)\\n\\t+ Outsmart LLM Arena – a battle of diplomacy and deviousness (published on June 26, 2024)\\n\\n### About Ed\\nEd is the co-founder and CTO of Nebula.io, an AI company that applies AI to help people discover their potential. He also founded and led AI startup untapt before its acquisition in 2021.\\n\\n### Contact Information\\n- Email: ed [at] edwarddonner [dot] com\\n- Website: www.edwarddonner.com\\n- Social Media:\\n\\t+ LinkedIn\\n\\t+ Twitter\\n\\t+ Facebook'" ] }, - "execution_count": 12, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -285,7 +285,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 10, "id": "3d926d59-450e-4609-92ba-2d6f244f1342", "metadata": {}, "outputs": [],