Browse Source

Day 2 Exercise

pull/237/head
craigprobus 2 months ago
parent
commit
05e8c4bcd2
  1. 69
      week1/day2 EXERCISE.ipynb

69
week1/day2 EXERCISE.ipynb

@ -889,72 +889,77 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 29,
"id": "e4993304-1a6b-43b5-919a-96b56cae7ad7",
"metadata": {},
"outputs": [],
"source": [
"def summarize(url):\n",
" website = Website(url)\n",
" #response = openai.chat.completions.create(\n",
" # model = \"gpt-4o-mini\",\n",
" # messages = messages_for(website)\n",
" #)\n",
" #return response.choices[0].message.content\n",
" messages = messages_for(website)\n",
" return ollama.chat(model=MODEL, messages=messages)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 31,
"id": "4d91f204-d6e4-4601-95a3-71eae021212a",
"metadata": {},
"outputs": [],
"source": [
"def display_summary(url):\n",
" summary = summarize(url)\n",
" print(f\"SUMMARY <${summary}>\")\n",
" #display(Markdown(summary))"
" display(Markdown(summary.message.content))"
]
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 32,
"id": "362ba391-8103-43b3-9a16-a171aebe028a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SUMMARY <$model='llama3.2' created_at='2025-03-04T00:12:00.263857Z' done=True done_reason='stop' total_duration=2697124208 load_duration=40565500 prompt_eval_count=311 prompt_eval_duration=165000000 eval_count=202 eval_duration=2488000000 message=Message(role='assistant', content='### Website Summary\\n\\n#### Overview\\nSpotlight Monitor is a company that provides solutions for improving Salesforce security. Their website offers various tools and services to help businesses reduce risk and identify bad actors in their Salesforce ecosystem.\\n\\n#### Key Features\\n\\n* **SpotMon**: A solution to assess your Salesforce risk, ensure compliance, and mitigate risk.\\n* **Salesforce Security Assessment**: A way to monitor user behavior to identify suspicious activity.\\n* **Shield Quickstarts**: Pre-built solutions to speed up Salesforce Shield implementation.\\n\\n#### News/Announcements\\nThe website mentions that:\\n* 65% of data breaches involve internal actors.\\n* Salesforce stores sensitive mission-critical data, making it a prime target for security threats.\\n* Most Salesforce customers have a limited understanding of what their users actually do, leaving them vulnerable to security risks.\\n* The company offers a recent webinar clip available on their website.\\n\\n#### Contact Information\\nSpotlight Monitor provides contact information, including a link to talk with an expert about improving your Salesforce security posture.', images=None, tool_calls=None)>\n"
]
}
],
"source": [
"display_summary(\"https://spotlightmonitor.com\")"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "df9335a1-b17f-4738-8c55-cd7fcf14641a",
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"**Summary of The Onion Website**\n",
"=====================================\n",
"\n",
"### News and Announcements\n",
"\n",
"* **Pete Hegseth Deploys 3,000 U.S. Troops On Beer Run**: Defense Secretary Pete Hegseth deploys 3,000 troops to a beer run after declaring the lack of alcohol in the Pentagon kitchen a \"national emergency.\"\n",
"* **The Onion Is Back In Print**: The Onion returns to print with new publications and subscriptions.\n",
"* **Trump Signs Executive Order Making Official Language Of U.S. Remedial English**: Trump signs an executive order making remedial English the official language of the US.\n",
"\n",
"### Trending News\n",
"\n",
"* **Lockheed Martin Develops Giant Tactical Rubber Spider**: Lockheed Martin develops a giant tactical rubber spider to counter global threats.\n",
"* **Scientists Confirm Shingleback Lizards Only Reptiles That Mate For Sake Of Aging Mothers**: Scientists confirm that shingleback lizards only mate for the sake of their aging mothers.\n",
"\n",
"### Local and Entertainment News\n",
"\n",
"* **Passengers Rush To Arriving Train’s Doors Like Rat Babies Nursing At Mother’s Teats**: Passengers rush to arriving train doors like rats nursing at a mother's teats.\n",
"* **Kylie Jenner Admits She’d Like To Go On One Date That Isn’t Awards Ceremony**: Kylie Jenner admits she'd like to go on one date that isn't an awards ceremony.\n",
"\n",
"### Sports News\n",
"\n",
"* **Washington Wizards Reminded That Bottled Water In Hotel Room Isn’t Free**: The Washington Wizards are reminded that bottled water in hotel rooms is not free.\n",
"* **Numerous Teams Express Interest In Aaron Rodgers Playing Elsewhere**: Numerous teams express interest in Aaron Rodgers playing elsewhere.\n",
"\n",
"### Opinion and Lifestyle News\n",
"\n",
"* **Woman Contaminates Grocery Store Food With Urine For Years**: A woman contaminates grocery store food with urine for years, according to a new report.\n",
"* **Your Horoscope — Today’s Birthday**: Pisces (February 19 to March 20): Sometimes help comes from unexpected sources, but don't overthink this one—just call 911."
],
"text/plain": [
"ChatResponse(model='llama3.2', created_at='2025-03-04T00:10:25.224805Z', done=True, done_reason='stop', total_duration=1946978625, load_duration=36116708, prompt_eval_count=311, prompt_eval_duration=166000000, eval_count=142, eval_duration=1741000000, message=Message(role='assistant', content='### Website Summary\\n\\n**Overview**\\nSpotlight Monitor is a cybersecurity firm specializing in Salesforce security solutions. The website provides various services to help businesses reduce risk and identify bad actors within their Salesforce ecosystems.\\n\\n**Key Features**\\n\\n* **SpotMon**: A solution to assess Salesforce risk and ensure compliance.\\n* **Shield Quickstarts**: Accelerate Salesforce Shield implementation for faster security.\\n* **Salesforce Security Assessment**: Monitor user behavior to detect suspicious activity.\\n\\n### News/Announcements\\n\\n* **Data Breach Statistics**: 65% of data breaches involve internal actors, highlighting the importance of effective security measures.\\n* **Webinar Clips**: The website mentions recent webinar clips available for more insights into Salesforce security best practices.', images=None, tool_calls=None))"
"<IPython.core.display.Markdown object>"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
"output_type": "display_data"
}
],
"source": [
"summarize(\"https://spotlightmonitor.com\")"
"display_summary(\"https://www.pbs.org/newshour\")"
]
},
{

Loading…
Cancel
Save