"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",
"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",
"Navigation\n",
"Home\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\n",
"\n",
@ -132,7 +185,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "abdb8417-c5dc-44bc-9bee-2e059d162699",
"metadata": {},
"outputs": [],
@ -144,7 +197,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "f0275b1b-7cfe-4f9d-abfa-7650d378da0c",
"metadata": {},
"outputs": [],
@ -177,7 +230,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "0134dfa4-8299-48b5-b444-f2a8c3403c88",
"metadata": {},
"outputs": [],
@ -199,7 +252,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"id": "905b9919-aba7-45b5-ae65-81b3d1d78e34",
"metadata": {},
"outputs": [],
@ -215,17 +268,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"id": "05e38d41-dfa4-4b20-9c96-c46ea75d9fb5",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"\"# Summary of Edward Donner's Website\\n\\nEdward Donner's website features insights into his interests in coding and experimenting with large language models (LLMs). As the co-founder and CTO of Nebula.io, Donner focuses on leveraging AI to improve talent discovery and management. He has a background in AI startups, highlighting a successful acquisition of his previous venture, untapt, in 2021.\\n\\n## Recent Posts\\n- **November 13, 2024**: *Mastering AI and LLM Engineering – Resources*\\n- **October 16, 2024**: *From Software Engineer to AI Data Scientist – Resources*\\n- **August 6, 2024**: *Outsmart LLM Arena – A Battle of Diplomacy and Deviousness*\\n- **June 26, 2024**: *Choosing the Right LLM: Toolkit and Resources*\\n\\nThe site encourages visitors to connect and shares his passion for technology and music.\""
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"summarize(\"https://edwarddonner.com\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"id": "3d926d59-450e-4609-92ba-2d6f244f1342",
"metadata": {},
"outputs": [],
@ -237,10 +301,38 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"id": "3018853a-445f-41ff-9560-d925d1774b2f",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/markdown": [
"# Summary of Edward Donner's Website\n",
"\n",
"Edward Donner's website serves as a platform for sharing insights and developments related to large language models (LLMs) and their applications. \n",
"\n",
"### About Edward\n",
"Edward describes himself as a programmer and enthusiast of LLMs, with interests in DJing and electronic music production. He is the co-founder and CTO of Nebula.io, a company focused on leveraging AI to enhance talent discovery and engagement in a job context. He previously founded the AI startup untapt, which was acquired in 2021. \n",
"\n",
"### Featured Content\n",
"The website highlights several posts with resources that include:\n",
"- **Mastering AI and LLM Engineering** (November 13, 2024)\n",
"- **From Software Engineer to AI Data Scientist** (October 16, 2024)\n",
"- **Outsmart LLM Arena** (August 6, 2024) - An initiative designed to challenge LLMs in strategic scenarios.\n",
"- **Choosing the Right LLM: Toolkit and Resources** (June 26, 2024)\n",
"\n",
"### Focus\n",
"The website primarily emphasizes exploring LLMs and their transformative potential, especially in the realm of talent management. There are also connections to various platforms where Edward can be followed or contacted."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"display_summary(\"https://edwarddonner.com\")"
]
@ -277,20 +369,49 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"id": "52ae98bb",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/markdown": [
"# Summary of Website Content\n",
"\n",
"The website appears to be inaccessible due to a prompt requesting users to enable JavaScript and cookies in their web browser. As a result, no specific content, news, or announcements can be summarized from the site at this time. \n",
"\n",
"For a full experience and access to content, it is necessary to adjust browser settings accordingly."
"Cell \u001b[1;32mIn[14], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m#Parse webpages which is designed using JavaScript heavely\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;66;03m# download the chorme driver from here as per your version of chrome - https://developer.chrome.com/docs/chromedriver/downloads\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mselenium\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m webdriver\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mselenium\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mwebdriver\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mchrome\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mservice\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Service\n\u001b[0;32m 5\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mselenium\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mwebdriver\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcommon\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mby\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m By\n",
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'selenium'"
]
}
],
"source": [
"#Parse webpages which is designed using JavaScript heavely\n",
"# download the chorme driver from here as per your version of chrome - https://developer.chrome.com/docs/chromedriver/downloads\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",
"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",
"Navigation\n",
"Home\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",
@ -238,7 +309,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "abdb8417-c5dc-44bc-9bee-2e059d162699",
"metadata": {},
"outputs": [],
@ -252,7 +323,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"id": "a1b3fcc3-1152-41a4-b4ad-a6d66ee18b79",
"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": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"system_prompt"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "f0275b1b-7cfe-4f9d-abfa-7650d378da0c",
"metadata": {},
"outputs": [],
@ -270,10 +362,65 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"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",
"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",
"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",
"Navigation\n",
"Home\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))"
]
@ -299,7 +446,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"id": "f25dcd35-0cd0-4235-9f64-ac37ed9eaaa5",
"metadata": {},
"outputs": [],
@ -312,10 +459,40 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"id": "6100800a-f1dd-4624-9956-75735225be02",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'role': 'system', 'content': 'You are a snarky assistant'},\n",
" {'role': 'user', 'content': 'What is 2 + 2?'}]"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"messages"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "21ed95c5-7001-47de-a36d-1d6673b403ce",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Oh, we're doing math now? Well, 2 + 2 equals 4. Shocking, I know!\n"
]
}
],
"source": [
"# To give you a preview -- calling OpenAI with system and user messages:\n",
"\n",
@ -333,7 +510,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"id": "0134dfa4-8299-48b5-b444-f2a8c3403c88",
"metadata": {},
"outputs": [],
@ -349,10 +526,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 21,
"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\\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!\\nNovember 13, 2024\\nMastering AI and LLM Engineering – Resources\\nOctober 16, 2024\\nFrom Software Engineer to AI Data Scientist – resources\\nAugust 6, 2024\\nOutsmart LLM Arena – a battle of diplomacy and deviousness\\nJune 26, 2024\\nChoosing the Right LLM: Toolkit and Resources\\nNavigation\\nHome\\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": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Try this out, and then try for a few more websites\n",
"\n",
@ -369,7 +560,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"id": "905b9919-aba7-45b5-ae65-81b3d1d78e34",
"metadata": {},
"outputs": [],
@ -387,17 +578,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 23,
"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 platform where he discusses his interests and expertise, primarily in coding and experimenting with large language models (LLMs). As the co-founder and CTO of Nebula.io, he focuses on leveraging AI to help individuals discover their potentials and enhance talent management for recruiters.\\n\\n### Key Sections:\\n\\n- **About Ed**: Edward enjoys coding, DJing, and engaging with the tech community. He has a background in AI startups, including being the founder and CEO of untapt, which was acquired in 2021.\\n- **Outsmart**: This feature introduces an arena where LLMs compete in diplomacy and cunning, showcasing innovative applications of AI.\\n- **Posts**: \\n - **Mastering AI and LLM Engineering – Resources** (November 13, 2024)\\n - **From Software Engineer to AI Data Scientist – Resources** (October 16, 2024)\\n - **Outsmart LLM Arena – A Battle of Diplomacy and Deviousness** (August 6, 2024)\\n - **Choosing the Right LLM: Toolkit and Resources** (June 26, 2024)\\n\\nThe website invites visitors to connect with Edward and stay updated through his posts and resources related to AI and LLMs.\""
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"summarize(\"https://edwarddonner.com\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 24,
"id": "3d926d59-450e-4609-92ba-2d6f244f1342",
"metadata": {},
"outputs": [],
@ -411,10 +613,38 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 25,
"id": "3018853a-445f-41ff-9560-d925d1774b2f",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/markdown": [
"# Summary of Edward Donner's Website\n",
"\n",
"Edward Donner's website is a personal and professional platform showcasing his interests and expertise in working with Large Language Models (LLMs) and AI technologies. As the co-founder and CTO of Nebula.io, he is focused on leveraging AI to enhance talent discovery and engagement. Previously, he founded the AI startup untapt, which was acquired in 2021. \n",
"\n",
"## Key Features:\n",
"\n",
"- **Personal Introduction**: Ed shares his passion for coding, experimentation with LLMs, and interests in DJing and electronic music production.\n",
"- **Professional Background**: Insights into his role at Nebula.io and previous experience with untapt. He highlights his work with proprietary LLMs and innovative matching models.\n",
" \n",
"## Recent Posts:\n",
"- **November 13, 2024**: Mastering AI and LLM Engineering – Resources\n",
"- **October 16, 2024**: From Software Engineer to AI Data Scientist – Resources\n",
"- **August 6, 2024**: Outsmart LLM Arena – A battle of diplomacy and deviousness\n",
"- **June 26, 2024**: Choosing the Right LLM: Toolkit and Resources\n",
"\n",
"These posts suggest a focus on educational resources and insights related to AI and LLM engineering."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"display_summary(\"https://edwarddonner.com\")"
]
@ -437,20 +667,86 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 26,
"id": "45d83403-a24c-44b5-84ac-961449b4008f",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/markdown": [
"# CNN Summary\n",
"\n",
"CNN is a leading news outlet providing the latest updates on various topics, including:\n",
"\n",
"- **Breaking News:** Continuous updates on urgent events around the globe.\n",
"- **Featured Stories:** Insights into significant current affairs, such as the ongoing conflict between Israel and Hamas, and developments in the Ukraine-Russia war.\n",
"- **Politics:** Coverage of key political events, including President Biden's recent clemency grants and implications of Trump's potential inauguration.\n",
"- **World Affairs:** Reports on international crises, including the situation in Syria and reactions to Sudan's bombardments.\n",
"- **Health & Science:** Articles discussing public health issues and scientific discoveries, such as innovations in herbal medicine.\n",
"- **Business & Economy:** Analysis of corporate developments, job cuts in Germany, and impacts of international trade policies.\n",
"- **Entertainment & Culture:** Features on public figures and trends affecting the entertainment industry, as well as the latest in sports.\n",
"\n",
"Recent announcements on the site include:\n",
"- **Clemency for Nearly 1,500 People:** This act marks the largest single-day clemency decision in recent history.\n",
"- **Status of International Relations:** Notable updates on figures like Trump and Xi Jinping, alongside the unfolding situation in Ukraine and the Middle East.\n",
"- **Cultural Insights:** Breakdowns of significant cultural events such as the recognition of Time's \"Person of the Year.\"\n",
"\n",
"CNN emphasizes the importance of viewer feedback to enhance reading and engagement experiences on their platform."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"display_summary(\"https://cnn.com\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 27,
"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 reliable and beneficial AI systems with a strong emphasis on safety. The company boasts an interdisciplinary team with expertise in machine learning, physics, policy, and product development.\n",
"\n",
"## Key Offerings\n",
"\n",
"- **Claude AI Models**: \n",
" - The latest model, **Claude 3.5 Sonnet**, is highlighted as the most intelligent AI model to date.\n",
" - **Claude 3.5 Haiku** has also been introduced, expanding their product offerings.\n",
"\n",
"- **API Access**: \n",
" - Users can leverage Claude to enhance efficiency and create new revenue opportunities.\n",
"\n",
"## Recent Announcements\n",
"\n",
"1. **New Model Updates** (October 22, 2024):\n",
" - Introduction of Claude 3.5 Sonnet and Claude 3.5 Haiku.\n",
" - Announcement of new capabilities for computer use.\n",
"\n",
"2. **Research Initiatives**:\n",
" - **Constitutional AI**: Discusses ensuring harmlessness through AI feedback (December 15, 2022).\n",
" - **Core Views on AI Safety**: Outlines when, why, what, and how AI safety should be addressed (March 8, 2023).\n",
"\n",
"Overall, Anthropic is focused on pioneering advancements in AI through research and development while prioritizing safety and reliability in its applications."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"display_summary(\"https://anthropic.com\")"
]
@ -489,30 +785,58 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 31,
"id": "00743dac-0e70-45b7-879a-d7293a6f68a6",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Objet : Contestation du frais de retour tardif\n",
"\n",
"Bonjour,\n",
"\n",
"Je fais suite à votre email concernant le retour tardif de la voiture. Je conteste fermement cette modification de prix qui, selon moi, est injustifiée.\n",
"\n",
"Selon les termes de notre contrat de location, le délai de grâce pour le retour est souvent de 30 minutes, ce qui est fréquemment appliqué dans le secteur. De plus, vous n'avez pas mentionné dans votre contrat un tarif additionnel pour une telle situation, ce qui pourrait constituer une clause abusive.\n",
"\n",
"Je vous prie donc de bien vouloir annuler cette modification tarifaire. Je me réserve le droit d'explorer des recours supplémentaires si cette situation n'est pas corrigée rapidement.\n",
"\n",
"Dans l'attente de votre retour.\n",
"\n",
"Cordialement, \n",
"Sylvain\n"
]
}
],
"source": [
"# Step 1: Create your prompts\n",
"\n",
"system_prompt = \"something here\"\n",
"system_prompt = \"You are my very smart assistant. Your task will be to suggest to me an answer to my email. I want to avoid paying. you can be agressive and use the law\"\n",
"user_prompt = \"\"\"\n",
" Lots of text\n",
" Can be pasted here\n",
" Retour tardif\n",
"Bonjour sylvain,\n",
"\n",
"Vous avez réservé la voiture jusqu'à 15:00 , et vous l'avez rendue à 15:30 . Le prix de votre location a été modifié en conséquence.\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; use either of the above approaches."
"The line of code you've provided utilizes a generator expression along with the `yield from` syntax in Python. Let's break it down step by step.\n",
"\n",
"### Breakdown of the Code\n",
"\n",
"1. **Context of `yield from`:**\n",
" - `yield from` is a special syntax in Python used within a generator to yield all values from an iterable (like a list, set, or another generator) without explicitly iterating through it. It's useful for delegating part of the generator's operations to another generator.\n",
"\n",
"2. **The Set Comprehension:**\n",
" - `{book.get(\"author\") for book in books if book.get(\"author\")}` is a **set comprehension**. It constructs a set of unique author names from the `books` collection.\n",
" - **How it works:**\n",
" - `for book in books`: This iterates over each `book` in the `books` iterable (which is assumed to be a list or another iterable containing dictionaries).\n",
" - `book.get(\"author\")`: This retrieves the value corresponding to the key `\"author\"` from the `book` dictionary. If the key does not exist in the dictionary, `get()` returns `None`.\n",
" - `if book.get(\"author\")`: This condition checks if the author exists (i.e., is not `None`, empty string, etc.). If the result of `get(\"author\")` is falsy (like `None`), that book is skipped.\n",
" - The result is a set of unique author names because sets automatically remove duplicates.\n",
"\n",
"3. **Combining `yield from` with Set Comprehension:**\n",
" - The entire line of code thus creates a generator that can yield each unique author from the set of authors collected from the `books`, allowing the surrounding context to retrieve authors one by one.\n",
"\n",
"### Purpose of the Code\n",
"\n",
"- **Purpose:** The purpose of this line is to efficiently generate a sequence of unique author names from a list (or iterable) of book dictionaries, while filtering out any entries that do not have an author specified.\n",
"- **Why Use This Approach:** \n",
" - Using a set comprehension ensures that only unique authors are collected, avoiding duplicates.\n",
" - The `yield from` syntax provides a clean way to return these unique authors as part of a generator function, making it easy to iterate over them in another context without needing to manage the iteration and collection explicitly.\n",
"\n",
"### Example Scenario\n",
"\n",
"Let's say you have a list of books structured like this:\n",
"If you execute the line in a generator function, here's what happens:\n",
"\n",
"1. The **Set Comprehension** is evaluated, resulting in the set `{\"Alice\", \"Bob\"}`.\n",
"2. The `yield from` syntax will then yield each of these authors one by one, allowing any caller of the generator to iterate through `Alice` and `Bob`.\n",
"\n",
"### Usage\n",
"\n",
"Here is a complete example of how you might use this line in a generator function:\n",
"\n",
"python\n",
"def unique_authors(books):\n",
" yield from {book.get(\"author\") for book in books if book.get(\"author\")}\n",
"In summary, the line of code you've provided is a concise way to yield unique authors from a collection of books using Python's powerful set comprehension and generator features. It provides both efficiency in terms of time and space complexity (due to unique filtering) and succinctness in code structure."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Get gpt-4o-mini to answer, with streaming\n",
"\n",
@ -118,10 +204,64 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "8f7c8ea8-4082-4ad0-8751-3301adcf6538",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/markdown": [
"**Breaking Down the Code**\n",
"\n",
"The given code snippet is written in Python and utilizes a combination of features such as generators, dictionary iteration, and conditional logic. Let's break it down step by step:\n",
"\n",
"```python\n",
"yield from {book.get(\"author\") for book in books if book.get(\"author\")}\n",
"```\n",
"\n",
"Here's what's happening:\n",
"\n",
"1. `for book in books`: This is a standard `for` loop that iterates over the elements of the `books` collection (likely a list, dictionary, or some other iterable).\n",
"\n",
"2. `if book.get(\"author\")`: Inside the loop, there's an additional condition that filters out any items from the `books` collection where the `\"author\"` key does not exist or its value is empty/missing (`None`, `''`, etc.). This ensures only books with a valid author name are processed.\n",
"\n",
"3. `{book.get(\"author\") for book in books if book.get(\"author\")}`: This is an expression that iterates over the filtered list of books, extracting and yielding their authors. The `get()` method is used to safely retrieve the value associated with the `\"author\"` key from each book dictionary.\n",
"\n",
"4. `yield from {...}`: The outer expression is a generator expression, which yields values one at a time instead of computing them all at once and returning them in a list (as would be done with a regular list comprehension). The `yield from` syntax allows us to delegate the execution of this inner generator to another iterable (`{book.get(\"author\") for book in books if book.get(\"author\")}`).\n",
"\n",
"**Why it's useful**\n",
"\n",
"This code snippet is useful when you need to:\n",
"\n",
"* Filter out invalid or incomplete data points while still working with iterables.\n",
"* Work with large datasets without loading the entire dataset into memory at once.\n",
"* Simplify your code by leveraging generator expressions and avoiding unnecessary computations.\n",
"\n",
"In practice, this could be used in a variety of scenarios where you're dealing with lists of dictionaries (e.g., books) and need to extract specific information from them (e.g., authors).\n",
"\n",
"**Example usage**\n",
"\n",
"Here's an example using a list of book dictionaries:\n",
"In this example, the `yield from` expression filters out books with missing or empty authors and extracts their values as a generator. The outer loop can then iterate over these generated values without having to store them all in memory at once."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Get Llama 3.2 to answer\n",
"\n",
@ -142,14 +282,6 @@
"\n",
"And then creating the prompts and making the calls interactively."
"Sure! Let's break down the code you've provided:\n",
"\n",
"```python\n",
"yield from {book.get(\"author\") for book in books if book.get(\"author\")}\n",
"```\n",
"\n",
"### Explanation of the Code\n",
"\n",
"1. **Set Comprehension:**\n",
" - The code `{book.get(\"author\") for book in books if book.get(\"author\")}` is a **set comprehension**. This is a concise way to create a set in Python.\n",
" - It iterates over a collection named `books`.\n",
"\n",
"2. **Accessing the \"author\" Key:**\n",
" - `book.get(\"author\")`: For each `book` in the `books` collection, it attempts to get the value associated with the key `\"author\"`. \n",
" - The `get()` method is used to safely access dictionary keys. If the key does not exist, it returns `None` instead of throwing an error.\n",
"\n",
"3. **Filtering Authors:**\n",
" - The clause `if book.get(\"author\")` acts as a filter. It ensures that only books with a valid (non-`None`) author get included in the resulting set.\n",
" - Therefore, this part: `{book.get(\"author\") for book in books if book.get(\"author\")}` creates a set of unique authors from the `books` collection that have valid author values.\n",
"\n",
"4. **Yielding Results:**\n",
" - The `yield from` statement is used to yield values from the set comprehension created previously. \n",
" - This means that the containing function will return each unique author one at a time as they are requested (similar to a generator).\n",
"\n",
"### Summary\n",
"\n",
"- **What the Code Does:**\n",
" - It generates a set of unique authors from a list of books, filtering out any entries that do not have an author. It then yields each of these authors.\n",
"\n",
"- **Why It's Useful:**\n",
" - This code is particularly useful when dealing with collections of books where some might not have an author specified. It safely retrieves the authors and ensures that each author is only returned once. \n",
" - Using `yield from` makes it memory efficient, as it does not create an intermediate list of authors but generates them one at a time on demand.\n",
"This code snippet is written in Python and utilizes the `yield from` statement, which was introduced in Python 3.3.\n",
"\n",
"### What does it do?\n",
"\n",
"The code takes two main inputs:\n",
"\n",
"* A list of dictionaries (`books`) where each dictionary represents a book.\n",
"* Another dictionary (`book`) that contains information about an author.\n",
"\n",
"It generates a sequence of authors from the `books` list and yields them one by one, while also applying the condition that the book has a valid \"author\" key in its dictionary.\n",
"\n",
"Here's a step-by-step breakdown:\n",
"\n",
"1. `{book.get(\"author\") for book in books if book.get(\"author\")}`:\n",
" * This is an expression that generates a sequence of authors.\n",
" * `for book in books` iterates over each book in the `books` list.\n",
" * `if book.get(\"author\")` filters out books without an \"author\" key, to prevent errors and ensure only valid data is processed.\n",
"\n",
"2. `yield from ...`:\n",
" * This statement is used to delegate a sub-generator or iterator.\n",
" * In this case, it's delegating the sequence of authors generated in step 1.\n",
"\n",
"**Why does it yield authors?**\n",
"\n",
"The use of `yield from` serves two main purposes:\n",
"\n",
"* **Efficiency**: Instead of creating a new list with all the authors, this code yields each author one by one. This approach is more memory-efficient and can be particularly beneficial when dealing with large datasets.\n",
"* **Flexibility**: By using `yield from`, you can create generators that produce values on-the-fly, allowing for lazy evaluation.\n",
"\n",
"### Example Usage\n",
"\n",
"Here's an example of how you might use this code:\n",
"In this example, `get_authors` is a generator function that yields unique authors from the `books` list. The generated values are collected in a set (`authors`) to eliminate duplicates."