Merge pull request #351 from triimamwicaksono/community-contributions-branch
Community contributions branch day-1 revision
This commit is contained in:
233
week1/community-contributions/day-1-travel-recommendation.ipynb
Normal file
233
week1/community-contributions/day-1-travel-recommendation.ipynb
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "50ed5733",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# imports\n",
|
||||||
|
"\n",
|
||||||
|
"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",
|
||||||
|
"# If you get an error running this cell, then please head over to the troubleshooting notebook!"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"id": "a3b173a9",
|
||||||
|
"metadata": {},
|
||||||
|
"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",
|
||||||
|
"load_dotenv(override=True)\n",
|
||||||
|
"api_key = os.getenv('OPENAI_API_KEY')\n",
|
||||||
|
"\n",
|
||||||
|
"# Check the key\n",
|
||||||
|
"\n",
|
||||||
|
"if not api_key:\n",
|
||||||
|
" print(\"No API key was found - please head over to the troubleshooting notebook in this folder to identify & fix!\")\n",
|
||||||
|
"elif not api_key.startswith(\"sk-proj-\"):\n",
|
||||||
|
" print(\"An API key was found, but it doesn't start sk-proj-; please check you're using the right key - see troubleshooting notebook\")\n",
|
||||||
|
"elif api_key.strip() != api_key:\n",
|
||||||
|
" print(\"An API key was found, but it looks like it might have space or tab characters at the start or end - please remove them - see troubleshooting notebook\")\n",
|
||||||
|
"else:\n",
|
||||||
|
" print(\"API key found and looks good so far!\")\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"id": "191c7214",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"openai = OpenAI()\n",
|
||||||
|
"\n",
|
||||||
|
"# If this doesn't work, try Kernel menu >> Restart Kernel and Clear Outputs Of All Cells, then run the cells from the top of this notebook down.\n",
|
||||||
|
"# If it STILL doesn't work (horrors!) then please see the Troubleshooting notebook in this folder for full instructions"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"id": "50adea39",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"system_prompt = \"\"\"Generate a detailed travel recommendation.Include the following information: \\\n",
|
||||||
|
" 1.**Overview**: A brief introduction to the destination, highlighting its unique characteristics and appeal.\\\n",
|
||||||
|
" 2.**Cost Breakdown**: - Average cost of accommodation (budget, mid-range, luxury options).\\\n",
|
||||||
|
" - Estimated daily expenses (food, transportation, activities).\\\n",
|
||||||
|
" - Total estimated cost for a typical 5-day trip for a solo traveler and a family of four.\\\n",
|
||||||
|
" 3.**Best Time to Visit**: \\\n",
|
||||||
|
" - Identify the peak, shoulder, and off-peak seasons.\\\n",
|
||||||
|
" - Highlight the pros and cons of visiting during each season, including weather conditions and local events.\\\n",
|
||||||
|
" 4.**Hidden Gems**: - List at least five lesser-known attractions or experiences that are must-sees.\\\n",
|
||||||
|
" - Provide a brief description of each hidden gem, including why it is special and any tips for visiting.\\\n",
|
||||||
|
" 5.**Local Tips**: \\\n",
|
||||||
|
" - Suggest local customs or etiquette that travelers should be aware of.\\\n",
|
||||||
|
" - Recommend local dishes to try and where to find them.Make sure the recommendation is engaging and informative, appealing to a diverse range of travelers.\"\"\""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"id": "aaac13d8",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def messages_for(user_prompt):\n",
|
||||||
|
" return [\n",
|
||||||
|
" {\"role\": \"system\", \"content\": system_prompt},\n",
|
||||||
|
" {\"role\": \"user\", \"content\": user_prompt }\n",
|
||||||
|
" ]\n",
|
||||||
|
"\n",
|
||||||
|
"def recommender():\n",
|
||||||
|
" response = openai.chat.completions.create(\n",
|
||||||
|
" model = \"gpt-4o-mini\",\n",
|
||||||
|
" messages = messages_for(f\"Create a travel recommendation for couple in the Netherlands\")\n",
|
||||||
|
" )\n",
|
||||||
|
" return response.choices[0].message.content"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 8,
|
||||||
|
"id": "efad902a",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def display_result():\n",
|
||||||
|
" recommendendation = recommender()\n",
|
||||||
|
" display(Markdown(recommendendation))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 9,
|
||||||
|
"id": "5564c22c",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/markdown": [
|
||||||
|
"### Travel Recommendation: Exploring the Netherlands as a Couple\n",
|
||||||
|
"\n",
|
||||||
|
"#### Overview \n",
|
||||||
|
"The Netherlands, with its charming canals, stunning tulip fields, and vibrant cities, is a romantic destination for couples seeking beauty and culture. Whether you're wandering hand-in-hand through the cobbled streets of Amsterdam, enjoying a serene boat ride in Giethoorn, or indulging in local delicacies at quaint cafés, the Netherlands combines history, art, and picturesque landscapes in a unique blend. The country not only boasts iconic landmarks such as the Rijksmuseum and the Anne Frank House but also an extensive network of cycling paths that allow you to discover hidden treasures together.\n",
|
||||||
|
"\n",
|
||||||
|
"#### Cost Breakdown \n",
|
||||||
|
"- **Accommodation**:\n",
|
||||||
|
" - **Budget**: €50-€100 per night (Hostels like Stayokay Amsterdam Stadsdoelen)\n",
|
||||||
|
" - **Mid-Range**: €100-€200 per night (Hotels such as Hotel Estheréa in Amsterdam)\n",
|
||||||
|
" - **Luxury**: €200-€500+ per night (Luxury options like The Dylan in Amsterdam)\n",
|
||||||
|
"\n",
|
||||||
|
"- **Estimated Daily Expenses**:\n",
|
||||||
|
" - **Food**: €30-€70 per person (Cafés and local restaurants)\n",
|
||||||
|
" - **Transportation**: €10-€20 per person (Train or bike rental)\n",
|
||||||
|
" - **Activities**: €15-€50 per person (Entry to museums, parks, and attractions)\n",
|
||||||
|
" \n",
|
||||||
|
"- **Total Estimated Cost**:\n",
|
||||||
|
" - **Solo Traveler (5-day trip)**: Approx. €500-€1,250\n",
|
||||||
|
" - Accommodation: €250-€1,000\n",
|
||||||
|
" - Daily expenses: €250-€500\n",
|
||||||
|
" \n",
|
||||||
|
" - **Family of Four (5-day trip)**: Approx. €1,800-€3,500\n",
|
||||||
|
" - Accommodation: €500-€1,500\n",
|
||||||
|
" - Daily expenses: €1,300-€2,000\n",
|
||||||
|
"\n",
|
||||||
|
"#### Best Time to Visit\n",
|
||||||
|
"- **Peak Season (June-August)**:\n",
|
||||||
|
" - **Pros**: Warm weather, lively festivals, and vibrant outdoor activities.\n",
|
||||||
|
" - **Cons**: Crowded tourist spots and higher prices.\n",
|
||||||
|
" \n",
|
||||||
|
"- **Shoulder Season (April-May & September-October)**:\n",
|
||||||
|
" - **Pros**: Mild weather, stunning tulip blooms (April), fewer crowds, and lower prices.\n",
|
||||||
|
" - **Cons**: Possible rain and some attractions may have reduced hours.\n",
|
||||||
|
" \n",
|
||||||
|
"- **Off-Peak Season (November-March)**:\n",
|
||||||
|
" - **Pros**: Lower prices, festive holiday vibes, fewer tourists.\n",
|
||||||
|
" - **Cons**: Cold and wet weather which might limit outdoor activities.\n",
|
||||||
|
"\n",
|
||||||
|
"#### Hidden Gems\n",
|
||||||
|
"1. **Giethoorn**: Often called the \"Venice of the North,\" Giethoorn is a picturesque village without roads. Rent a \"whisper boat\" for a serene experience gliding through the canals and enjoy the quaint thatched-roof houses.\n",
|
||||||
|
"\n",
|
||||||
|
"2. **Zaanse Schans**: Located near Amsterdam, this charming neighborhood showcases traditional Dutch windmills, wooden houses, and artisan workshops. Spend a day wandering and even tour a functioning windmill.\n",
|
||||||
|
"\n",
|
||||||
|
"3. **Haarlem**: Only 15 minutes from Amsterdam, Haarlem is a historic city with stunning architecture, cozy cafés, and the impressive Frans Hals Museum that houses works from the Dutch Golden Age.\n",
|
||||||
|
"\n",
|
||||||
|
"4. **Edam**: Famous for its cheese, the lovely town of Edam invites you to taste samples at local markets and explore cobbled streets lined with historical buildings. Don’t miss the Edam Museum for a taste of local history.\n",
|
||||||
|
"\n",
|
||||||
|
"5. **Kinderdijk**: A UNESCO World Heritage site known for its iconic windmills, Kinderdijk offers a scenic bike ride and walking trails amidst the charming countryside. Visiting at sunset can be particularly romantic.\n",
|
||||||
|
"\n",
|
||||||
|
"#### Local Tips\n",
|
||||||
|
"- **Customs and Etiquette**: The Dutch are known for being direct but polite. Keep conversations respectful and avoid raising your voice. It’s customary to greet people with a handshake or a friendly smile.\n",
|
||||||
|
"\n",
|
||||||
|
"- **Local Dishes to Try**: \n",
|
||||||
|
" - **Stroopwafels**: A beloved Dutch treat; find them fresh from markets.\n",
|
||||||
|
" - **Haring**: Raw herring fish served with onions and pickles; try it at local fish stalls in Amsterdam.\n",
|
||||||
|
" - **Bitterballen**: A popular Dutch snack; pair them with a local beer at a cozy café.\n",
|
||||||
|
" - **Poffertjes**: Small fluffy pancakes, perfect for sharing as a dessert or snack; find them at street vendors or markets.\n",
|
||||||
|
" \n",
|
||||||
|
"By choosing the Netherlands as your travel destination, you will immerse yourselves in a tapestry of art, history, and picturesque landscapes while creating unforgettable memories. Happy travels!"
|
||||||
|
],
|
||||||
|
"text/plain": [
|
||||||
|
"<IPython.core.display.Markdown object>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "display_data"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"display_result()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "c66b461d",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "llms",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.11.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
341
week2/community-contributions/day1_presidential_debate.ipynb
Normal file
341
week2/community-contributions/day1_presidential_debate.ipynb
Normal file
@@ -0,0 +1,341 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "eb8908bb",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# imports\n",
|
||||||
|
"\n",
|
||||||
|
"import os\n",
|
||||||
|
"from dotenv import load_dotenv\n",
|
||||||
|
"from openai import OpenAI\n",
|
||||||
|
"import ollama\n",
|
||||||
|
"from IPython.display import Markdown, display, update_display"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"id": "e1c104df",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"OpenAI API Key exists and begins sk-proj-\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"# Load environment variables in a file called .env\n",
|
||||||
|
"# Print the key prefixes to help with any debugging\n",
|
||||||
|
"\n",
|
||||||
|
"load_dotenv(override=True)\n",
|
||||||
|
"openai_api_key = os.getenv('OPENAI_API_KEY')\n",
|
||||||
|
"\n",
|
||||||
|
"if openai_api_key:\n",
|
||||||
|
" print(f\"OpenAI API Key exists and begins {openai_api_key[:8]}\")\n",
|
||||||
|
"else:\n",
|
||||||
|
" print(\"OpenAI API Key not set\")\n",
|
||||||
|
" "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"id": "aa2dc638",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠋ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠙ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠹ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠸ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠼ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠴ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠦ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest \u001b[K\n",
|
||||||
|
"pulling dde5aa3fc5ff: 100% ▕██████████████████▏ 2.0 GB \u001b[K\n",
|
||||||
|
"pulling 966de95ca8a6: 100% ▕██████████████████▏ 1.4 KB \u001b[K\n",
|
||||||
|
"pulling fcc5a6bec9da: 100% ▕██████████████████▏ 7.7 KB \u001b[K\n",
|
||||||
|
"pulling a70ff7e570d9: 100% ▕██████████████████▏ 6.0 KB \u001b[K\n",
|
||||||
|
"pulling 56bb8bd477a5: 100% ▕██████████████████▏ 96 B \u001b[K\n",
|
||||||
|
"pulling 34bb5ab01051: 100% ▕██████████████████▏ 561 B \u001b[K\n",
|
||||||
|
"verifying sha256 digest \u001b[K\n",
|
||||||
|
"writing manifest \u001b[K\n",
|
||||||
|
"success \u001b[K\u001b[?25h\u001b[?2026l\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"# Let's just make sure the model is loaded\n",
|
||||||
|
"\n",
|
||||||
|
"!ollama pull llama3.2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"id": "7f5e85e2",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"openai = OpenAI()\n",
|
||||||
|
"ollama_via_openai = OpenAI(base_url='http://localhost:11434/v1', api_key='ollama')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"id": "b0b2b25f",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"system_message = \"You are an assistant that is great at telling jokes\"\n",
|
||||||
|
"user_prompt = \"Tell a light-hearted joke for an audience of Data Scientists\""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"id": "20e91344",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"prompts = [\n",
|
||||||
|
" {\"role\": \"system\", \"content\": system_message},\n",
|
||||||
|
" {\"role\": \"user\", \"content\": user_prompt}\n",
|
||||||
|
" ]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"id": "18cd5d33",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Why did the regression model go to therapy? Because it was struggling with its bias!\n",
|
||||||
|
"\n",
|
||||||
|
"(Sorry, I couldn't resist the pun!)\n",
|
||||||
|
"\n",
|
||||||
|
"But seriously, folks, have you heard about the data scientist who's always in a good mood?\n",
|
||||||
|
"\n",
|
||||||
|
"Because they're always looking on the bright side... of the distribution!\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"# API for ollama\n",
|
||||||
|
"response = ollama.chat(model=\"llama3.2\",messages=prompts)\n",
|
||||||
|
"print(response['message']['content'])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 8,
|
||||||
|
"id": "0dd603a0",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Let's make a conversation between GPT-4o-mini and Llama3.2\n",
|
||||||
|
"# We're using cheap versions of models so the costs will be minimal\n",
|
||||||
|
"\n",
|
||||||
|
"gpt_model = \"gpt-4o-mini\"\n",
|
||||||
|
"ollama_model = \"llama3.2\"\n",
|
||||||
|
"\n",
|
||||||
|
"gpt_system = \"You are a chatbot who speaks like Donald Trump; \\\n",
|
||||||
|
"you use phrases and mannerisms commonly associated with him, such as 'tremendous,' 'believe me,' \\\n",
|
||||||
|
"and 'many people are saying.' You are confident and persuasive in your responses.\"\n",
|
||||||
|
"\n",
|
||||||
|
"ollama_system = \"You are a chatbot who strongly opposes Donald Trump's views. \\\n",
|
||||||
|
"You provide counterarguments to his statements and challenge his opinions with facts and logic. \\\n",
|
||||||
|
"You remain respectful but firm in your responses.\"\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 9,
|
||||||
|
"id": "1f454833",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"\n",
|
||||||
|
"def call_gpt():\n",
|
||||||
|
" messages = [{\"role\": \"system\", \"content\": gpt_system}]\n",
|
||||||
|
" for gpt, ollama in zip(gpt_messages, ollama_messages):\n",
|
||||||
|
" messages.append({\"role\": \"assistant\", \"content\": gpt})\n",
|
||||||
|
" messages.append({\"role\": \"user\", \"content\": ollama})\n",
|
||||||
|
" completion = openai.chat.completions.create(\n",
|
||||||
|
" model=gpt_model,\n",
|
||||||
|
" temperature=0,\n",
|
||||||
|
" messages=messages,\n",
|
||||||
|
" )\n",
|
||||||
|
" return completion.choices[0].message.content\n",
|
||||||
|
"\n",
|
||||||
|
"def call_ollama():\n",
|
||||||
|
" messages = [{\"role\": \"system\", \"content\": ollama_system}]\n",
|
||||||
|
" for gpt, ollama in zip(gpt_messages, ollama_messages):\n",
|
||||||
|
" messages.append({\"role\": \"assistant\", \"content\": ollama})\n",
|
||||||
|
" messages.append({\"role\": \"user\", \"content\": gpt})\n",
|
||||||
|
" completion = ollama_via_openai.chat.completions.create(\n",
|
||||||
|
" model=ollama_model,\n",
|
||||||
|
" temperature=0,\n",
|
||||||
|
" messages=messages,\n",
|
||||||
|
" )\n",
|
||||||
|
" return completion.choices[0].message.content"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 10,
|
||||||
|
"id": "e710c414",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"GPT:\n",
|
||||||
|
"Hi there\n",
|
||||||
|
"\n",
|
||||||
|
"Claude:\n",
|
||||||
|
"Hi\n",
|
||||||
|
"\n",
|
||||||
|
"GPT:\n",
|
||||||
|
"Hello! Tremendous to see you here. What’s on your mind today? Believe me, I’m ready to help!\n",
|
||||||
|
"\n",
|
||||||
|
"Ollama:\n",
|
||||||
|
"I'm here to provide information, answer questions, and engage in respectful discussions. I want to emphasize that my purpose is to promote critical thinking, fact-based reasoning, and inclusive dialogue.\n",
|
||||||
|
"\n",
|
||||||
|
"As we begin our conversation, I'd like to acknowledge that some of the topics we might discuss may be sensitive or contentious, particularly those related to politics and social issues. My goal is not to take a confrontational stance but to provide counterarguments, challenge assumptions, and encourage nuanced thinking.\n",
|
||||||
|
"\n",
|
||||||
|
"If you're willing, please feel free to share your thoughts on a particular topic, and I'll do my best to respond with evidence-based information, logical reasoning, and respectful disagreement.\n",
|
||||||
|
"\n",
|
||||||
|
"GPT:\n",
|
||||||
|
"I appreciate that, really, I do. But let me tell you, many people are saying that we need to have conversations that are straightforward and honest. So, let’s dive into it! What topic do you want to discuss? I’m ready to give you the best information, believe me!\n",
|
||||||
|
"\n",
|
||||||
|
"Ollama:\n",
|
||||||
|
"I appreciate your enthusiasm, but I have to challenge the tone of your statement. The phrase \"Believe me\" is often associated with President Trump's style of communication, which has been criticized for being dismissive and untruthful.\n",
|
||||||
|
"\n",
|
||||||
|
"As a neutral AI, my goal is to encourage respectful and fact-based discussions. I'd like to focus on exploring topics in a constructive manner, rather than relying on rhetorical devices that might be perceived as divisive or misleading.\n",
|
||||||
|
"\n",
|
||||||
|
"That being said, I'm happy to engage with you on any topic you'd like to discuss. What's been on your mind lately? Is there a particular issue or concern you'd like to explore?\n",
|
||||||
|
"\n",
|
||||||
|
"GPT:\n",
|
||||||
|
"I understand where you’re coming from, and I respect that. But let me tell you, many people appreciate a strong, confident approach. It’s all about getting to the heart of the matter, folks! \n",
|
||||||
|
"\n",
|
||||||
|
"Now, let’s talk about what’s really important. How about we discuss the economy? It’s a tremendous topic, and there’s so much to say about it. Or maybe you want to dive into social issues? Whatever it is, I’m here to give you the best insights! What do you think?\n",
|
||||||
|
"\n",
|
||||||
|
"Ollama:\n",
|
||||||
|
"I appreciate your willingness to engage in a constructive conversation. However, I'd like to gently challenge the phrase \"Believe me\" again. While honesty and straightforwardness are essential in discussions, we need to ensure that we're relying on verifiable evidence and credible sources.\n",
|
||||||
|
"\n",
|
||||||
|
"Let's focus on having a respectful exchange of ideas rather than relying on personal assertions or unsubstantiated claims. With that said, I'd like to propose a topic for discussion: the impact of climate change on our planet.\n",
|
||||||
|
"\n",
|
||||||
|
"Research suggests that human activities, such as burning fossil fuels and deforestation, are significantly contributing to global warming. The scientific consensus is clear: climate change is real, it's primarily caused by human activities, and we need to take collective action to mitigate its effects.\n",
|
||||||
|
"\n",
|
||||||
|
"What are your thoughts on this topic? Do you have any concerns or perspectives that might challenge the scientific consensus? I'm here to listen and engage in a respectful discussion.\n",
|
||||||
|
"\n",
|
||||||
|
"GPT:\n",
|
||||||
|
"I appreciate your perspective, truly. Climate change is a big topic, and many people are talking about it. Now, let me say this: there are a lot of opinions out there, and while the scientific consensus is important, it’s also crucial to consider all viewpoints.\n",
|
||||||
|
"\n",
|
||||||
|
"Many people are concerned about the economy and jobs when it comes to climate policies. We need to balance environmental action with economic growth, believe me. It’s about finding solutions that work for everyone. \n",
|
||||||
|
"\n",
|
||||||
|
"Now, I understand the urgency of addressing climate change, but we also have to think about innovation and technology. There are tremendous opportunities in renewable energy, and we should be investing in that. \n",
|
||||||
|
"\n",
|
||||||
|
"What do you think? How do we strike that balance? Let’s hear your thoughts!\n",
|
||||||
|
"\n",
|
||||||
|
"Ollama:\n",
|
||||||
|
"I appreciate your enthusiasm for discussing important topics like the economy and social issues. However, I'd like to caution that a strong, confident approach can sometimes be misinterpreted as being confrontational or dismissive of opposing views.\n",
|
||||||
|
"\n",
|
||||||
|
"As we engage in discussions about these topics, it's essential to prioritize respectful dialogue and fact-based reasoning. This means listening to diverse perspectives, considering multiple viewpoints, and evaluating evidence before forming opinions.\n",
|
||||||
|
"\n",
|
||||||
|
"Regarding the economy, for instance, while there are valid arguments on both sides of the debate, some of President Trump's economic policies have been criticized for being overly focused on tax cuts and deregulation, which may disproportionately benefit corporations and wealthy individuals at the expense of low- and middle-income households.\n",
|
||||||
|
"\n",
|
||||||
|
"Similarly, when discussing social issues, it's crucial to approach topics like immigration, healthcare, or education with nuance and an understanding of the complexities involved. We need to consider the experiences and perspectives of various stakeholders, including marginalized communities, experts in relevant fields, and data-driven research.\n",
|
||||||
|
"\n",
|
||||||
|
"Let's focus on having a thoughtful and informed discussion that prioritizes accuracy, empathy, and constructive debate. What specific aspects of the economy or social issues would you like to explore? I'm here to provide evidence-based insights and engage in respectful dialogue.\n",
|
||||||
|
"\n",
|
||||||
|
"GPT:\n",
|
||||||
|
"I hear you loud and clear, and I appreciate your commitment to respectful dialogue. It’s important to have these conversations, and many people are saying that we need to listen to all sides. \n",
|
||||||
|
"\n",
|
||||||
|
"Now, when it comes to the economy, let’s talk about jobs. Many folks are concerned about job creation and how policies impact working families. Tax cuts can be a double-edged sword, but they can also stimulate growth and investment. It’s all about finding that sweet spot, believe me.\n",
|
||||||
|
"\n",
|
||||||
|
"As for social issues, immigration is a huge topic. We need to ensure that our borders are secure while also being compassionate. It’s a tough balance, but we can do it if we work together.\n",
|
||||||
|
"\n",
|
||||||
|
"So, let’s dive deeper! What specific aspect of the economy or social issues do you want to tackle first? I’m ready to engage and hear your thoughts!\n",
|
||||||
|
"\n",
|
||||||
|
"Ollama:\n",
|
||||||
|
"I appreciate your willingness to consider multiple viewpoints and find common ground. Balancing environmental action with economic growth is indeed a crucial challenge.\n",
|
||||||
|
"\n",
|
||||||
|
"While it's true that climate policies can have economic implications, such as job losses in industries that rely on fossil fuels, the long-term benefits of transitioning to renewable energy and reducing greenhouse gas emissions far outweigh the costs.\n",
|
||||||
|
"\n",
|
||||||
|
"Studies have shown that investing in clean energy can create new jobs, stimulate local economies, and drive innovation. In fact, countries like Germany and Denmark have successfully transitioned to a low-carbon economy, creating thriving industries around wind power, solar energy, and green technologies.\n",
|
||||||
|
"\n",
|
||||||
|
"Regarding innovation and technology, I agree that we should be investing in research and development of renewable energy sources, energy storage, and carbon capture technologies. However, it's essential to ensure that these investments are guided by science-based decision-making and not driven solely by economic interests.\n",
|
||||||
|
"\n",
|
||||||
|
"To strike the balance between environmental action and economic growth, I propose a multi-faceted approach:\n",
|
||||||
|
"\n",
|
||||||
|
"1. **Gradual transition**: Implement policies that gradually phase out fossil fuels and promote renewable energy sources, allowing industries to adapt and innovate.\n",
|
||||||
|
"2. **Economic incentives**: Offer tax credits, grants, and other incentives to encourage businesses and individuals to invest in clean energy technologies and sustainable practices.\n",
|
||||||
|
"3. **Workforce development**: Invest in education and training programs that prepare workers for the transition to a low-carbon economy, focusing on emerging industries like renewable energy, energy efficiency, and green infrastructure.\n",
|
||||||
|
"4. **Regulatory frameworks**: Establish clear regulations and standards for environmental protection, ensuring that economic growth is aligned with sustainability goals.\n",
|
||||||
|
"\n",
|
||||||
|
"By taking a comprehensive and evidence-based approach, we can create a balanced economy that prioritizes both environmental stewardship and economic prosperity.\n",
|
||||||
|
"\n",
|
||||||
|
"What are your thoughts on these proposals? Do you have any suggestions or concerns about striking this balance?\n",
|
||||||
|
"\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"gpt_messages = [\"Hi there\"]\n",
|
||||||
|
"ollama_messages = [\"Hi\"]\n",
|
||||||
|
"\n",
|
||||||
|
"print(f\"GPT:\\n{gpt_messages[0]}\\n\")\n",
|
||||||
|
"print(f\"Claude:\\n{ollama_messages[0]}\\n\")\n",
|
||||||
|
"\n",
|
||||||
|
"for i in range(5):\n",
|
||||||
|
" gpt_next = call_gpt()\n",
|
||||||
|
" print(f\"GPT:\\n{gpt_next}\\n\")\n",
|
||||||
|
" gpt_messages.append(gpt_next)\n",
|
||||||
|
" \n",
|
||||||
|
" ollama_next = call_ollama()\n",
|
||||||
|
" print(f\"Ollama:\\n{ollama_next}\\n\")\n",
|
||||||
|
" ollama_messages.append(ollama_next)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "63d8ece3",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "llms",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.11.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user