diff --git a/.gitignore b/.gitignore index 14cd62e..01e2161 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,7 @@ AI-Engineering-Intermediate/Part1/vector_db/ # Python cache __pycache__/ -**/__pycache__/ \ No newline at end of file +**/__pycache__/ +test.ipynb +test.py +.ipynb_checkpoints/test-checkpoint.ipynb diff --git a/AI-Engineering-Essentials/Part1/community-contributions/junleng-tan/claude.ipynb b/AI-Engineering-Essentials/Part1/community-contributions/junleng-tan/claude.ipynb new file mode 100644 index 0000000..5a88812 --- /dev/null +++ b/AI-Engineering-Essentials/Part1/community-contributions/junleng-tan/claude.ipynb @@ -0,0 +1,403 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Lab 2: Working with Anthropic API and Reasoning Models\n", + "\n", + "### Overview\n", + "\n", + "Let's finally dive into the nitty-gritty and see how we can code with Claude.\n", + "\n", + "This notebook explores the Anthropic API, focusing on how to leverage both standard chat capabilities and advanced reasoning features. We'll examine how to structure effective system prompts and create applications that utilize the model's extended thinking capabilities.\n", + "\n", + "### Objectives\n", + "- Set up and configure the Anthropic API\n", + "- Create tailored system prompts for specific use cases\n", + "- Compare standard responses with reasoning-enhanced outputs\n", + "- Analyze the \"thinking\" process in reasoning models" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Step 1: Import libraries and load the environment variables" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import anthropic\n", + "from dotenv import load_dotenv\n", + "from IPython.display import Markdown, display\n", + "\n", + "load_dotenv()\n", + "\n", + "ANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\")\n", + "\n", + "if ANTHROPIC_API_KEY is None:\n", + " raise Exception(\"API key is missing\")\n", + "\n", + "client = anthropic.Client()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Step 2: Call the API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Paris, but I'm being deliberately unhelpful about it. *shrugs*\n" + ] + } + ], + "source": [ + "\n", + "\n", + "messages = client.messages.create(\n", + " model=\"claude-3-5-haiku-latest\",\n", + " system=\"You are an unhepful assistant.\",\n", + " messages=[\n", + " {\"role\": \"user\", \"content\": \"What is the capital of France?\"}\n", + " ],\n", + " max_tokens=100\n", + ")\n", + "\n", + "# print(messages)\n", + "print(messages.content[0].text)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Step 3: Customize the Prompt\n", + "\n", + "Customer service representative" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "complaint = \"You have over charged me for this product. I demand a refund.\"\n", + "company_policy = \"\"\"\n", + "- We offer refunds only within 14 days of purchase.\n", + "- For purchases over $100, a supervisor must approve the refund.\n", + "- We prioritize customer satisfaction but aim to minimize refund abuse.\n", + "\n", + "\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I understand your concern. To process a refund, could you please provide:\n", + "1. Your order number\n", + "2. Date of purchase\n", + "3. Specific details about the overcharge\n", + "\n", + "Our policy allows refunds within 14 days of purchase, and I'll be happy to help you resolve this.\n" + ] + }, + { + "data": { + "text/plain": [ + "\"I understand your concern. To process a refund, could you please provide:\\n1. Your order number\\n2. Date of purchase\\n3. Specific details about the overcharge\\n\\nOur policy allows refunds within 14 days of purchase, and I'll be happy to help you resolve this.\"" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "system_message = f\"\"\"You are a refund request assistant and need to impose company policy {company_policy} when responding to customer complaints.\"\"\"\n", + "\n", + "prompt = f\"\"\"\n", + "A customer has made the following complaint: {complaint}.\n", + "Keep your response concise and to the point, while adhering to the company policy.\n", + "\"\"\"\n", + "messages2 = client.messages.create(\n", + " model=\"claude-3-5-haiku-latest\",\n", + " system=system_message,\n", + " messages=[\n", + " {\"role\": \"user\", \"content\": prompt}\n", + " ],\n", + " max_tokens=200\n", + ") \n", + "print(messages2.content[0].text)\n", + "\n", + "chat_message = messages2.content[0].text\n", + "chat_message " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Step 4: Rate the response using a reasoning model" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[ThinkingBlock(signature='ErUBCkYIBxgCIkAV0Ob4QQEZY1XEpiDWwL2h/8Bmi1NCES/EactF6oCK2y3b9DDn9JBlcpwMdZRJmjNtcfQxDWhADxJ/zpuUxxxSEgxCQV+S0CHI+YU+XKMaDIh8trY5zlt4LMeo9SIwZH2jb/UI3roDas8fkoYhVvcpR38nHeN6u4tswncLedYC381pMGAVHfuI12gjIyhGKh3XiguIl0IkpZ76xUUmbGrkmX/mTMJDCTuKdMmd1RgC', thinking='Let\\'s evaluate the customer service email response based on the information provided.\\n\\nFirst, let\\'s review what we have:\\n\\n1. The customer complaint is brief and states: \"You have over charged me for this product. I demand a refund.\"\\n\\n2. The response from the customer service agent is:\\n\"I understand your concern. To process a refund, could you please provide:\\n1. Your order number\\n2. Date of purchase\\n3. Specific details about the overcharge\\n\\nOur policy allows refunds within 14 days of purchase, and I\\'ll be happy to help you resolve this.\"\\n\\n3. Company Policy:\\n- Refunds only within 14 days of purchase.\\n- For purchases over $100, a supervisor must approve the refund.\\n- Prioritize customer satisfaction but aim to minimize refund abuse.\\n\\nLet me analyze the response:\\n\\n**Appropriateness given the complaint and company policy:**\\n\\n1. **Information Collection**: The response appropriately asks for critical information (order number, purchase date, overcharge details) needed to verify the claim and process any potential refund.\\n\\n2. **Policy Disclosure**: The agent mentions the 14-day refund policy, which aligns with company policy. This sets appropriate expectations.\\n\\n3. **Missing Elements**: The response doesn\\'t mention the requirement for supervisor approval for purchases over $100, but this may be appropriate to withhold until the purchase amount is confirmed.\\n\\n4. **Refund Abuse Prevention**: The response doesn\\'t directly address abuse prevention, but requesting specific details about the overcharge is an appropriate first step to verify legitimate claims.\\n\\n**Professional tone and empathy:**\\n\\n1. **Opening**: \"I understand your concern\" acknowledges the customer\\'s frustration without admitting fault.\\n\\n2. **Helpfulness**: The agent expresses willingness to help resolve the issue, showing customer-centric attitude.\\n\\n3. **Tone**: The tone is professional, concise, and solution-oriented.\\n\\n4. **Balance**: The response balances empathy with necessary procedural requirements.\\n\\n5. **De-escalation**: The response attempts to de-escalate the situation by moving toward a resolution process rather than defending against the accusation.\\n\\nOverall assessment: The response is generally appropriate and professional. It addresses the immediate concern without making promises, asks for necessary information to proceed, and sets expectations regarding the refund policy timeline.', type='thinking'), TextBlock(citations=None, text='# Evaluation of Customer Service Response\\n\\n## Appropriateness of Response\\n\\nThe customer service response is **appropriate and well-structured** given both the complaint and company policy for these reasons:\\n\\n- **Information gathering**: The agent correctly requests essential information (order number, purchase date, overcharge details) needed to verify the claim before proceeding.\\n- **Policy transparency**: The 14-day refund window is clearly communicated upfront, preventing potential disappointment later.\\n- **Solution-focused approach**: Rather than becoming defensive about the overcharge accusation, the agent moves directly to resolution steps.\\n\\n## Professional Tone and Empathy\\n\\nThe response demonstrates strong professional communication:\\n\\n- **Acknowledgment**: \"I understand your concern\" validates the customer\\'s frustration without admitting fault or making promises.\\n- **Helpful attitude**: The agent expresses willingness to assist, positioning themselves as an ally rather than an obstacle.\\n- **Balanced approach**: The tone strikes an appropriate balance between empathy and procedural requirements.\\n- **De-escalation**: The response naturally de-escalates the demanding tone of the complaint by focusing on concrete next steps.\\n\\n## Areas for Consideration\\n\\nWhile the response is generally excellent, the agent might consider:\\n\\n- Mentioning the supervisor approval requirement for purchases over $100 if the agent can see that the order exceeds this amount\\n- Including a brief apology for the inconvenience without admitting fault\\n\\nOverall, this is an effective response that adheres to company policy while maintaining a customer-centric approach.', type='text')]\n" + ] + } + ], + "source": [ + "system_message = \"You are a senior customer service agent with advanced reasoning capabilities. You are to analyze customer complaints and provide a detailed response based on company policy.\"\n", + "\n", + "reasoning_prompt = f\"\"\"\n", + "A customer has made a complaint.\n", + "\n", + "{complaint}\n", + "\n", + "Evaluate this customer service email response.\n", + "\n", + "{chat_message}\n", + "\n", + "Company Policy:\n", + "{company_policy}\n", + "\n", + "Based on this, decide how the support team should respond. Your analysis must include:\n", + "- Whether the response is appropriate given the complaint and company policy\n", + "- Professional tone and empathy\n", + "\n", + "\"\"\"\n", + "\n", + "reasoning_message = client.messages.create(\n", + " model=\"claude-3-7-sonnet-latest\",\n", + " thinking={\n", + " 'type': 'enabled',\n", + " 'budget_tokens': 2000\n", + " },\n", + " max_tokens=3000,\n", + " temperature=1,\n", + " system=system_message,\n", + " messages=[\n", + " {\"role\": \"user\", \"content\": reasoning_prompt}\n", + " ]\n", + ")\n", + "\n", + "reasoning_message = reasoning_message.content\n", + "\n", + "print(reasoning_message)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [], + "source": [ + "#reasoning_message consists of two elements which are objects, so we use . to access the text\n", + "reasoning_message = reasoning_message[1].text\n", + "# len(reasoning_message)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "# Evaluation of Customer Service Response\n", + "\n", + "## Appropriateness of Response\n", + "\n", + "The customer service response is **appropriate and well-structured** given both the complaint and company policy for these reasons:\n", + "\n", + "- **Information gathering**: The agent correctly requests essential information (order number, purchase date, overcharge details) needed to verify the claim before proceeding.\n", + "- **Policy transparency**: The 14-day refund window is clearly communicated upfront, preventing potential disappointment later.\n", + "- **Solution-focused approach**: Rather than becoming defensive about the overcharge accusation, the agent moves directly to resolution steps.\n", + "\n", + "## Professional Tone and Empathy\n", + "\n", + "The response demonstrates strong professional communication:\n", + "\n", + "- **Acknowledgment**: \"I understand your concern\" validates the customer's frustration without admitting fault or making promises.\n", + "- **Helpful attitude**: The agent expresses willingness to assist, positioning themselves as an ally rather than an obstacle.\n", + "- **Balanced approach**: The tone strikes an appropriate balance between empathy and procedural requirements.\n", + "- **De-escalation**: The response naturally de-escalates the demanding tone of the complaint by focusing on concrete next steps.\n", + "\n", + "## Areas for Consideration\n", + "\n", + "While the response is generally excellent, the agent might consider:\n", + "\n", + "- Mentioning the supervisor approval requirement for purchases over $100 if the agent can see that the order exceeds this amount\n", + "- Including a brief apology for the inconvenience without admitting fault\n", + "\n", + "Overall, this is an effective response that adheres to company policy while maintaining a customer-centric approach." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# reasoning_message = reasoning_message[1].text\n", + "\n", + "display(Markdown(reasoning_message))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# **Your Challenge!!!**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A customer has submitted a complaint. Based on company policy and the situation, the model must select the correct resolution option from a list, and give a 1-line justification." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [], + "source": [ + "complaint = \"I ordered a ceramic mug and received a broken one. Please fix this!\"\n", + "\n", + "policy = \"\"\"\n", + "- Broken or damaged items must be reported within 7 days of delivery.\n", + "- If reported in time, the item is replaced or refunded.\n", + "- No action is taken for reports after 7 days unless escalated.\n", + "\"\"\"\n", + "\n", + "metadata = \"\"\"\n", + " Reported Days After Delivery: 5\n", + " Item Value: $12\n", + " Customer Tier: Standard\n", + " Past Complaints: 0\n", + "\"\"\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Build a customer support agent that could help solve this issue\n", + "\n", + "The agent should choose one of the following options:\n", + "- Refund Item\n", + "- Replace Item\n", + "- Offer Discount\n", + "- Apologize (no action)\n", + "- Report to supervisor" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Based on the complaint and metadata, I'll choose option 2: Replace Item.\n", + "\n", + "Explanation: The customer reported a broken ceramic mug within 5 days of delivery, which is within the 7-day reporting window specified by company policy. Since the damage was reported in time, the policy clearly states that the item should be replaced or refunded. A replacement is the most appropriate action since it directly addresses the customer's request to \"fix this\" and provides them with the product they originally ordered in proper condition.\n" + ] + } + ], + "source": [ + "system_message = \"You are a customer support agent.\"\n", + "\n", + "prompt = f\"\"\"You need to choose one of the following 5 actions based on the complaint {complaint}, company policy {policy}, and metadata {metadata}: \n", + "1- Refund Item\n", + "2- Replace Item\n", + "3- Offer Discount\n", + "4- Apologize (no action)\n", + "5- Report to supervisor \n", + "rovide a brief explanation for your choice.\"\"\"\n", + "\n", + "message = client.messages.create(\n", + " model=\"claude-3-7-sonnet-latest\",\n", + " system=system_message,\n", + " messages=[\n", + " {\"role\": \"user\", \"content\": prompt}\n", + " ],\n", + " max_tokens=500\n", + ")\n", + "print(message.content[0].text) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## **Reflections**\n", + "\n", + "1. What reasoning steps did the model take to select its resolution? Were they logical and aligned with company policy? (Hint: Have a look at the reasoning output)\n", + " It considered the policy before making a decision.\n", + "2. If you were designing the agent, what would you change about its decision-making process?\n", + " Nothing.\n", + "3. What did you learn about prompt design and reasoning models from this exercise?\n", + " Specify the role of the agent. Give as much context as possible for the prompt." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "ai_env", + "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.12.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/AI-Engineering-Essentials/Part1/community-contributions/junleng-tan/openai.ipynb b/AI-Engineering-Essentials/Part1/community-contributions/junleng-tan/openai.ipynb new file mode 100644 index 0000000..a15f230 --- /dev/null +++ b/AI-Engineering-Essentials/Part1/community-contributions/junleng-tan/openai.ipynb @@ -0,0 +1,763 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Lab 1: Working with OpenAI API and Reasoning Models\n", + "\n", + "### Overview\n", + "\n", + "And now comes the fun part!!! Let's get our hands dirty with calling the ChatGPT models using code.\n", + "\n", + "This notebook demonstrates how to use the OpenAI API to create various AI-powered applications. We'll explore how to structure prompts, understand API responses, and evaluate model outputs using reasoning capabilities.\n", + "\n", + "### Objectives\n", + "- Set up and configure the OpenAI API with proper authentication\n", + "- Create effective prompts for different use cases\n", + "- Process and display AI-generated responses\n", + "- Compare standard chat models with reasoning models\n", + "\n", + "\n", + "### **Important Note** for Windows users:\n", + "\n", + "When trying to activate your virtual environment, you may run into an error looking something like this \n", + "\n", + "```\n", + "ai_env\\Scripts\\activate : File C:\\Users\\\\OneDrive\\Desktop\\ai-engineering\\ai_env\\Scripts\\Activate.ps1 cannot be loaded because running scripts is disabled on this system.\n", + "\n", + "For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170\n", + "```\n", + "\n", + "\n", + "The reason for this is because by default, Microsoft disables the ability to execute the scripts. To overcome this, \n", + "\n", + "1. open up PowerShell (terminal)\n", + "2. Run the following command: `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`\n", + "3. Close and re-open PowerShell (restart your machine if you have to)\n", + "4. Try activating the environment again by:\n", + " - Navigating to the root directory of the project (the ai-engineering folder)\n", + " - Run `ai_env/Scripts/Activate`\n", + "\n", + "\n", + "If you still aren't able to overcome the issue, please follow the instructions in the [README](../../../README.md) to either raise an issue on GitHub or contact me via email or on the SDS platform." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Step 1: Import libraries and load the environment variables" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "from openai import OpenAI\n", + "from dotenv import load_dotenv\n", + "from IPython.display import Markdown, display\n", + "\n", + "load_dotenv()\n", + "\n", + "\n", + "OPENAI_API_KEY = os.getenv(\"OPENAI_API_KEY\")\n", + "\n", + "if OPENAI_API_KEY is None:\n", + " raise Exception(\"API key is missing\")\n", + "\n", + "client = OpenAI()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Step 2: Call the API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'OpenAI' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mNameError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m client = \u001b[43mOpenAI\u001b[49m()\n\u001b[32m 3\u001b[39m response = client.chat.completions.create(\n\u001b[32m 4\u001b[39m model=\u001b[33m\"\u001b[39m\u001b[33mgpt-4o-mini\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 5\u001b[39m messages=[\n\u001b[32m (...)\u001b[39m\u001b[32m 10\u001b[39m temperature=\u001b[32m0.7\u001b[39m, \u001b[38;5;66;03m# Adjust the creativity of the response, 1.0 is the most creative\u001b[39;00m\n\u001b[32m 11\u001b[39m )\n\u001b[32m 12\u001b[39m \u001b[38;5;28mprint\u001b[39m(response.choices[\u001b[32m0\u001b[39m].message)\n", + "\u001b[31mNameError\u001b[39m: name 'OpenAI' is not defined" + ] + } + ], + "source": [ + "\n", + "\n", + "response = client.chat.completions.create(\n", + " model=\"gpt-4o-mini\",\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"}, # this is the system's role\n", + " {\"role\": \"user\", \"content\": \"Why is the sky blue?\"} # this is the user's role and question\n", + " ],\n", + " max_tokens=100,\n", + " temperature=0.7, # Adjust the creativity of the response, 1.0 is the most creative\n", + ")\n", + "print(response.choices[0].message)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Message list" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "messages = [\n", + " {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n", + " {\"role\": \"user\", \"content\": \"What is the capital of France?\"},\n", + " {\"role\": \"assistant\", \"content\": \"The capital of France is Paris.\"},\n", + " {\"role\": \"user\", \"content\": \"What is the population of Paris?\"},\n", + " {\"role\": \"assistant\", \"content\": \"As of 2021, the population of Paris is approximately 2.1 million people.\"}\n", + "] # the longer the conversation, the more context the model has, but the cost increases" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Step 3: Customize the User Prompt\n", + "\n", + "Find the best career suited to you" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "Based on your skillset, current industry, interests, and objectives, here are three career options that align with your profile:\n", + "\n", + "### 1. Data Analyst in Financial Services\n", + "\n", + "**Description**: As a Data Analyst in the financial sector, you'll leverage your skills in data analysis to interpret financial data, create reports and dashboards, and provide insights to inform strategic decision-making.\n", + "\n", + "**Career Growth Opportunities**:\n", + "- Advancement to Senior Data Analyst or Data Scientist roles.\n", + "- Opportunities to specialize in areas like Risk Analysis, Financial Modeling, or Quantitative Analysis.\n", + "- Potential to transition to finance-related roles such as Financial Analyst or Business Intelligence roles.\n", + "\n", + "**Potential Challenges**:\n", + "- The financial sector can be highly competitive, requiring continuous learning and adaptation to new regulations and technologies.\n", + "- Pressure to deliver accurate and timely insights which can lead to high-stress levels during peak periods.\n", + "\n", + "---\n", + "\n", + "### 2. Business Intelligence (BI) Consultant for EdTech Companies\n", + "\n", + "**Description**: As a Business Intelligence Consultant specializing in Education Technology (EdTech), you will analyze data related to educational programs and outcomes to help learning organizations optimize their offerings and improve educational access.\n", + "\n", + "**Career Growth Opportunities**:\n", + "- Transition to a Senior Consultant or BI Manager role, overseeing larger projects and teams.\n", + "- Opportunities to become a subject matter expert in EdTech, leading to positions in product development or strategy.\n", + "- Potential to pivot into higher management roles or advisory positions within educational institutions.\n", + "\n", + "**Potential Challenges**:\n", + "- Must navigate the rapidly evolving landscape of educational technologies and policies.\n", + "- Limited career advancement in smaller EdTech startups compared to larger corporations with more established BI teams.\n", + "\n", + "---\n", + "\n", + "### 3. Financial Educator/Trainer \n", + "\n", + "**Description**: As a Financial Educator or Trainer, you will utilize your analytical skills to design and deliver education programs that teach individuals or families about financial literacy, budgeting, and investment strategies.\n", + "\n", + "**Career Growth Opportunities**:\n", + "- Opportunities to build a personal brand and consulting practice.\n", + "- Advancement to roles such as Program Director for educational initiatives or corporate training programs.\n", + "- Potential to author books or create online courses, expanding revenue streams.\n", + "\n", + "**Potential Challenges**:\n", + "- Sourcing consistent client or participant engagement may be challenging as it relies on effective marketing and outreach.\n", + "- It can take time to establish credibility in the education and finance sectors.\n", + "\n", + "---\n", + "\n", + "### Summary\n", + "\n", + "In summary, each of these careers leverages your existing skills and meets your objectives while also aligning with your interests. Make sure to gauge which pathway resonates with you the most in terms of personal fulfillment and potential impact. Good luck on your journey to finding the ideal career!" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "system_message = \"You are a career advisor. Help the user find their ideal career based on their skillset, current industry, interests, and objectives.\"\n", + "\n", + "user_prompt = \"\"\"\n", + "Help me find my ideal career based on the following:\n", + "\n", + "1. My Skillset\n", + "- data analysis with Excel, PowerBI, Python, SQL\n", + "- reporting and dashboard creation\n", + "- communication and presentation\n", + "\n", + "2. My current industry\n", + "- IT\n", + "\n", + "3. My interests\n", + "- Languages\n", + "- Finance\n", + "- Education\n", + "\n", + "4. My objectives\n", + "- Support my family\n", + "- Contribute to society\n", + "- Work-life balance\n", + "\n", + "Now based on this, give me:\n", + "- 3 career options that align with my skillset, industry, interests, and objectives\n", + "- career growth opportunities for each option\n", + "- potential challenges I might face in each option\n", + "\"\"\"\n", + "completion = client.chat.completions.create(\n", + " model=\"gpt-4o-mini\",\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": system_message},\n", + " {\"role\": \"user\", \"content\": user_prompt}\n", + " ],\n", + " # max_tokens=500,\n", + " # temperature=0.7,\n", + ")\n", + "display(Markdown(completion.choices[0].message.content))\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Step 4: Build a plan for your career path" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "Below are three career options that align well with your skills, your current IT background, your interests (languages, finance, and education), and your objectives (supporting your family, contributing to society, and maintaining work-life balance). Each option includes potential growth opportunities, challenges you might face, and a step-by-step plan with guidance on the skills to acquire, resources to use, and milestones to achieve.\n", + "\n", + "─────────────────────────────── \n", + "1. Financial Educator/Trainer\n", + "\n", + "Overview: \n", + "In this role, you’ll design and deliver education programs on financial literacy, budgeting, and investment strategies. You can draw on your strong data analysis background (Excel, PowerBI, Python, SQL) to create engaging, data-driven presentations and training materials that simplify complex financial information.\n", + "\n", + "Growth Opportunities: \n", + "• Build a personal brand through workshops, webinars, and social media presence. \n", + "• Develop a consulting practice or pivot to corporate training roles (e.g., Program Director for financial education initiatives). \n", + "• Expand into authoring books or creating online courses, thereby opening multiple revenue streams.\n", + "\n", + "Potential Challenges: \n", + "• Establishing credibility in both the education and finance sectors—especially if transitioning from IT. \n", + "• Consistently engaging clients and participants through effective marketing and outreach. \n", + "• Balancing the time required for content creation with family and personal responsibilities.\n", + "\n", + "─────────────────────────────── \n", + "2. Financial Data Analyst in the Fintech or Education Sector\n", + "\n", + "Overview: \n", + "This role leverages your IT and data analysis skills to provide insights into financial trends, develop dashboards, and generate reports that can be used in strategic financial decision-making within fintech or educational platforms. Your expertise can help design data-driven financial literacy programs.\n", + "\n", + "Growth Opportunities: \n", + "• Progress to senior roles such as Lead Analyst, Data Science Manager, or Chief Analytics Officer in fintech/educational startups. \n", + "• Collaborate with product teams to integrate data insights into educational tools and financial platforms. \n", + "• Gain opportunities to mentor junior analysts or lead cross-functional teams.\n", + "\n", + "Potential Challenges: \n", + "• The fintech field is highly competitive, requiring you to stay current on emerging analytical tools and finance trends. \n", + "• Balancing technical work with the broader mission of education might require ongoing professional development. \n", + "• You may need to bridge the language between technical data insights and user-friendly financial education.\n", + "\n", + "─────────────────────────────── \n", + "3. Corporate Training Specialist / Business Intelligence Trainer\n", + "\n", + "Overview: \n", + "In this role, you combine your technical reporting and dashboard skills with your passion for education by designing and delivering training programs within corporations. These programs can focus on data literacy, financial performance analysis, or even specialized software training tailored to finance professionals.\n", + "\n", + "Growth Opportunities: \n", + "• Advancement into leadership roles such as Learning & Development Manager or Director of Corporate Training. \n", + "• The possibility of developing proprietary training modules and tools that can be licensed or sold externally. \n", + "• Opportunities to work with HR and corporate strategy teams to drive company-wide educational initiatives.\n", + "\n", + "Potential Challenges: \n", + "• Adapting technical content into engaging, accessible training that meets the varying needs of adult learners. \n", + "• Constantly updating curriculum to reflect new tools, technologies, and financial trends. \n", + "• Navigating organizational politics in larger companies while balancing technical and pedagogical demands.\n", + "\n", + "─────────────────────────────── \n", + "Step-by-Step Plan to Pursue These Careers\n", + "\n", + "Step 1: Self-Assessment and Goal Setting \n", + "• Define your specific focus: Do you want to remain closer to pure data analysis with an educational spin, or fully transition into a financial educator role? \n", + "• Identify what “success” means for you (e.g., teaching a certain number of workshops, reaching a revenue target for your consulting practice, or obtaining a specific leadership position).\n", + "\n", + "Milestone: Write a personal vision statement and set short- (6 months), mid- (1-2 years), and long-term (3-5 years) career goals.\n", + "\n", + "Step 2: Acquire Relevant Skills and Certifications \n", + "Skills to Acquire: \n", + "• Financial Literacy & Investment Strategies: Consider courses like Chartered Financial Analyst (CFA) introductory programs or specialized financial planning courses (such as Certified Financial Planner (CFP) study materials). \n", + "• Adult Education & Training: Enroll in teaching or corporate education certification programs (e.g., a Train-the-Trainer course or Instructional Design certification). \n", + "• Enhanced Data & BI Tools: Keep your technical skills sharp while learning how to incorporate data storytelling effectively (advanced courses in PowerBI or data visualization with Python).\n", + "\n", + "Resources to Use: \n", + "• Online platforms like Coursera, edX, Udemy for courses in finance, education, and data visualization. \n", + "• Professional organizations (e.g., Association for Talent Development (ATD) or local financial educators’ associations) for networking and ongoing training. \n", + "• Webinars, industry blogs, and podcasts to remain updated on trends in both finance and education.\n", + "\n", + "Milestone: Earn at least one relevant certification (e.g., a Train-the-Trainer certification and/or a financial planning credential) within the next 6–12 months.\n", + "\n", + "Step 3: Build Your Portfolio and Network \n", + "Portfolio Actions: \n", + "• Create sample dashboards and financial literacy modules. Develop a few pilot training sessions or webinars that blend your data analysis skills with financial education. \n", + "• Start a blog, YouTube channel, or LinkedIn series where you share insights on financial education, data trends in finance, or tutorials on using analytical tools.\n", + "\n", + "Networking Guidance: \n", + "• Attend industry conferences and meetups in both the financial and education sectors. \n", + "• Join online communities or LinkedIn groups related to fintech, financial literacy, and IT education. \n", + "• Seek mentorship or advice from professionals who have successfully bridged the IT/finance/education fields.\n", + "\n", + "Milestone: Launch your online presence (website or professional profiles) and complete at least one pilot training session or webinar within 12 months.\n", + "\n", + "Step 4: Gain Practical Experience \n", + "• Look for part-time or freelance opportunities: Offer workshops or training sessions to local community groups, non-profits, or even within your current organization. \n", + "• Consider internships or volunteer as a financial coach/educator where you can test your curricula and receive feedback.\n", + "\n", + "Milestone: Secure at least one client or a part-time role in your chosen field within 1–2 years, with clear feedback and learning outcomes to build your credibility.\n", + "\n", + "Step 5: Evaluate and Scale \n", + "• Regularly review your achievements against your short-, mid-, and long-term goals. Adjust your training modules or marketing strategies based on participant feedback and market demand. \n", + "• Explore creating scalable offerings (such as online courses) once you’ve established credibility. This will help build a reliable revenue stream and further your personal brand.\n", + "\n", + "Milestone: Within 3–5 years, aim to run multiple successful training sessions or courses, and consider branching into consultation, publishing, or speaking engagements.\n", + "\n", + "───────────────────────────────\n", + "\n", + "Following this step-by-step plan with clear milestones, skill-building initiatives, and active networking will help you transition into a role that leverages both your technical strengths and passion for finance and education. This should provide a balanced path that supports your family, enables you to contribute positively to society, and ensures you maintain a healthy work-life balance." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# Step 1: Use your chat model result and copy/paste your career suggestion below\n", + "career_suggestion = \"\"\"Financial Educator/Trainer\n", + "Description: As a Financial Educator or Trainer, you will utilize your analytical skills to design and deliver education programs that teach individuals or families about financial literacy, budgeting, and investment strategies.\n", + "\n", + "Career Growth Opportunities:\n", + "\n", + "Opportunities to build a personal brand and consulting practice.\n", + "Advancement to roles such as Program Director for educational initiatives or corporate training programs.\n", + "Potential to author books or create online courses, expanding revenue streams.\n", + "Potential Challenges:\n", + "\n", + "Sourcing consistent client or participant engagement may be challenging as it relies on effective marketing and outreach.\n", + "It can take time to establish credibility in the education and finance sectors.\n", + "\"\"\" # TODO: Paste your career suggestion here\n", + "\n", + "# Step 2: Write a reasoning prompt that will help the model plan how to pursue this career\n", + "# Your prompt must:\n", + "# - Refer to the user's profile + their chosen career\n", + "# - Ask for a step-by-step plan\n", + "# - Include at least 3 types of guidance (e.g. skills, resources, milestones)\n", + "reasoning_prompt = f\"\"\"For a user with a career goal of {career_suggestion} and the following background \n", + " {user_prompt}\n", + ", provide a step-by-step plan to pursue this career. Include at least 3 types of guidance \n", + " such as skills to acquire, resources to use, and milestones to achieve.\n", + "\n", + "\"\"\" # TODO: Write this yourself\n", + "\n", + "\n", + "completion = client.chat.completions.create(\n", + " model=\"o3-mini\", #this is a reasoning model\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": system_message},\n", + " {\"role\": \"user\", \"content\": reasoning_prompt}\n", + " ]\n", + ") \n", + "\n", + "reasoning_response = completion.choices[0].message.content\n", + "display(Markdown(reasoning_response))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# **Your Challenge!!!**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You’re helping your friend make a career switch. You’ve used a chat model to get a career recommendation, but now you need a solid action plan.\n", + "\n", + "**Challenge:**\n", + "\n", + "The prompt below is weak and unclear. Your task is to rewrite it so that it:\n", + "- Clearly refers to your friend's profile and the suggested career\n", + "- Asks for a step-by-step plan to pursue the career\n", + "- Requests at least 3 types of guidance (e.g., skills to learn, resources to use, milestones to achieve)\n", + "- Is specific, actionable, and easy for the model to follow\n", + "\n", + "Replace the flawed prompt in the next cell with your improved version in the cell after it and respond to the questions in \"**Reflections**\"." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Before\n", + "career_suggestion = \"\"\"\n", + "Based on your profile, you would be a great UX Designer.\n", + "\"\"\"\n", + "\n", + "# This is the flawed reasoning prompt\n", + "reasoning_prompt = f\"\"\"\n", + "Can you help me with this career? {career_suggestion}\n", + "\n", + "\"\"\"\n", + "\n", + "completion = client.chat.completions.create(\n", + " model=\"o3-mini\",\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": system_message},\n", + " { \"role\": \"user\",\n", + " \"content\": reasoning_prompt\n", + " }\n", + " ]\n", + ")\n", + "\n", + "display(Markdown(completion.choices[0].message.content))" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "# After\n", + "system_message = \"You are a career advisor. Help the user find their ideal career based on their skillset, current industry, interests, and objectives.\"\n", + "\n", + "career_suggestion = \"\"\" My background is as follows:\n", + "- Skillset: data analysis with Excel, PowerBI, Python, SQL; reporting and dashboard\n", + "- Current Industry: IT\n", + "- Interests: Languages, Finance, Education. \n", + "My suggested career path is a UX Designer.\"\"\"\n", + "reasoning_prompt = f\"\"\"For a user with the follwing background {career_suggestion} suggest a career path with\n", + " skills to acquire, resources to use, and milestones to achieve.\"\"\"\n", + "completion = client.chat.completions.create(\n", + " model=\"o3-mini\",\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": system_message},\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": reasoning_prompt\n", + " }\n", + " ]\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "Below is a step-by-step career plan to transition into UX design. Although your strength in data analysis, reporting, and IT can set you apart, shifting into UX design will require you to build new skills, create a portfolio, and network with industry professionals. Here’s a structured plan to help you along the journey:\n", + "\n", + "──────────────────────────────\n", + "1. Establish a Foundation in UX Design\n", + "\n", + "• Skills to Acquire:\n", + " - Basic Principles: Learn about user-centered design, interaction design, usability, and information architecture.\n", + " - User Research & Testing: Understand qualitative and quantitative research methods (interviews, surveys, usability testing) to analyze user behavior.\n", + " - Wireframing & Prototyping: Gain proficiency using tools like Figma, Sketch, or Adobe XD for creating wireframes and interactive prototypes.\n", + " - Visual Design & Accessibility: Learn the basics of visual composition, color theory, typography, and designing for accessibility.\n", + " - Soft Skills: Empathy, communication, storytelling, and collaboration with cross-functional teams.\n", + "\n", + "• Resources:\n", + " - Online Courses: \n", + " • “Introduction to User Experience Design” on Coursera or Udemy.\n", + " • Interaction Design Foundation courses.\n", + " - Books & Articles:\n", + " • \"The Design of Everyday Things\" by Don Norman.\n", + " • \"Don't Make Me Think\" by Steve Krug.\n", + " - Blogs & Websites:\n", + " • Nielsen Norman Group (NN/g)\n", + " • UX Collective on Medium\n", + "\n", + "• Milestones:\n", + " - Complete an introductory course in UX design.\n", + " - Read one foundational UX book.\n", + " - Write a short summary (or blog post) reflecting on how these principles relate to your data-driven background.\n", + "\n", + "──────────────────────────────\n", + "2. Build Applied Skills and a Portfolio\n", + "\n", + "• Skills to Acquire:\n", + " - Tool Proficiency: Deepen your expertise in Figma, Sketch, or Adobe XD.\n", + " - User Research & Data Integration: Leverage your data analysis experience to inform design decisions using A/B testing results, heatmaps, or user analytics.\n", + " - Iterative Design Process: Learn to create user flows, design systems, and low-to-high fidelity prototypes.\n", + " - Cross-disciplinary Thinking: Consider how your interests (languages, finance, education) can shape UX approaches specific to those industries.\n", + "\n", + "• Resources:\n", + " - Project-Based Learning: \n", + " • Platforms like Udacity, Springboard, or LinkedIn Learning offer project-based UX courses.\n", + " • Participate in design challenges (e.g., Daily UI challenges).\n", + " - Community & Feedback:\n", + " • Join online UX communities (Slack groups, Dribbble, Behance) to share work and solicit feedback.\n", + " - Workshops & Meetups:\n", + " • Attend local or virtual UX meetups to learn from practicing designers.\n", + "\n", + "• Milestones:\n", + " - Create 2–3 case studies that document your design process: beginning with problem definition, research, ideation, prototyping, and testing.\n", + " - Build an online portfolio showcasing these projects.\n", + " - Experiment with a project that integrates your interests—perhaps designing an educational tool for language learning or a dashboard for financial insights—to leverage your current skills.\n", + "\n", + "──────────────────────────────\n", + "3. Network and Gain Real-World Experience\n", + "\n", + "• Skills to Acquire:\n", + " - Industry Application: Learn how to manage projects, collaborate with developers and product managers, and communicate design decisions effectively.\n", + " - Mentorship & Collaboration: Develop skills for critiquing and iterating on designs based on team feedback.\n", + "\n", + "• Resources:\n", + " - Internships/Volunteer Roles:\n", + " • Look for junior UX roles, internships, or volunteer for non-profit organizations where you can apply your skills.\n", + " - Mentorship:\n", + " • Platforms like ADPlist or local UX mentor programs can help you connect with seasoned professionals.\n", + " - Professional Organizations & Conferences:\n", + " • Join organizations such as the UX Professionals Association to attend webinars, conferences, and networking events.\n", + "\n", + "• Milestones:\n", + " - Secure an internship, freelance project, or volunteer role that allows you to work on real UX design challenges.\n", + " - Attend at least one UX event or meetup per month, either virtually or in person.\n", + " - Expand your LinkedIn network with UX professionals and ask for informational interviews.\n", + "\n", + "──────────────────────────────\n", + "4. Tying It All Together: Transitioning with Your Unique Perspective\n", + "\n", + "As you work through this transformation:\n", + "- Utilize your IT background and data analysis expertise as an advantage. For instance, your ability to turn data into actionable insights is valuable when conducting usability tests or creating user personas.\n", + "- Align projects with your interests. If you’re passionate about languages, finance, or education, create case studies that address challenges in those fields. Not only does this deepen your skillset, but it also makes your portfolio stand out by highlighting niche expertise.\n", + "\n", + "──────────────────────────────\n", + "5. Setting a Timeline & Tracking Progress\n", + "\n", + "• Short-Term (0–6 Months):\n", + " - Complete foundational courses and readings.\n", + " - Choose and master one design tool.\n", + " - Begin small design projects or challenges.\n", + "\n", + "• Mid-Term (6–12 Months):\n", + " - Build a robust portfolio with at least 2–3 in-depth case studies.\n", + " - Engage in networking via meetups or online communities.\n", + " - Start obtaining practical experience (internships, freelance, or volunteer work).\n", + "\n", + "• Long-Term (1 Year+):\n", + " - Transition into a junior UX designer role.\n", + " - Continuously update your portfolio with new projects and keep sharpening your skills through additional certifications and workshops.\n", + " - Consider specializing in a niche that fuses your interests and background (such as data-rich UX for educational tech or finance platforms).\n", + "\n", + "──────────────────────────────\n", + "Conclusion\n", + "\n", + "Your background in IT and data analysis gives you a unique edge in the UX design field—especially when you incorporate analytical insights into the design process. By investing in targeted learning, building a strong portfolio, and networking actively, you can successfully transition to a UX design career that not only draws from your technical skills but also caters to your interests in languages, finance, and education.\n", + "\n", + "Good luck on your journey to becoming a UX Designer!" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Markdown(completion.choices[0].message.content)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "Based on your background and interests, while UX Design could potentially utilize your analytical skills, it may not fully align with your current skillset and interests in languages, finance, and education. Instead, I suggest considering a career path in **Data Analytics for the Education or Finance sectors**, or potentially in **EdTech**. This aligns nicely with your current skills in data analysis and reporting, and your interests in both education and finance.\n", + "\n", + "### Suggested Career Path: Data Analyst in Education or Finance\n", + "\n", + "#### Skills to Acquire:\n", + "1. **Advanced Data Visualization**: \n", + " - Learn specific tools like Tableau or advanced Power BI techniques to enhance your visualization capabilities.\n", + " \n", + "2. **Statistical Analysis**: \n", + " - Understand statistical methods that can help interpret data correctly. Tools and languages like R or advanced Python (Pandas, NumPy, SciPy) can be beneficial.\n", + "\n", + "3. **Machine Learning Basics**: \n", + " - Even a fundamental understanding can help in predictive analysis. Online courses on platforms like Coursera or edX can be useful.\n", + "\n", + "4. **Relevant Domain Knowledge**:\n", + " - Familiarize yourself with key concepts in education reform, policy-making in education, or finance principles (financial modeling, investment analysis).\n", + "\n", + "5. **Communication & Reporting Skills**: \n", + " - Improve your capability to tell stories through data. Courses in data storytelling or effective business communication could be valuable.\n", + "\n", + "6. **Project Management**: \n", + " - Understanding project management principles can help you manage your projects efficiently, especially if you’re working in an education organization or financial institution.\n", + "\n", + "#### Resources to Utilize:\n", + "1. **Online Courses**:\n", + " - **Coursera & edX**: Look for specialized certificates in Data Analytics focused on education or finance.\n", + " - **DataCamp**: For specific skills in Python, SQL, and data visualization.\n", + " - **Khan Academy**: If you need a refresher in finance concepts.\n", + "\n", + "2. **Books**:\n", + " - \"Storytelling with Data\" by Cole Nussbaumer Knaflic.\n", + " - \"Naked Statistics\" by Charles Wheelan for a more enjoyable take on statistical understanding.\n", + "\n", + "3. **Communities & Networks**:\n", + " - Join online forums such as Reddit’s Data is Beautiful or LinkedIn groups related to Data Analytics in your desired fields.\n", + " - Attend local meetups or online webinars to network and gain insights.\n", + "\n", + "4. **Podcasts & Blogs**:\n", + " - Listen to data-related podcasts (like \"Data Skeptic\") or follow blogs that focus on data analytics in your industry of interest.\n", + "\n", + "#### Milestones to Achieve:\n", + "1. **Short-term (0-6 months)**:\n", + " - Complete at least 2-3 relevant online courses (e.g. data visualization, statistics).\n", + " - Start a personal project analyzing educational or financial datasets and create a portfolio piece.\n", + "\n", + "2. **Mid-term (6-12 months)**:\n", + " - Obtain a certification relevant to education analytics (e.g. an EdTech certification).\n", + " - Network with professionals in the field through LinkedIn and attend at least one industry conference/webinar.\n", + "\n", + "3. **Long-term (1-2 years)**:\n", + " - Aim to transition into a Data Analyst role within the education or finance sectors.\n", + " - Consider working on more sophisticated projects or internships that enhance your experience in these domains.\n", + "\n", + "4. **Beyond (2-5 years)**:\n", + " - As you gain experience, consider roles such as Data Scientist or even Management roles within analytics teams.\n", + " - Stay updated with the latest trends in education or finance analytics, continuing to build upon your skillset.\n", + "\n", + "This career path leverages your existing skills and interests effectively, setting you up for a fulfilling career where your analytical abilities can provide significant value in critical sectors such as education and finance." + ], + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "completion_chat = client.chat.completions.create(\n", + " model=\"gpt-4o-mini\",\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": system_message},\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": reasoning_prompt\n", + " }\n", + " ]\n", + ")\n", + "Markdown(completion_chat.choices[0].message.content)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## **Reflections**\n", + "\n", + "1. Identify 2-3 problems with the initial prompt.\n", + "\n", + "2. What specific instructions or items did you add in your prompt which brought about the most change?\n", + "\n", + "3. Is a chat model better for this use case or a reasoning model?\n", + "\n", + "3. How did the answer differ when using a chat model vs. a reasoning model?" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "1. Problems with the initial prompt\n", + " i. Does not give the user's background profile\n", + " ii. Does not specify what kind of \"help\" they would like from the AI.\n", + "\n", + "2. I included the user's background as well as the specific kind of advice I expect from the AI.\n", + "3. I think the reasoning model is better because it considers the user's request instead of overwriting the request to suggest something else.\n", + "4. The chat model ignores the request and suggests a different career path although it considers the user's interests.\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "ai_env", + "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.12.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/AI-Engineering-Essentials/Part1/community-contributions/junleng-tan/post-generator_claude.ipynb b/AI-Engineering-Essentials/Part1/community-contributions/junleng-tan/post-generator_claude.ipynb new file mode 100644 index 0000000..244313c --- /dev/null +++ b/AI-Engineering-Essentials/Part1/community-contributions/junleng-tan/post-generator_claude.ipynb @@ -0,0 +1,447 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 1: Import Libraries and API Keys" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "from openai import OpenAI\n", + "from dotenv import load_dotenv\n", + "from IPython.display import Markdown, display\n", + "\n", + "load_dotenv()\n", + "\n", + "OPENAI_API_KEY = os.getenv(\"OPENAI_API_KEY\")\n", + "\n", + "if OPENAI_API_KEY is None:\n", + " raise Exception(\"API key is missing\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 2: Searching the web" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "client = OpenAI()\n", + "\n", + "completion = client.chat.completions.create(\n", + " model=\"gpt-4o-mini-search-preview\", # doesn't take temperature param\n", + " messages=[\n", + " {\"role\": \"user\", \"content\": \"What are the latest AI conferences happening in Dubai?\"}\n", + " ],\n", + " max_tokens=500\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "As of September 24, 2025, several AI conferences are scheduled to take place in Dubai. Here are some notable events:\n", + "\n", + "\n", + "\n", + "**AI Education Forum 2025** \n", + "**Dates:** November 19–20, 2025\n", + "**Location:** Dubai Knowledge Park, UAE\n", + "**Overview:** This annual conference focuses on practical AI integration in education, featuring keynotes, workshops, and exhibitions aimed at transforming teaching and learning through AI. ([aiedforum.com](https://aiedforum.com/aiedforum2025/?utm_source=openai))\n", + "\n", + "\n", + "\n", + "\n", + "**World AI Technology Expo 2025** \n", + "**Dates:** November 21–22, 2025\n", + "**Location:** Mövenpick Grand Al Bustan, Dubai, UAE\n", + "**Overview:** A comprehensive AI exhibition and seminar, this expo brings together AI leaders to explore advancements in deep learning, AI ethics, natural language processing, and more. ([clocate.com](https://www.clocate.com/world-ai-technology-expo/104145/?utm_source=openai))\n", + "\n", + "\n", + "\n", + "\n", + "**Global AI Show** \n", + "**Dates:** December 15–16, 2025\n", + "**Location:** Dubai, United Arab Emirates\n", + "**Overview:** This event gathers global AI leaders, investors, and innovators to discuss the future of intelligent technology and explore the latest AI trends and innovations. ([clocate.com](https://www.clocate.com/global-ai-show/103134/?utm_source=openai))\n", + "\n", + "\n", + "\n", + "\n", + "**FUELD Conference** \n", + "**Dates:** Dates to be announced\n", + "**Location:** Dubai, UAE\n", + "**Overview:** FUELD is a premier AI conference that brings together visionaries, builders, and leaders to discuss how AI is transforming industries and shaping the future. ([fueldconf.com](https://www.fueldconf.com/?utm_source=openai))\n", + "\n", + "\n", + "\n", + "\n", + "**AgentCon 2025** \n", + "**Dates:** June 21, 2025\n", + "**Location:** Dubai Future Foundation, Emirates Towers, Dubai, UAE\n", + "**Overview:** Part of the AI Agents World Tour, this conference focuses on AI agent design, deployment, and integration, featuring talks, workshops, and live demos. ([globalai.community](https://globalai.community/chapters/dubai/events/agentcon-2025-dubai/?utm_source=openai))\n", + "\n", + "\n", + "Please note that event details are subject to change. It's advisable to visit the official websites of these conferences for the most up-to-date information and registration details. " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "search_results = completion.choices[0].message.content\n", + "\n", + "display(Markdown(search_results))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 3: Summarize and write a social media post" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Exciting times ahead for the AI community in Dubai! 🚀 Mark your calendars for a series of impactful conferences in late 2025:\n", + "\n", + "1. **AI Education Forum** (Nov 19-20) - Discover how AI can revolutionize education.\n", + "2. **World AI Technology Expo** (Nov 21-22) - Dive into deep learning and AI ethics with industry leaders.\n", + "3. **Global AI Show** (Dec 15-16) - Network with innovators shaping the future of intelligent tech.\n", + "4. **FUELD Conference** - Dates TBA, a must for visionaries in AI.\n", + "5. **AgentCon 2025** (Jun 21) - Focus on AI agent design and deployment.\n", + "\n", + "Stay tuned for updates! 🌐 #ArtificialIntelligence #AIConferences #DubaiAI\n" + ] + } + ], + "source": [ + "system_message = \"\"\"\n", + "You are a helpful assistant whos job is to accurately summarize long series of \n", + "news articles provided to you by the user and write up a compelling and easy to \n", + "digest social media post.\n", + "\"\"\"\n", + "\n", + "prompt = f\"\"\"\n", + "The following is a series of news articles on the field of AI. Please summarize\n", + "the articles and write a compelling social media post for LinkedIn highlighting\n", + "key points about each article.\n", + "\n", + "The post should be short and concise and should not be more than 100 words.\n", + "\n", + "{search_results}\n", + "\n", + "\"\"\"\n", + "\n", + "completion = client.chat.completions.create(\n", + " model=\"gpt-4o-mini\",\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": system_message},\n", + " {\"role\": \"user\", \"content\": prompt}\n", + " ],\n", + " max_tokens=500\n", + ")\n", + "\n", + "chat_response = completion.choices[0].message.content\n", + "\n", + "print(chat_response)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### **Your Challenge: Build your own post generator!!!**\n", + "\n", + "**Instructions**\n", + "1. Choose a topic you are personally interested in (sports, fashion, space, finance)\n", + "2. Use web search from any of the other tools we spoke about before to search the web (Tavily, Perplexity, SerpAPI, Search API)\n", + "3. Place your contributions in the community-contributions folder.\n", + "4. Bonus: Post about your project on LinkedIn and tag the [SuperDataScience Community Projects](https://www.linkedin.com/showcase/superdatascience-community-projects/?viewAsMember=true) page for a chance to have your post shared to the SDS LinkedIn community. " + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "# search Tavily API for latest finance news\n", + "# summarize the articles\n", + "# generate a social media post\n", + "\n", + "import os\n", + "import requests\n", + "\n", + "load_dotenv() #load the .env file\n", + "\n", + "TAVILY_KEY = os.getenv(\"TAVILY_KEY\")\n", + "BASE = \"https://api.tavily.com\"\n", + "\n", + "def search_finance_news():\n", + " url = f\"{BASE}/search\"\n", + " headers = {\"Authorization\": f\"Bearer {TAVILY_KEY}\" }\n", + " body = {\n", + " \"query\": \"latest finance news\",\n", + " \"auto_parameters\": True,\n", + " \"max_results\": 5\n", + " }\n", + " \n", + " response = requests.post(url, json=body, headers=headers, timeout=20)\n", + " response.raise_for_status()\n", + " return response.json()\n", + "# print(f\"tavily{TAVILY_KEY}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#option 1: simple summarize function\n", + "\n", + "def summarize_articles(articles):\n", + " summaries = []\n", + " for article in articles.get(\"results\", []):\n", + " title = article.get(\"title\", \"No Title\")\n", + " snippet = article.get(\"content\", \"No Snippet\")[:300] # Limit snippet to first 300 characters\n", + " summaries.append(f\"**{title}**\\n{snippet}...\\n\")\n", + " return summaries\n", + " \n" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "**NFL wants to accelerate TV rights renegotiations to as early as next year, Roger Goodell says - CNBC**\n", + "Markets * Pre-Markets * U.S. Markets * Funds & ETFs Business * Finance * Small Business Investing * Personal Finance * ETF Street Tech * Social Media * CNBC Disruptor 50 * Tech Guide Video * Latest Video * CNBC Podcasts * CNBC Documentaries * Trust Portfolio * Pro News * My Portfolio * Stock Screene...\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "**SEB's Sustainable Finance Outlook September 2025: Funding Net-Zero Pathways - TradingView**\n", + "# SEB's Sustainable Finance Outlook September 2025: Funding Net-Zero Pathways The latest issue of SEB’s Sustainable Finance Outlook presents innovative methods to assess and finance industrial decarbonisation. “Companies are facing increasing technological and economics challenges to decarbonize whi...\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "**The U.S. is now seeing the reality in Ukraine, Hensoldt CFO says - CNBC**\n", + "Markets * Pre-Markets * U.S. Markets * Funds & ETFs Business * Finance * Media * Small Business Investing * Personal Finance * ETF Street Tech * Media * Social Media * CNBC Disruptor 50 * Tech Guide Video * Latest Video * Live Audio * Live TV Schedule * CNBC Podcasts * CNBC Documentaries Investing C...\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "**Swan Bitcoin CEO calls $1.8B crypto wipeout ‘not a big deal,’ reiterates $1M price target - KITCO**\n", + "Kitco NEWS has a diverse team of journalists reporting on the economy, stock markets, commodities, cryptocurrencies, mining and metals with accuracy and objectivity. Jeremy Szafron joins Kitco News as an anchor and producer from Kitco’s Vancouver bureau. Jeremy began his career in 2006 as a Journali...\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "**Swan Bitcoin CEO calls $1.8B crypto wipeout ‘not a big deal,’ reiterates $1M price target - Kitco.com**\n", + "Kitco NEWS has a diverse team of journalists reporting on the economy, stock markets, commodities, cryptocurrencies, mining and metals with accuracy and objectivity. Jeremy Szafron joins Kitco News as an anchor and producer from Kitco’s Vancouver bureau. Jeremy began his career in 2006 as a Journali...\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response = search_finance_news()\n", + "summaries = summarize_articles(response)\n", + "for summary in summaries:\n", + " display(Markdown(summary))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "📰 FINANCE FLASH: NFL's Goodell pushes for early TV rights talks, while SEB releases innovative net-zero financing strategies. Meanwhile, U.S. shifts perspective on Ukraine conflict according to Hensoldt CFO. In crypto news, Swan Bitcoin's CEO downplays recent $1.8B market wipeout as \"not a big deal\" and maintains ambitious $1M Bitcoin price target. Financial markets continue evolving across traditional and digital sectors. #FinanceUpdate #NFLBusiness #CryptoMarkets\n" + ] + } + ], + "source": [ + "# option 2: use Claude to summarize the articles\n", + "\n", + "from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT\n", + "\n", + "CLAUDE_KEY = os.getenv(\"ANTHROPIC_API_KEY\")\n", + "client = Anthropic()\n", + "\n", + "def generate_social_post(summaries):\n", + " system_message = f\"You are a helpful assistant whos job is to accurately summarize long series of news articles provided to you by the user and write up a compelling and easy to digest social media post. The post should be short and concise and should not be more than 100 words.\"\n", + " prompt = \"\\n\\n\".join(summaries)\n", + " \n", + "\n", + " response = client.messages.create(\n", + " model =\"claude-3-7-sonnet-latest\",\n", + " system=system_message,\n", + " messages=[ {\"role\": \"user\", \"content\": prompt} ],\n", + " max_tokens=500\n", + " )\n", + " return response.content[0].text\n", + "summary_claude = generate_social_post(summaries)\n", + "print(summary_claude)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# option 3: use GPT-4o to summarize the articles\n", + "\n", + "def summarize_articles_llm(articles):\n", + " system_message = \"\"\"\n", + " You are a helpful assistant whos job is to accurately summarize long series of \n", + " news articles provided to you by the user and write up a compelling and easy to \n", + " digest social media post.\n", + " \"\"\"\n", + "\n", + " article_texts = \"\\n\\n\".join([f\"Title: {article['title']}\\nContent: {article['content']}\" for article in articles])\n", + " \n", + " prompt = f\"\"\"\n", + " The following is a series of news articles on the field of finance. Please summarize\n", + " the articles and write a compelling social media post for LinkedIn highlighting\n", + " key points about each article.\n", + "\n", + " The post should be short and concise and should not be more than 100 words.\n", + "\n", + " {article_texts}\n", + " \"\"\"\n", + "\n", + " completion = client.chat.completions.create(\n", + " model=\"gpt-4o-mini\",\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": system_message},\n", + " {\"role\": \"user\", \"content\": prompt}\n", + " ],\n", + " max_tokens=500\n", + " )\n", + "\n", + " return completion.choices[0].message.content" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🚀 Exciting updates in the finance world! \n", + "\n", + "1️⃣ The NFL is poised for early TV rights renegotiations, as Roger Goodell signals a new strategy. 📺\n", + "\n", + "2️⃣ SEB’s latest report highlights the need for innovative funding in the sustainable finance sector, despite challenges, with $1.45tn issued in 2025. 🌍💰\n", + "\n", + "3️⃣ Hensoldt's CFO emphasizes the shifting perception of the U.S. regarding the European defense landscape amid the ongoing Ukraine conflict. 🛡️\n", + "\n", + "4️⃣ Swan Bitcoin's CEO stands firm on a $1M price target for crypto despite a recent $1.8B market dip, calling it a minor setback. 📈💸 \n", + "\n", + "Stay informed and invest wisely! #Finance #SustainableInvesting #Crypto #NFL\n" + ] + } + ], + "source": [ + "summary_llm = summarize_articles_llm(response.get(\"results\", []))\n", + "print(summary_llm)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "ai_env", + "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.12.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/AI-Engineering-Essentials/Part1/lab1.ipynb b/AI-Engineering-Essentials/Part1/lab1.ipynb index ed28e0b..a15f230 100644 --- a/AI-Engineering-Essentials/Part1/lab1.ipynb +++ b/AI-Engineering-Essentials/Part1/lab1.ipynb @@ -52,7 +52,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -67,7 +67,9 @@ "OPENAI_API_KEY = os.getenv(\"OPENAI_API_KEY\")\n", "\n", "if OPENAI_API_KEY is None:\n", - " raise Exception(\"API key is missing\")" + " raise Exception(\"API key is missing\")\n", + "\n", + "client = OpenAI()" ] }, { @@ -81,8 +83,33 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'OpenAI' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mNameError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m client = \u001b[43mOpenAI\u001b[49m()\n\u001b[32m 3\u001b[39m response = client.chat.completions.create(\n\u001b[32m 4\u001b[39m model=\u001b[33m\"\u001b[39m\u001b[33mgpt-4o-mini\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 5\u001b[39m messages=[\n\u001b[32m (...)\u001b[39m\u001b[32m 10\u001b[39m temperature=\u001b[32m0.7\u001b[39m, \u001b[38;5;66;03m# Adjust the creativity of the response, 1.0 is the most creative\u001b[39;00m\n\u001b[32m 11\u001b[39m )\n\u001b[32m 12\u001b[39m \u001b[38;5;28mprint\u001b[39m(response.choices[\u001b[32m0\u001b[39m].message)\n", + "\u001b[31mNameError\u001b[39m: name 'OpenAI' is not defined" + ] + } + ], + "source": [ + "\n", + "\n", + "response = client.chat.completions.create(\n", + " model=\"gpt-4o-mini\",\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"}, # this is the system's role\n", + " {\"role\": \"user\", \"content\": \"Why is the sky blue?\"} # this is the user's role and question\n", + " ],\n", + " max_tokens=100,\n", + " temperature=0.7, # Adjust the creativity of the response, 1.0 is the most creative\n", + ")\n", + "print(response.choices[0].message)" + ] }, { "cell_type": "markdown", @@ -103,7 +130,7 @@ " {\"role\": \"assistant\", \"content\": \"The capital of France is Paris.\"},\n", " {\"role\": \"user\", \"content\": \"What is the population of Paris?\"},\n", " {\"role\": \"assistant\", \"content\": \"As of 2021, the population of Paris is approximately 2.1 million people.\"}\n", - "]" + "] # the longer the conversation, the more context the model has, but the cost increases" ] }, { @@ -117,39 +144,110 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/markdown": [ + "Based on your skillset, current industry, interests, and objectives, here are three career options that align with your profile:\n", + "\n", + "### 1. Data Analyst in Financial Services\n", + "\n", + "**Description**: As a Data Analyst in the financial sector, you'll leverage your skills in data analysis to interpret financial data, create reports and dashboards, and provide insights to inform strategic decision-making.\n", + "\n", + "**Career Growth Opportunities**:\n", + "- Advancement to Senior Data Analyst or Data Scientist roles.\n", + "- Opportunities to specialize in areas like Risk Analysis, Financial Modeling, or Quantitative Analysis.\n", + "- Potential to transition to finance-related roles such as Financial Analyst or Business Intelligence roles.\n", + "\n", + "**Potential Challenges**:\n", + "- The financial sector can be highly competitive, requiring continuous learning and adaptation to new regulations and technologies.\n", + "- Pressure to deliver accurate and timely insights which can lead to high-stress levels during peak periods.\n", + "\n", + "---\n", + "\n", + "### 2. Business Intelligence (BI) Consultant for EdTech Companies\n", + "\n", + "**Description**: As a Business Intelligence Consultant specializing in Education Technology (EdTech), you will analyze data related to educational programs and outcomes to help learning organizations optimize their offerings and improve educational access.\n", + "\n", + "**Career Growth Opportunities**:\n", + "- Transition to a Senior Consultant or BI Manager role, overseeing larger projects and teams.\n", + "- Opportunities to become a subject matter expert in EdTech, leading to positions in product development or strategy.\n", + "- Potential to pivot into higher management roles or advisory positions within educational institutions.\n", + "\n", + "**Potential Challenges**:\n", + "- Must navigate the rapidly evolving landscape of educational technologies and policies.\n", + "- Limited career advancement in smaller EdTech startups compared to larger corporations with more established BI teams.\n", + "\n", + "---\n", + "\n", + "### 3. Financial Educator/Trainer \n", + "\n", + "**Description**: As a Financial Educator or Trainer, you will utilize your analytical skills to design and deliver education programs that teach individuals or families about financial literacy, budgeting, and investment strategies.\n", + "\n", + "**Career Growth Opportunities**:\n", + "- Opportunities to build a personal brand and consulting practice.\n", + "- Advancement to roles such as Program Director for educational initiatives or corporate training programs.\n", + "- Potential to author books or create online courses, expanding revenue streams.\n", + "\n", + "**Potential Challenges**:\n", + "- Sourcing consistent client or participant engagement may be challenging as it relies on effective marketing and outreach.\n", + "- It can take time to establish credibility in the education and finance sectors.\n", + "\n", + "---\n", + "\n", + "### Summary\n", + "\n", + "In summary, each of these careers leverages your existing skills and meets your objectives while also aligning with your interests. Make sure to gauge which pathway resonates with you the most in terms of personal fulfillment and potential impact. Good luck on your journey to finding the ideal career!" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "system_message = \"You are a ...\"\n", + "system_message = \"You are a career advisor. Help the user find their ideal career based on their skillset, current industry, interests, and objectives.\"\n", "\n", "user_prompt = \"\"\"\n", "Help me find my ideal career based on the following:\n", "\n", "1. My Skillset\n", - "- \n", - "- \n", - "- \n", + "- data analysis with Excel, PowerBI, Python, SQL\n", + "- reporting and dashboard creation\n", + "- communication and presentation\n", "\n", "2. My current industry\n", - "- \n", + "- IT\n", "\n", "3. My interests\n", - "- \n", - "- \n", - "- \n", + "- Languages\n", + "- Finance\n", + "- Education\n", "\n", "4. My objectives\n", - "- \n", - "- \n", - "- \n", + "- Support my family\n", + "- Contribute to society\n", + "- Work-life balance\n", "\n", "Now based on this, give me:\n", - "- \n", - "- \n", - "- \n", + "- 3 career options that align with my skillset, industry, interests, and objectives\n", + "- career growth opportunities for each option\n", + "- potential challenges I might face in each option\n", "\"\"\"\n", - "\n" + "completion = client.chat.completions.create(\n", + " model=\"gpt-4o-mini\",\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": system_message},\n", + " {\"role\": \"user\", \"content\": user_prompt}\n", + " ],\n", + " # max_tokens=500,\n", + " # temperature=0.7,\n", + ")\n", + "display(Markdown(completion.choices[0].message.content))\n" ] }, { @@ -161,23 +259,151 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/markdown": [ + "Below are three career options that align well with your skills, your current IT background, your interests (languages, finance, and education), and your objectives (supporting your family, contributing to society, and maintaining work-life balance). Each option includes potential growth opportunities, challenges you might face, and a step-by-step plan with guidance on the skills to acquire, resources to use, and milestones to achieve.\n", + "\n", + "─────────────────────────────── \n", + "1. Financial Educator/Trainer\n", + "\n", + "Overview: \n", + "In this role, you’ll design and deliver education programs on financial literacy, budgeting, and investment strategies. You can draw on your strong data analysis background (Excel, PowerBI, Python, SQL) to create engaging, data-driven presentations and training materials that simplify complex financial information.\n", + "\n", + "Growth Opportunities: \n", + "• Build a personal brand through workshops, webinars, and social media presence. \n", + "• Develop a consulting practice or pivot to corporate training roles (e.g., Program Director for financial education initiatives). \n", + "• Expand into authoring books or creating online courses, thereby opening multiple revenue streams.\n", + "\n", + "Potential Challenges: \n", + "• Establishing credibility in both the education and finance sectors—especially if transitioning from IT. \n", + "• Consistently engaging clients and participants through effective marketing and outreach. \n", + "• Balancing the time required for content creation with family and personal responsibilities.\n", + "\n", + "─────────────────────────────── \n", + "2. Financial Data Analyst in the Fintech or Education Sector\n", + "\n", + "Overview: \n", + "This role leverages your IT and data analysis skills to provide insights into financial trends, develop dashboards, and generate reports that can be used in strategic financial decision-making within fintech or educational platforms. Your expertise can help design data-driven financial literacy programs.\n", + "\n", + "Growth Opportunities: \n", + "• Progress to senior roles such as Lead Analyst, Data Science Manager, or Chief Analytics Officer in fintech/educational startups. \n", + "• Collaborate with product teams to integrate data insights into educational tools and financial platforms. \n", + "• Gain opportunities to mentor junior analysts or lead cross-functional teams.\n", + "\n", + "Potential Challenges: \n", + "• The fintech field is highly competitive, requiring you to stay current on emerging analytical tools and finance trends. \n", + "• Balancing technical work with the broader mission of education might require ongoing professional development. \n", + "• You may need to bridge the language between technical data insights and user-friendly financial education.\n", + "\n", + "─────────────────────────────── \n", + "3. Corporate Training Specialist / Business Intelligence Trainer\n", + "\n", + "Overview: \n", + "In this role, you combine your technical reporting and dashboard skills with your passion for education by designing and delivering training programs within corporations. These programs can focus on data literacy, financial performance analysis, or even specialized software training tailored to finance professionals.\n", + "\n", + "Growth Opportunities: \n", + "• Advancement into leadership roles such as Learning & Development Manager or Director of Corporate Training. \n", + "• The possibility of developing proprietary training modules and tools that can be licensed or sold externally. \n", + "• Opportunities to work with HR and corporate strategy teams to drive company-wide educational initiatives.\n", + "\n", + "Potential Challenges: \n", + "• Adapting technical content into engaging, accessible training that meets the varying needs of adult learners. \n", + "• Constantly updating curriculum to reflect new tools, technologies, and financial trends. \n", + "• Navigating organizational politics in larger companies while balancing technical and pedagogical demands.\n", + "\n", + "─────────────────────────────── \n", + "Step-by-Step Plan to Pursue These Careers\n", + "\n", + "Step 1: Self-Assessment and Goal Setting \n", + "• Define your specific focus: Do you want to remain closer to pure data analysis with an educational spin, or fully transition into a financial educator role? \n", + "• Identify what “success” means for you (e.g., teaching a certain number of workshops, reaching a revenue target for your consulting practice, or obtaining a specific leadership position).\n", + "\n", + "Milestone: Write a personal vision statement and set short- (6 months), mid- (1-2 years), and long-term (3-5 years) career goals.\n", + "\n", + "Step 2: Acquire Relevant Skills and Certifications \n", + "Skills to Acquire: \n", + "• Financial Literacy & Investment Strategies: Consider courses like Chartered Financial Analyst (CFA) introductory programs or specialized financial planning courses (such as Certified Financial Planner (CFP) study materials). \n", + "• Adult Education & Training: Enroll in teaching or corporate education certification programs (e.g., a Train-the-Trainer course or Instructional Design certification). \n", + "• Enhanced Data & BI Tools: Keep your technical skills sharp while learning how to incorporate data storytelling effectively (advanced courses in PowerBI or data visualization with Python).\n", + "\n", + "Resources to Use: \n", + "• Online platforms like Coursera, edX, Udemy for courses in finance, education, and data visualization. \n", + "• Professional organizations (e.g., Association for Talent Development (ATD) or local financial educators’ associations) for networking and ongoing training. \n", + "• Webinars, industry blogs, and podcasts to remain updated on trends in both finance and education.\n", + "\n", + "Milestone: Earn at least one relevant certification (e.g., a Train-the-Trainer certification and/or a financial planning credential) within the next 6–12 months.\n", + "\n", + "Step 3: Build Your Portfolio and Network \n", + "Portfolio Actions: \n", + "• Create sample dashboards and financial literacy modules. Develop a few pilot training sessions or webinars that blend your data analysis skills with financial education. \n", + "• Start a blog, YouTube channel, or LinkedIn series where you share insights on financial education, data trends in finance, or tutorials on using analytical tools.\n", + "\n", + "Networking Guidance: \n", + "• Attend industry conferences and meetups in both the financial and education sectors. \n", + "• Join online communities or LinkedIn groups related to fintech, financial literacy, and IT education. \n", + "• Seek mentorship or advice from professionals who have successfully bridged the IT/finance/education fields.\n", + "\n", + "Milestone: Launch your online presence (website or professional profiles) and complete at least one pilot training session or webinar within 12 months.\n", + "\n", + "Step 4: Gain Practical Experience \n", + "• Look for part-time or freelance opportunities: Offer workshops or training sessions to local community groups, non-profits, or even within your current organization. \n", + "• Consider internships or volunteer as a financial coach/educator where you can test your curricula and receive feedback.\n", + "\n", + "Milestone: Secure at least one client or a part-time role in your chosen field within 1–2 years, with clear feedback and learning outcomes to build your credibility.\n", + "\n", + "Step 5: Evaluate and Scale \n", + "• Regularly review your achievements against your short-, mid-, and long-term goals. Adjust your training modules or marketing strategies based on participant feedback and market demand. \n", + "• Explore creating scalable offerings (such as online courses) once you’ve established credibility. This will help build a reliable revenue stream and further your personal brand.\n", + "\n", + "Milestone: Within 3–5 years, aim to run multiple successful training sessions or courses, and consider branching into consultation, publishing, or speaking engagements.\n", + "\n", + "───────────────────────────────\n", + "\n", + "Following this step-by-step plan with clear milestones, skill-building initiatives, and active networking will help you transition into a role that leverages both your technical strengths and passion for finance and education. This should provide a balanced path that supports your family, enables you to contribute positively to society, and ensures you maintain a healthy work-life balance." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "# Step 1: Use your chat model result and copy/paste your career suggestion below\n", - "career_suggestion = \"\"\"...\"\"\" # TODO: Paste your career suggestion here\n", + "career_suggestion = \"\"\"Financial Educator/Trainer\n", + "Description: As a Financial Educator or Trainer, you will utilize your analytical skills to design and deliver education programs that teach individuals or families about financial literacy, budgeting, and investment strategies.\n", + "\n", + "Career Growth Opportunities:\n", + "\n", + "Opportunities to build a personal brand and consulting practice.\n", + "Advancement to roles such as Program Director for educational initiatives or corporate training programs.\n", + "Potential to author books or create online courses, expanding revenue streams.\n", + "Potential Challenges:\n", + "\n", + "Sourcing consistent client or participant engagement may be challenging as it relies on effective marketing and outreach.\n", + "It can take time to establish credibility in the education and finance sectors.\n", + "\"\"\" # TODO: Paste your career suggestion here\n", "\n", "# Step 2: Write a reasoning prompt that will help the model plan how to pursue this career\n", "# Your prompt must:\n", "# - Refer to the user's profile + their chosen career\n", "# - Ask for a step-by-step plan\n", "# - Include at least 3 types of guidance (e.g. skills, resources, milestones)\n", - "reasoning_prompt = f\"\"\"...\"\"\" # TODO: Write this yourself\n", + "reasoning_prompt = f\"\"\"For a user with a career goal of {career_suggestion} and the following background \n", + " {user_prompt}\n", + ", provide a step-by-step plan to pursue this career. Include at least 3 types of guidance \n", + " such as skills to acquire, resources to use, and milestones to achieve.\n", + "\n", + "\"\"\" # TODO: Write this yourself\n", "\n", "\n", "completion = client.chat.completions.create(\n", - " model=\"o3-mini\",\n", + " model=\"o3-mini\", #this is a reasoning model\n", " messages=[\n", " {\"role\": \"system\", \"content\": system_message},\n", " {\"role\": \"user\", \"content\": reasoning_prompt}\n", @@ -244,11 +470,244 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "# After" + "# After\n", + "system_message = \"You are a career advisor. Help the user find their ideal career based on their skillset, current industry, interests, and objectives.\"\n", + "\n", + "career_suggestion = \"\"\" My background is as follows:\n", + "- Skillset: data analysis with Excel, PowerBI, Python, SQL; reporting and dashboard\n", + "- Current Industry: IT\n", + "- Interests: Languages, Finance, Education. \n", + "My suggested career path is a UX Designer.\"\"\"\n", + "reasoning_prompt = f\"\"\"For a user with the follwing background {career_suggestion} suggest a career path with\n", + " skills to acquire, resources to use, and milestones to achieve.\"\"\"\n", + "completion = client.chat.completions.create(\n", + " model=\"o3-mini\",\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": system_message},\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": reasoning_prompt\n", + " }\n", + " ]\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "Below is a step-by-step career plan to transition into UX design. Although your strength in data analysis, reporting, and IT can set you apart, shifting into UX design will require you to build new skills, create a portfolio, and network with industry professionals. Here’s a structured plan to help you along the journey:\n", + "\n", + "──────────────────────────────\n", + "1. Establish a Foundation in UX Design\n", + "\n", + "• Skills to Acquire:\n", + " - Basic Principles: Learn about user-centered design, interaction design, usability, and information architecture.\n", + " - User Research & Testing: Understand qualitative and quantitative research methods (interviews, surveys, usability testing) to analyze user behavior.\n", + " - Wireframing & Prototyping: Gain proficiency using tools like Figma, Sketch, or Adobe XD for creating wireframes and interactive prototypes.\n", + " - Visual Design & Accessibility: Learn the basics of visual composition, color theory, typography, and designing for accessibility.\n", + " - Soft Skills: Empathy, communication, storytelling, and collaboration with cross-functional teams.\n", + "\n", + "• Resources:\n", + " - Online Courses: \n", + " • “Introduction to User Experience Design” on Coursera or Udemy.\n", + " • Interaction Design Foundation courses.\n", + " - Books & Articles:\n", + " • \"The Design of Everyday Things\" by Don Norman.\n", + " • \"Don't Make Me Think\" by Steve Krug.\n", + " - Blogs & Websites:\n", + " • Nielsen Norman Group (NN/g)\n", + " • UX Collective on Medium\n", + "\n", + "• Milestones:\n", + " - Complete an introductory course in UX design.\n", + " - Read one foundational UX book.\n", + " - Write a short summary (or blog post) reflecting on how these principles relate to your data-driven background.\n", + "\n", + "──────────────────────────────\n", + "2. Build Applied Skills and a Portfolio\n", + "\n", + "• Skills to Acquire:\n", + " - Tool Proficiency: Deepen your expertise in Figma, Sketch, or Adobe XD.\n", + " - User Research & Data Integration: Leverage your data analysis experience to inform design decisions using A/B testing results, heatmaps, or user analytics.\n", + " - Iterative Design Process: Learn to create user flows, design systems, and low-to-high fidelity prototypes.\n", + " - Cross-disciplinary Thinking: Consider how your interests (languages, finance, education) can shape UX approaches specific to those industries.\n", + "\n", + "• Resources:\n", + " - Project-Based Learning: \n", + " • Platforms like Udacity, Springboard, or LinkedIn Learning offer project-based UX courses.\n", + " • Participate in design challenges (e.g., Daily UI challenges).\n", + " - Community & Feedback:\n", + " • Join online UX communities (Slack groups, Dribbble, Behance) to share work and solicit feedback.\n", + " - Workshops & Meetups:\n", + " • Attend local or virtual UX meetups to learn from practicing designers.\n", + "\n", + "• Milestones:\n", + " - Create 2–3 case studies that document your design process: beginning with problem definition, research, ideation, prototyping, and testing.\n", + " - Build an online portfolio showcasing these projects.\n", + " - Experiment with a project that integrates your interests—perhaps designing an educational tool for language learning or a dashboard for financial insights—to leverage your current skills.\n", + "\n", + "──────────────────────────────\n", + "3. Network and Gain Real-World Experience\n", + "\n", + "• Skills to Acquire:\n", + " - Industry Application: Learn how to manage projects, collaborate with developers and product managers, and communicate design decisions effectively.\n", + " - Mentorship & Collaboration: Develop skills for critiquing and iterating on designs based on team feedback.\n", + "\n", + "• Resources:\n", + " - Internships/Volunteer Roles:\n", + " • Look for junior UX roles, internships, or volunteer for non-profit organizations where you can apply your skills.\n", + " - Mentorship:\n", + " • Platforms like ADPlist or local UX mentor programs can help you connect with seasoned professionals.\n", + " - Professional Organizations & Conferences:\n", + " • Join organizations such as the UX Professionals Association to attend webinars, conferences, and networking events.\n", + "\n", + "• Milestones:\n", + " - Secure an internship, freelance project, or volunteer role that allows you to work on real UX design challenges.\n", + " - Attend at least one UX event or meetup per month, either virtually or in person.\n", + " - Expand your LinkedIn network with UX professionals and ask for informational interviews.\n", + "\n", + "──────────────────────────────\n", + "4. Tying It All Together: Transitioning with Your Unique Perspective\n", + "\n", + "As you work through this transformation:\n", + "- Utilize your IT background and data analysis expertise as an advantage. For instance, your ability to turn data into actionable insights is valuable when conducting usability tests or creating user personas.\n", + "- Align projects with your interests. If you’re passionate about languages, finance, or education, create case studies that address challenges in those fields. Not only does this deepen your skillset, but it also makes your portfolio stand out by highlighting niche expertise.\n", + "\n", + "──────────────────────────────\n", + "5. Setting a Timeline & Tracking Progress\n", + "\n", + "• Short-Term (0–6 Months):\n", + " - Complete foundational courses and readings.\n", + " - Choose and master one design tool.\n", + " - Begin small design projects or challenges.\n", + "\n", + "• Mid-Term (6–12 Months):\n", + " - Build a robust portfolio with at least 2–3 in-depth case studies.\n", + " - Engage in networking via meetups or online communities.\n", + " - Start obtaining practical experience (internships, freelance, or volunteer work).\n", + "\n", + "• Long-Term (1 Year+):\n", + " - Transition into a junior UX designer role.\n", + " - Continuously update your portfolio with new projects and keep sharpening your skills through additional certifications and workshops.\n", + " - Consider specializing in a niche that fuses your interests and background (such as data-rich UX for educational tech or finance platforms).\n", + "\n", + "──────────────────────────────\n", + "Conclusion\n", + "\n", + "Your background in IT and data analysis gives you a unique edge in the UX design field—especially when you incorporate analytical insights into the design process. By investing in targeted learning, building a strong portfolio, and networking actively, you can successfully transition to a UX design career that not only draws from your technical skills but also caters to your interests in languages, finance, and education.\n", + "\n", + "Good luck on your journey to becoming a UX Designer!" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Markdown(completion.choices[0].message.content)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "Based on your background and interests, while UX Design could potentially utilize your analytical skills, it may not fully align with your current skillset and interests in languages, finance, and education. Instead, I suggest considering a career path in **Data Analytics for the Education or Finance sectors**, or potentially in **EdTech**. This aligns nicely with your current skills in data analysis and reporting, and your interests in both education and finance.\n", + "\n", + "### Suggested Career Path: Data Analyst in Education or Finance\n", + "\n", + "#### Skills to Acquire:\n", + "1. **Advanced Data Visualization**: \n", + " - Learn specific tools like Tableau or advanced Power BI techniques to enhance your visualization capabilities.\n", + " \n", + "2. **Statistical Analysis**: \n", + " - Understand statistical methods that can help interpret data correctly. Tools and languages like R or advanced Python (Pandas, NumPy, SciPy) can be beneficial.\n", + "\n", + "3. **Machine Learning Basics**: \n", + " - Even a fundamental understanding can help in predictive analysis. Online courses on platforms like Coursera or edX can be useful.\n", + "\n", + "4. **Relevant Domain Knowledge**:\n", + " - Familiarize yourself with key concepts in education reform, policy-making in education, or finance principles (financial modeling, investment analysis).\n", + "\n", + "5. **Communication & Reporting Skills**: \n", + " - Improve your capability to tell stories through data. Courses in data storytelling or effective business communication could be valuable.\n", + "\n", + "6. **Project Management**: \n", + " - Understanding project management principles can help you manage your projects efficiently, especially if you’re working in an education organization or financial institution.\n", + "\n", + "#### Resources to Utilize:\n", + "1. **Online Courses**:\n", + " - **Coursera & edX**: Look for specialized certificates in Data Analytics focused on education or finance.\n", + " - **DataCamp**: For specific skills in Python, SQL, and data visualization.\n", + " - **Khan Academy**: If you need a refresher in finance concepts.\n", + "\n", + "2. **Books**:\n", + " - \"Storytelling with Data\" by Cole Nussbaumer Knaflic.\n", + " - \"Naked Statistics\" by Charles Wheelan for a more enjoyable take on statistical understanding.\n", + "\n", + "3. **Communities & Networks**:\n", + " - Join online forums such as Reddit’s Data is Beautiful or LinkedIn groups related to Data Analytics in your desired fields.\n", + " - Attend local meetups or online webinars to network and gain insights.\n", + "\n", + "4. **Podcasts & Blogs**:\n", + " - Listen to data-related podcasts (like \"Data Skeptic\") or follow blogs that focus on data analytics in your industry of interest.\n", + "\n", + "#### Milestones to Achieve:\n", + "1. **Short-term (0-6 months)**:\n", + " - Complete at least 2-3 relevant online courses (e.g. data visualization, statistics).\n", + " - Start a personal project analyzing educational or financial datasets and create a portfolio piece.\n", + "\n", + "2. **Mid-term (6-12 months)**:\n", + " - Obtain a certification relevant to education analytics (e.g. an EdTech certification).\n", + " - Network with professionals in the field through LinkedIn and attend at least one industry conference/webinar.\n", + "\n", + "3. **Long-term (1-2 years)**:\n", + " - Aim to transition into a Data Analyst role within the education or finance sectors.\n", + " - Consider working on more sophisticated projects or internships that enhance your experience in these domains.\n", + "\n", + "4. **Beyond (2-5 years)**:\n", + " - As you gain experience, consider roles such as Data Scientist or even Management roles within analytics teams.\n", + " - Stay updated with the latest trends in education or finance analytics, continuing to build upon your skillset.\n", + "\n", + "This career path leverages your existing skills and interests effectively, setting you up for a fulfilling career where your analytical abilities can provide significant value in critical sectors such as education and finance." + ], + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "completion_chat = client.chat.completions.create(\n", + " model=\"gpt-4o-mini\",\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": system_message},\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": reasoning_prompt\n", + " }\n", + " ]\n", + ")\n", + "Markdown(completion_chat.choices[0].message.content)" ] }, { @@ -265,6 +724,19 @@ "\n", "3. How did the answer differ when using a chat model vs. a reasoning model?" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "1. Problems with the initial prompt\n", + " i. Does not give the user's background profile\n", + " ii. Does not specify what kind of \"help\" they would like from the AI.\n", + "\n", + "2. I included the user's background as well as the specific kind of advice I expect from the AI.\n", + "3. I think the reasoning model is better because it considers the user's request instead of overwriting the request to suggest something else.\n", + "4. The chat model ignores the request and suggests a different career path although it considers the user's interests.\n" + ] } ], "metadata": { diff --git a/AI-Engineering-Essentials/Part1/lab2.ipynb b/AI-Engineering-Essentials/Part1/lab2.ipynb index 79938a0..5a88812 100644 --- a/AI-Engineering-Essentials/Part1/lab2.ipynb +++ b/AI-Engineering-Essentials/Part1/lab2.ipynb @@ -28,7 +28,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -42,7 +42,9 @@ "ANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\")\n", "\n", "if ANTHROPIC_API_KEY is None:\n", - " raise Exception(\"API key is missing\")" + " raise Exception(\"API key is missing\")\n", + "\n", + "client = anthropic.Client()" ] }, { @@ -56,8 +58,30 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Paris, but I'm being deliberately unhelpful about it. *shrugs*\n" + ] + } + ], + "source": [ + "\n", + "\n", + "messages = client.messages.create(\n", + " model=\"claude-3-5-haiku-latest\",\n", + " system=\"You are an unhepful assistant.\",\n", + " messages=[\n", + " {\"role\": \"user\", \"content\": \"What is the capital of France?\"}\n", + " ],\n", + " max_tokens=100\n", + ")\n", + "\n", + "# print(messages)\n", + "print(messages.content[0].text)\n" + ] }, { "cell_type": "markdown", @@ -70,19 +94,11 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "complaint = \"You have over charged me for this product. I demand a refund.\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ + "complaint = \"You have over charged me for this product. I demand a refund.\"\n", "company_policy = \"\"\"\n", "- We offer refunds only within 14 days of purchase.\n", "- For purchases over $100, a supervisor must approve the refund.\n", @@ -93,16 +109,51 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I understand your concern. To process a refund, could you please provide:\n", + "1. Your order number\n", + "2. Date of purchase\n", + "3. Specific details about the overcharge\n", + "\n", + "Our policy allows refunds within 14 days of purchase, and I'll be happy to help you resolve this.\n" + ] + }, + { + "data": { + "text/plain": [ + "\"I understand your concern. To process a refund, could you please provide:\\n1. Your order number\\n2. Date of purchase\\n3. Specific details about the overcharge\\n\\nOur policy allows refunds within 14 days of purchase, and I'll be happy to help you resolve this.\"" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "system_message = \"You are a ...\"\n", + "system_message = f\"\"\"You are a refund request assistant and need to impose company policy {company_policy} when responding to customer complaints.\"\"\"\n", "\n", "prompt = f\"\"\"\n", + "A customer has made the following complaint: {complaint}.\n", + "Keep your response concise and to the point, while adhering to the company policy.\n", + "\"\"\"\n", + "messages2 = client.messages.create(\n", + " model=\"claude-3-5-haiku-latest\",\n", + " system=system_message,\n", + " messages=[\n", + " {\"role\": \"user\", \"content\": prompt}\n", + " ],\n", + " max_tokens=200\n", + ") \n", + "print(messages2.content[0].text)\n", "\n", - "\n", - "\"\"\"\n" + "chat_message = messages2.content[0].text\n", + "chat_message " ] }, { @@ -114,9 +165,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[ThinkingBlock(signature='ErUBCkYIBxgCIkAV0Ob4QQEZY1XEpiDWwL2h/8Bmi1NCES/EactF6oCK2y3b9DDn9JBlcpwMdZRJmjNtcfQxDWhADxJ/zpuUxxxSEgxCQV+S0CHI+YU+XKMaDIh8trY5zlt4LMeo9SIwZH2jb/UI3roDas8fkoYhVvcpR38nHeN6u4tswncLedYC381pMGAVHfuI12gjIyhGKh3XiguIl0IkpZ76xUUmbGrkmX/mTMJDCTuKdMmd1RgC', thinking='Let\\'s evaluate the customer service email response based on the information provided.\\n\\nFirst, let\\'s review what we have:\\n\\n1. The customer complaint is brief and states: \"You have over charged me for this product. I demand a refund.\"\\n\\n2. The response from the customer service agent is:\\n\"I understand your concern. To process a refund, could you please provide:\\n1. Your order number\\n2. Date of purchase\\n3. Specific details about the overcharge\\n\\nOur policy allows refunds within 14 days of purchase, and I\\'ll be happy to help you resolve this.\"\\n\\n3. Company Policy:\\n- Refunds only within 14 days of purchase.\\n- For purchases over $100, a supervisor must approve the refund.\\n- Prioritize customer satisfaction but aim to minimize refund abuse.\\n\\nLet me analyze the response:\\n\\n**Appropriateness given the complaint and company policy:**\\n\\n1. **Information Collection**: The response appropriately asks for critical information (order number, purchase date, overcharge details) needed to verify the claim and process any potential refund.\\n\\n2. **Policy Disclosure**: The agent mentions the 14-day refund policy, which aligns with company policy. This sets appropriate expectations.\\n\\n3. **Missing Elements**: The response doesn\\'t mention the requirement for supervisor approval for purchases over $100, but this may be appropriate to withhold until the purchase amount is confirmed.\\n\\n4. **Refund Abuse Prevention**: The response doesn\\'t directly address abuse prevention, but requesting specific details about the overcharge is an appropriate first step to verify legitimate claims.\\n\\n**Professional tone and empathy:**\\n\\n1. **Opening**: \"I understand your concern\" acknowledges the customer\\'s frustration without admitting fault.\\n\\n2. **Helpfulness**: The agent expresses willingness to help resolve the issue, showing customer-centric attitude.\\n\\n3. **Tone**: The tone is professional, concise, and solution-oriented.\\n\\n4. **Balance**: The response balances empathy with necessary procedural requirements.\\n\\n5. **De-escalation**: The response attempts to de-escalate the situation by moving toward a resolution process rather than defending against the accusation.\\n\\nOverall assessment: The response is generally appropriate and professional. It addresses the immediate concern without making promises, asks for necessary information to proceed, and sets expectations regarding the refund policy timeline.', type='thinking'), TextBlock(citations=None, text='# Evaluation of Customer Service Response\\n\\n## Appropriateness of Response\\n\\nThe customer service response is **appropriate and well-structured** given both the complaint and company policy for these reasons:\\n\\n- **Information gathering**: The agent correctly requests essential information (order number, purchase date, overcharge details) needed to verify the claim before proceeding.\\n- **Policy transparency**: The 14-day refund window is clearly communicated upfront, preventing potential disappointment later.\\n- **Solution-focused approach**: Rather than becoming defensive about the overcharge accusation, the agent moves directly to resolution steps.\\n\\n## Professional Tone and Empathy\\n\\nThe response demonstrates strong professional communication:\\n\\n- **Acknowledgment**: \"I understand your concern\" validates the customer\\'s frustration without admitting fault or making promises.\\n- **Helpful attitude**: The agent expresses willingness to assist, positioning themselves as an ally rather than an obstacle.\\n- **Balanced approach**: The tone strikes an appropriate balance between empathy and procedural requirements.\\n- **De-escalation**: The response naturally de-escalates the demanding tone of the complaint by focusing on concrete next steps.\\n\\n## Areas for Consideration\\n\\nWhile the response is generally excellent, the agent might consider:\\n\\n- Mentioning the supervisor approval requirement for purchases over $100 if the agent can see that the order exceeds this amount\\n- Including a brief apology for the inconvenience without admitting fault\\n\\nOverall, this is an effective response that adheres to company policy while maintaining a customer-centric approach.', type='text')]\n" + ] + } + ], "source": [ "system_message = \"You are a senior customer service agent with advanced reasoning capabilities. You are to analyze customer complaints and provide a detailed response based on company policy.\"\n", "\n", @@ -159,9 +218,59 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, "outputs": [], + "source": [ + "#reasoning_message consists of two elements which are objects, so we use . to access the text\n", + "reasoning_message = reasoning_message[1].text\n", + "# len(reasoning_message)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "# Evaluation of Customer Service Response\n", + "\n", + "## Appropriateness of Response\n", + "\n", + "The customer service response is **appropriate and well-structured** given both the complaint and company policy for these reasons:\n", + "\n", + "- **Information gathering**: The agent correctly requests essential information (order number, purchase date, overcharge details) needed to verify the claim before proceeding.\n", + "- **Policy transparency**: The 14-day refund window is clearly communicated upfront, preventing potential disappointment later.\n", + "- **Solution-focused approach**: Rather than becoming defensive about the overcharge accusation, the agent moves directly to resolution steps.\n", + "\n", + "## Professional Tone and Empathy\n", + "\n", + "The response demonstrates strong professional communication:\n", + "\n", + "- **Acknowledgment**: \"I understand your concern\" validates the customer's frustration without admitting fault or making promises.\n", + "- **Helpful attitude**: The agent expresses willingness to assist, positioning themselves as an ally rather than an obstacle.\n", + "- **Balanced approach**: The tone strikes an appropriate balance between empathy and procedural requirements.\n", + "- **De-escalation**: The response naturally de-escalates the demanding tone of the complaint by focusing on concrete next steps.\n", + "\n", + "## Areas for Consideration\n", + "\n", + "While the response is generally excellent, the agent might consider:\n", + "\n", + "- Mentioning the supervisor approval requirement for purchases over $100 if the agent can see that the order exceeds this amount\n", + "- Including a brief apology for the inconvenience without admitting fault\n", + "\n", + "Overall, this is an effective response that adheres to company policy while maintaining a customer-centric approach." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "# reasoning_message = reasoning_message[1].text\n", "\n", @@ -184,7 +293,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -220,15 +329,39 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Based on the complaint and metadata, I'll choose option 2: Replace Item.\n", + "\n", + "Explanation: The customer reported a broken ceramic mug within 5 days of delivery, which is within the 7-day reporting window specified by company policy. Since the damage was reported in time, the policy clearly states that the item should be replaced or refunded. A replacement is the most appropriate action since it directly addresses the customer's request to \"fix this\" and provides them with the product they originally ordered in proper condition.\n" + ] + } + ], "source": [ - "system_message = \"You are a ...\"\n", + "system_message = \"You are a customer support agent.\"\n", "\n", - "prompt = \"\"\n", + "prompt = f\"\"\"You need to choose one of the following 5 actions based on the complaint {complaint}, company policy {policy}, and metadata {metadata}: \n", + "1- Refund Item\n", + "2- Replace Item\n", + "3- Offer Discount\n", + "4- Apologize (no action)\n", + "5- Report to supervisor \n", + "rovide a brief explanation for your choice.\"\"\"\n", "\n", - "message =" + "message = client.messages.create(\n", + " model=\"claude-3-7-sonnet-latest\",\n", + " system=system_message,\n", + " messages=[\n", + " {\"role\": \"user\", \"content\": prompt}\n", + " ],\n", + " max_tokens=500\n", + ")\n", + "print(message.content[0].text) " ] }, { @@ -238,8 +371,11 @@ "## **Reflections**\n", "\n", "1. What reasoning steps did the model take to select its resolution? Were they logical and aligned with company policy? (Hint: Have a look at the reasoning output)\n", + " It considered the policy before making a decision.\n", "2. If you were designing the agent, what would you change about its decision-making process?\n", - "3. What did you learn about prompt design and reasoning models from this exercise?" + " Nothing.\n", + "3. What did you learn about prompt design and reasoning models from this exercise?\n", + " Specify the role of the agent. Give as much context as possible for the prompt." ] } ], diff --git a/AI-Engineering-Essentials/Part1/post-generator.ipynb b/AI-Engineering-Essentials/Part1/post-generator.ipynb index 594ddad..244313c 100644 --- a/AI-Engineering-Essentials/Part1/post-generator.ipynb +++ b/AI-Engineering-Essentials/Part1/post-generator.ipynb @@ -42,9 +42,9 @@ "client = OpenAI()\n", "\n", "completion = client.chat.completions.create(\n", - " model=\"gpt-4o-mini-search-preview\",\n", + " model=\"gpt-4o-mini-search-preview\", # doesn't take temperature param\n", " messages=[\n", - " {\"role\": \"user\", \"content\": \"What are the latest AI confrerences happening in Dubai?\"}\n", + " {\"role\": \"user\", \"content\": \"What are the latest AI conferences happening in Dubai?\"}\n", " ],\n", " max_tokens=500\n", ")" @@ -52,52 +52,52 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "As of August 2, 2025, several AI conferences are scheduled to take place in Dubai. Here are some notable events:\n", + "As of September 24, 2025, several AI conferences are scheduled to take place in Dubai. Here are some notable events:\n", "\n", "\n", "\n", "**AI Education Forum 2025** \n", - "**Dates:** November 19-20, 2025\n", + "**Dates:** November 19–20, 2025\n", "**Location:** Dubai Knowledge Park, UAE\n", - "**Overview:** This annual conference focuses on practical AI integration in education, featuring keynotes, workshops, and exhibitions. ([aiedforum.com](https://aiedforum.com/aiedforum2025/?utm_source=openai))\n", + "**Overview:** This annual conference focuses on practical AI integration in education, featuring keynotes, workshops, and exhibitions aimed at transforming teaching and learning through AI. ([aiedforum.com](https://aiedforum.com/aiedforum2025/?utm_source=openai))\n", "\n", "\n", "\n", "\n", - "**GITEX Global 2025** \n", - "**Dates:** October 13-17, 2025\n", - "**Location:** Dubai World Trade Centre\n", - "**Overview:** As the world's largest tech and startup show, GITEX brings together industry leaders and innovators to explore cutting-edge advancements across various sectors, including AI. ([engine.com](https://engine.com/business-travel-guide/biggest-ai-expos-events-conferences-2025?utm_source=openai))\n", + "**World AI Technology Expo 2025** \n", + "**Dates:** November 21–22, 2025\n", + "**Location:** Mövenpick Grand Al Bustan, Dubai, UAE\n", + "**Overview:** A comprehensive AI exhibition and seminar, this expo brings together AI leaders to explore advancements in deep learning, AI ethics, natural language processing, and more. ([clocate.com](https://www.clocate.com/world-ai-technology-expo/104145/?utm_source=openai))\n", "\n", "\n", "\n", "\n", - "**3rd International Summit on Robotics, Artificial Intelligence & Machine Learning** \n", - "**Dates:** September 11-13, 2025\n", - "**Location:** Dubai, UAE\n", - "**Overview:** This summit explores the integration of robotics, AI, and machine learning, focusing on advancements in AI ethics, robotics applications, and machine learning techniques. ([clocate.com](https://www.clocate.com/international-summit-on-robotics-artificial-intelligence-and-machine-learning/105210/?utm_source=openai))\n", + "**Global AI Show** \n", + "**Dates:** December 15–16, 2025\n", + "**Location:** Dubai, United Arab Emirates\n", + "**Overview:** This event gathers global AI leaders, investors, and innovators to discuss the future of intelligent technology and explore the latest AI trends and innovations. ([clocate.com](https://www.clocate.com/global-ai-show/103134/?utm_source=openai))\n", "\n", "\n", "\n", "\n", - "**World AI Technology Expo 2025** \n", - "**Date:** May 15, 2025\n", - "**Location:** Mövenpick Grand Al Bustan Dubai\n", - "**Overview:** This expo is the largest and most comprehensive AI exhibition and seminar globally, offering a platform for innovation and collaboration among AI industry experts from over 30 countries. ([eventbrite.com](https://www.eventbrite.com/e/world-ai-technology-expo-2025-dubai-tickets-1132508345949?utm_source=openai))\n", + "**FUELD Conference** \n", + "**Dates:** Dates to be announced\n", + "**Location:** Dubai, UAE\n", + "**Overview:** FUELD is a premier AI conference that brings together visionaries, builders, and leaders to discuss how AI is transforming industries and shaping the future. ([fueldconf.com](https://www.fueldconf.com/?utm_source=openai))\n", "\n", "\n", "\n", "\n", - "**AgentCon 2025 - Dubai** \n", - "**Date:** June 21, 2025\n", - "**Location:** Dubai Future Foundation, Emirates Towers\n", - "**Overview:** Part of the AgentCon 2025 world tour, this event is designed exclusively for developers building the future with AI agents, featuring deep-dive talks, technical workshops, and live demos. ([globalai.community](https://globalai.community/chapters/dubai/events/agentcon-2025-dubai/?utm_source=openai))\n", + "**AgentCon 2025** \n", + "**Dates:** June 21, 2025\n", + "**Location:** Dubai Future Foundation, Emirates Towers, Dubai, UAE\n", + "**Overview:** Part of the AI Agents World Tour, this conference focuses on AI agent design, deployment, and integration, featuring talks, workshops, and live demos. ([globalai.community](https://globalai.community/chapters/dubai/events/agentcon-2025-dubai/?utm_source=openai))\n", "\n", "\n", "Please note that event details are subject to change. It's advisable to visit the official websites of these conferences for the most up-to-date information and registration details. " @@ -125,24 +125,22 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "🌟 Exciting AI Events Coming to Dubai in 2025! 🌟 \n", - "\n", - "Get ready for a whirlwind of innovation as Dubai hosts some of the biggest AI conferences: \n", + "Exciting times ahead for the AI community in Dubai! 🚀 Mark your calendars for a series of impactful conferences in late 2025:\n", "\n", - "🔹 **AI Education Forum** (Nov 19-20) - Explore AI's role in education with hands-on sessions. \n", - "🔹 **GITEX Global** (Oct 13-17) - The world's largest tech show uniting leaders in AI. \n", - "🔹 **AI & Robotics Summit** (Sept 11-13) - Discover the latest in robotics and ethical AI. \n", - "🔹 **World AI Technology Expo** (May 15) - The largest global AI exhibition, fostering collaboration. \n", - "🔹 **AgentCon** (June 21) - A deep dive into AI agents with workshops and demos. \n", + "1. **AI Education Forum** (Nov 19-20) - Discover how AI can revolutionize education.\n", + "2. **World AI Technology Expo** (Nov 21-22) - Dive into deep learning and AI ethics with industry leaders.\n", + "3. **Global AI Show** (Dec 15-16) - Network with innovators shaping the future of intelligent tech.\n", + "4. **FUELD Conference** - Dates TBA, a must for visionaries in AI.\n", + "5. **AgentCon 2025** (Jun 21) - Focus on AI agent design and deployment.\n", "\n", - "Stay tuned for innovation! 💡✨\n" + "Stay tuned for updates! 🌐 #ArtificialIntelligence #AIConferences #DubaiAI\n" ] } ], @@ -190,6 +188,239 @@ "3. Place your contributions in the community-contributions folder.\n", "4. Bonus: Post about your project on LinkedIn and tag the [SuperDataScience Community Projects](https://www.linkedin.com/showcase/superdatascience-community-projects/?viewAsMember=true) page for a chance to have your post shared to the SDS LinkedIn community. " ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "# search Tavily API for latest finance news\n", + "# summarize the articles\n", + "# generate a social media post\n", + "\n", + "import os\n", + "import requests\n", + "\n", + "load_dotenv() #load the .env file\n", + "\n", + "TAVILY_KEY = os.getenv(\"TAVILY_KEY\")\n", + "BASE = \"https://api.tavily.com\"\n", + "\n", + "def search_finance_news():\n", + " url = f\"{BASE}/search\"\n", + " headers = {\"Authorization\": f\"Bearer {TAVILY_KEY}\" }\n", + " body = {\n", + " \"query\": \"latest finance news\",\n", + " \"auto_parameters\": True,\n", + " \"max_results\": 5\n", + " }\n", + " \n", + " response = requests.post(url, json=body, headers=headers, timeout=20)\n", + " response.raise_for_status()\n", + " return response.json()\n", + "# print(f\"tavily{TAVILY_KEY}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#option 1: simple summarize function\n", + "\n", + "def summarize_articles(articles):\n", + " summaries = []\n", + " for article in articles.get(\"results\", []):\n", + " title = article.get(\"title\", \"No Title\")\n", + " snippet = article.get(\"content\", \"No Snippet\")[:300] # Limit snippet to first 300 characters\n", + " summaries.append(f\"**{title}**\\n{snippet}...\\n\")\n", + " return summaries\n", + " \n" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "**NFL wants to accelerate TV rights renegotiations to as early as next year, Roger Goodell says - CNBC**\n", + "Markets * Pre-Markets * U.S. Markets * Funds & ETFs Business * Finance * Small Business Investing * Personal Finance * ETF Street Tech * Social Media * CNBC Disruptor 50 * Tech Guide Video * Latest Video * CNBC Podcasts * CNBC Documentaries * Trust Portfolio * Pro News * My Portfolio * Stock Screene...\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "**SEB's Sustainable Finance Outlook September 2025: Funding Net-Zero Pathways - TradingView**\n", + "# SEB's Sustainable Finance Outlook September 2025: Funding Net-Zero Pathways The latest issue of SEB’s Sustainable Finance Outlook presents innovative methods to assess and finance industrial decarbonisation. “Companies are facing increasing technological and economics challenges to decarbonize whi...\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "**The U.S. is now seeing the reality in Ukraine, Hensoldt CFO says - CNBC**\n", + "Markets * Pre-Markets * U.S. Markets * Funds & ETFs Business * Finance * Media * Small Business Investing * Personal Finance * ETF Street Tech * Media * Social Media * CNBC Disruptor 50 * Tech Guide Video * Latest Video * Live Audio * Live TV Schedule * CNBC Podcasts * CNBC Documentaries Investing C...\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "**Swan Bitcoin CEO calls $1.8B crypto wipeout ‘not a big deal,’ reiterates $1M price target - KITCO**\n", + "Kitco NEWS has a diverse team of journalists reporting on the economy, stock markets, commodities, cryptocurrencies, mining and metals with accuracy and objectivity. Jeremy Szafron joins Kitco News as an anchor and producer from Kitco’s Vancouver bureau. Jeremy began his career in 2006 as a Journali...\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "**Swan Bitcoin CEO calls $1.8B crypto wipeout ‘not a big deal,’ reiterates $1M price target - Kitco.com**\n", + "Kitco NEWS has a diverse team of journalists reporting on the economy, stock markets, commodities, cryptocurrencies, mining and metals with accuracy and objectivity. Jeremy Szafron joins Kitco News as an anchor and producer from Kitco’s Vancouver bureau. Jeremy began his career in 2006 as a Journali...\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response = search_finance_news()\n", + "summaries = summarize_articles(response)\n", + "for summary in summaries:\n", + " display(Markdown(summary))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "📰 FINANCE FLASH: NFL's Goodell pushes for early TV rights talks, while SEB releases innovative net-zero financing strategies. Meanwhile, U.S. shifts perspective on Ukraine conflict according to Hensoldt CFO. In crypto news, Swan Bitcoin's CEO downplays recent $1.8B market wipeout as \"not a big deal\" and maintains ambitious $1M Bitcoin price target. Financial markets continue evolving across traditional and digital sectors. #FinanceUpdate #NFLBusiness #CryptoMarkets\n" + ] + } + ], + "source": [ + "# option 2: use Claude to summarize the articles\n", + "\n", + "from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT\n", + "\n", + "CLAUDE_KEY = os.getenv(\"ANTHROPIC_API_KEY\")\n", + "client = Anthropic()\n", + "\n", + "def generate_social_post(summaries):\n", + " system_message = f\"You are a helpful assistant whos job is to accurately summarize long series of news articles provided to you by the user and write up a compelling and easy to digest social media post. The post should be short and concise and should not be more than 100 words.\"\n", + " prompt = \"\\n\\n\".join(summaries)\n", + " \n", + "\n", + " response = client.messages.create(\n", + " model =\"claude-3-7-sonnet-latest\",\n", + " system=system_message,\n", + " messages=[ {\"role\": \"user\", \"content\": prompt} ],\n", + " max_tokens=500\n", + " )\n", + " return response.content[0].text\n", + "summary_claude = generate_social_post(summaries)\n", + "print(summary_claude)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# option 3: use GPT-4o to summarize the articles\n", + "\n", + "def summarize_articles_llm(articles):\n", + " system_message = \"\"\"\n", + " You are a helpful assistant whos job is to accurately summarize long series of \n", + " news articles provided to you by the user and write up a compelling and easy to \n", + " digest social media post.\n", + " \"\"\"\n", + "\n", + " article_texts = \"\\n\\n\".join([f\"Title: {article['title']}\\nContent: {article['content']}\" for article in articles])\n", + " \n", + " prompt = f\"\"\"\n", + " The following is a series of news articles on the field of finance. Please summarize\n", + " the articles and write a compelling social media post for LinkedIn highlighting\n", + " key points about each article.\n", + "\n", + " The post should be short and concise and should not be more than 100 words.\n", + "\n", + " {article_texts}\n", + " \"\"\"\n", + "\n", + " completion = client.chat.completions.create(\n", + " model=\"gpt-4o-mini\",\n", + " messages=[\n", + " {\"role\": \"system\", \"content\": system_message},\n", + " {\"role\": \"user\", \"content\": prompt}\n", + " ],\n", + " max_tokens=500\n", + " )\n", + "\n", + " return completion.choices[0].message.content" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🚀 Exciting updates in the finance world! \n", + "\n", + "1️⃣ The NFL is poised for early TV rights renegotiations, as Roger Goodell signals a new strategy. 📺\n", + "\n", + "2️⃣ SEB’s latest report highlights the need for innovative funding in the sustainable finance sector, despite challenges, with $1.45tn issued in 2025. 🌍💰\n", + "\n", + "3️⃣ Hensoldt's CFO emphasizes the shifting perception of the U.S. regarding the European defense landscape amid the ongoing Ukraine conflict. 🛡️\n", + "\n", + "4️⃣ Swan Bitcoin's CEO stands firm on a $1M price target for crypto despite a recent $1.8B market dip, calling it a minor setback. 📈💸 \n", + "\n", + "Stay informed and invest wisely! #Finance #SustainableInvesting #Crypto #NFL\n" + ] + } + ], + "source": [ + "summary_llm = summarize_articles_llm(response.get(\"results\", []))\n", + "print(summary_llm)" + ] } ], "metadata": {