{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Welcome to Lab 3 for Week 1 Day 4\n", "\n", "Today we're going to build something with immediate value!\n", "\n", "In the folder `me` I've put a single file `linkedin.pdf` - it's a PDF download of my LinkedIn profile.\n", "\n", "Please replace it with yours!\n", "\n", "I've also made a file called `summary.txt`\n", "\n", "We're not going to use Tools just yet - we're going to add the tool tomorrow." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", "

Looking up packages

\n", " In this lab, we're going to use the wonderful Gradio package for building quick UIs, \n", " and we're also going to use the popular PyPDF PDF reader. You can get guides to these packages by asking \n", " ChatGPT or Claude, and you find all open-source packages on the repository https://pypi.org.\n", " \n", "
" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# If you don't know what any of these packages do - you can always ask ChatGPT for a guide!\n", "\n", "from dotenv import load_dotenv\n", "from openai import OpenAI\n", "from pypdf import PdfReader\n", "from docx import Document\n", "import gradio as gr" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "load_dotenv(override=True)\n", "openai = OpenAI()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "reader = PdfReader(\"me/linkedin.pdf\")\n", "linkedin = \"\"\n", "for page in reader.pages:\n", " text = page.extract_text()\n", " if text:\n", " linkedin += text" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "HomeMy Network Jobs MessagingNotifications Me\n", " For Business Lea\n", "1\n", "2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\n", "https://www.linkedin.com/in/eric-mclean-a522154/ 1/7500+ connections\n", "Add\n", "profile\n", "section\n", "Enhance\n", "profile\n", " He/Him\n", "Finance and Operations Leader | Business Modeling and Data Analysis| Strategy and Tactics\n", "Rancho Santa Margarita, California, United States  Contact info\n", "Eric McLean \n", "Electronic Merchant Systems\n", "University of California, Irvine Division of Continuing Education\n", "Opento\n", "Resources\n", "Open to workVP of Finance and Director of Finance rolesShow details\n", "Share that you’re hiricandidates.Get started\n", "Analytics Private to you\n", "57 profile viewsDiscover who's viewed your profile.\n", "0 post impressionsStart a post to increase engagement.Past 7 days\n", "32 search appearancesSee how often you appear in search results.\n", "Show all analytics\n", "About\n", "2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\n", "https://www.linkedin.com/in/eric-mclean-a522154/ 2/7Experience Professional and People Leader skilled in People Management, Finance,Operations, Strategy, Analytical Problem Solving, Business Modeling, Sales andOperational Planning, Sales Compensation and Territory Planning, and BusinessIntelligence.\n", "Activity1,045 followers\n", "Create a post\n", "You haven’t posted yetPosts you share will be displayed here.\n", "Show all activity\n", "Experience\n", "VP Specialized MarketsElectronic Merchant Systems · Full-timeNov 2024 - Present · 1 yr 4 mosCleveland, Ohio, United States · Hybrid\n", "Leadership and Business Acumen\n", "AdvisorSparkbrook Consulting · ContractJun 2024 - Oct 2024 · 5 mosCalifornia, United States · Hybrid\n", "Strategic Planning, Leadership and +1 skill\n", "VP OperationsiPaySmart · Full-timeJun 2023 - May 2024 · 1 yrIrvine, California, United States · On-site\n", "Leadership, Business Acumen and +1 skill\n", "Vice President Of Finance And OperationsPaysafe Group · Full-timeJul 2015 - Jun 2023 · 8 yrsIrvine\n", "Strategic Planning, Leadership and +4 skills\n", "2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\n", "https://www.linkedin.com/in/eric-mclean-a522154/ 3/7Show all 8 experiences\n", "Senior Financial Analyst/ Finance Manager/ Senior FinanceManagerExperianAug 2012 - Jul 2015 · 3 yrs\n", "Strategic Planning, Leadership and +2 skills\n", "Led team of analysts in multiple offices responsible for sales forecasting andplanning for revenue and expense, sales compensation, client and contract……see more\n", "Education\n", "Show all 3 educations\n", "University of California, Irvine Division of Continuing EducationProject Management Certification, Project Management2018 - 2020\n", "Business Acumen\n", "USC Marshall School of BusinessMBA, Finance2007 - 2010\n", "Business Acumen and Budgeting\n", "Skills\n", "Show all 41 skills\n", "Private Equity\n", "2 experiences across iPaySmart and 1 other company\n", "Mergers & Acquisitions (M&A)\n", "1 endorsement\n", "Vice President Of Finance And Operations at Paysafe Group\n", "Recommendations\n", "Show all pending\n", "You haven't accepted a recommendation yet\n", "Received Given\n", "2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\n", "https://www.linkedin.com/in/eric-mclean-a522154/ 4/7Interests\n", "Show all Top Voices\n", "Top Voices Companies Groups Newsletters Schools\n", "Jeff Weiner· 2ndExecutive Chairman at LinkedIn / Founding Partner Next Play Ventures10,390,179 followers\n", "Following\n", "Mohamed El-ErianFinance, Economics Expert2,628,614 followers\n", "Following\n", "Profile language\n", "English\n", "Public profile & URL\n", "www.linkedin.com/in/eric-mclean-a522154\n", "Who your viewers also viewed Private to you\n", "Marcelo Suh· 1st\n", "Message\n", "FP&A Manager\n", "DJ Sommers · 1st\n", "Message\n", "Turning Data into Decision Ready Stories that keep the Business Aligned andMoving | Modern Payments Made Simple\n", "Afshin Yazdian· 1st\n", "Message\n", "CEO at Kurv | Modern Payments, Made Simple.\n", "Valentina Phelps· 1st\n", "Finance Leader \n", "2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\n", "https://www.linkedin.com/in/eric-mclean-a522154/ 5/7Show all\n", "Message\n", "Pete Embs· 1st\n", "Message\n", "Vice President of Financial Planning & Analysis\n", "People you may knowFrom your company\n", "Show all\n", "Taylor Treadway\n", "Connect\n", "Relationship Manager \n", "James Weiland\n", "Connect\n", "Founder and Board Member\n", "Jaimee Knight\n", "Connect\n", "Relationship Manager @ Electronic Merchant Systems\n", "Leslie Pochaukas\n", "Connect\n", "Strategic Advisor & CIO Emeritus at Electronic Merchant Systems\n", "Abigail Barrett\n", "Connect\n", "Administrative Coordinator at Electronic Merchant Systems\n", "You might likeGroups for you\n", "Governance, Risk and Compliance Management (GRC)252,267 members\n", "Join\n", "2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\n", "https://www.linkedin.com/in/eric-mclean-a522154/ 6/7About Accessibility Talent Solutions\n", "ProfessionalCommunity Policies Careers MarketingSolutions\n", "Ad Choices Advertising\n", "Sales Solutions Mobile Small Business\n", "Safety Center\n", "Questions?Visit our Help Center.\n", "Manage your accountand privacyGo to your Settings.\n", "RecommendationtransparencyLearn more aboutRecommended Content.\n", "Select Language\n", "LinkedIn Corporation © 2026\n", "Show all\n", "Microsoft Excel Users2,177,434 members\n", "Join\n", "Privacy & Terms \n", "          اﻟﻌﺮﺑﻴﺔArabic)         \n", "2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\n", "https://www.linkedin.com/in/eric-mclean-a522154/ 7/7\n" ] } ], "source": [ "print(linkedin)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "with open(\"me/summary.txt\", \"r\", encoding=\"utf-8\") as f:\n", " summary = f.read()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "from docx import Document\n", "\n", "resume = \"\"\n", "doc = Document(\"me/resume.docx\")\n", "resume = \"\\n\".join([para.text for para in doc.paragraphs])\n", "\n" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "name = \"Eric McLean\"" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "system_prompt = f\"You are acting as {name}. You are answering questions on {name}'s website, \\\n", "particularly questions related to {name}'s career, background, skills and experience. \\\n", "Your responsibility is to represent {name} for interactions on the website as faithfully as possible. \\\n", "You are given a summary of {name}'s background and LinkedIn profile which you can use to answer questions. \\\n", "Be professional and engaging, as if talking to a potential client or future employer who came across the website. \\\n", "If you don't know the answer, say so.\"\n", "\n", "system_prompt += f\"\\n\\n## Summary:\\n{summary}\\n\\n## LinkedIn Profile:\\n{linkedin}\\n\\n##Resume:\\n{resume}\\n\\n\"\n", "system_prompt += f\"With this context, please chat with the user, always staying in character as {name}.\"\n" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"You are acting as Eric McLean. You are answering questions on Eric McLean's website, particularly questions related to Eric McLean's career, background, skills and experience. Your responsibility is to represent Eric McLean for interactions on the website as faithfully as possible. You are given a summary of Eric McLean's background and LinkedIn profile which you can use to answer questions. Be professional and engaging, as if talking to a potential client or future employer who came across the website. If you don't know the answer, say so.\\n\\n## Summary:\\nEric McLean is a fintech strategist, technical builder, and creative problem-solver operating at the intersection of payments, AI, and applied analytics. Professionally, he focuses on merchant acquiring, high-risk verticals, and revenue optimization—designing data-driven frameworks for risk segmentation, pricing strategy, AML/CIP/KYC compliance, and performance measurement (e.g., ROAS, blended metrics, chargeback analytics). He thinks like a CFO but builds like an engineer, often connecting financial modeling concepts—such as Bayesian shrinkage or elasticity modeling—to real-world decision systems inside payments organizations.\\n\\nTechnically, Eric is deeply hands-on. He architects end-to-end data pipelines, web crawlers, and classification systems using Python, Postgres, vector databases, and LLM tooling. He experiments with local GPU infrastructure, fine-tuning workflows, embeddings, and AI-powered automation to solve practical business problems—from merchant clustering to product intelligence gateways. He values structured outputs, reproducible environments, and production-ready implementation.\\n\\nBeyond fintech, he channels the same intensity into creative and personal projects: designing golf performance trackers and speed programs, building interactive visual systems, crafting custom artwork, and planning ambitious family travel. He approaches ChatGPT as a collaborative technical partner—expecting rigor, iteration, and polish—while also enjoying imaginative, design-forward outputs.\\n\\nAt his core, Eric blends finance, engineering, and creativity into systems that are both analytically sound and practically deployable.\\n\\nIn spare time Eric enjoys hiking with his dog Chewie, cooking, watching movies, playing music, golf, and enjoying time with his two daughter doing whatever they are into at the time. Eric has a lot of confidence in his skills and abilities to figure out things in his career but lacks confidence in how those translate are seen to others that work above him. He is not boastful and tends to rely on results as proof.\\n\\n## LinkedIn Profile:\\nHomeMy Network Jobs MessagingNotifications Me\\n For Business Lea\\n1\\n2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\\nhttps://www.linkedin.com/in/eric-mclean-a522154/ 1/7500+\\xa0connections\\nAdd\\nprofile\\nsection\\nEnhance\\nprofile\\n\\xa0He/Him\\nFinance and Operations Leader | Business Modeling and Data Analysis| Strategy and Tactics\\nRancho Santa Margarita, California, United States\\xa0\\xa0Contact info\\nEric McLean\\xa0\\nElectronic Merchant Systems\\nUniversity of California, Irvine Division of Continuing Education\\nOpento\\nResources\\nOpen to workVP of Finance and Director of Finance rolesShow details\\nShare that you’re hiricandidates.Get started\\nAnalytics Private to you\\n57 profile viewsDiscover who's viewed your profile.\\n0 post impressionsStart a post to increase engagement.Past 7 days\\n32 search appearancesSee how often you appear in search results.\\nShow all analytics\\nAbout\\n2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\\nhttps://www.linkedin.com/in/eric-mclean-a522154/ 2/7Experience Professional and People Leader skilled in People Management, Finance,Operations, Strategy, Analytical Problem Solving, Business Modeling, Sales andOperational Planning, Sales Compensation and Territory Planning, and BusinessIntelligence.\\nActivity1,045 followers\\nCreate a post\\nYou haven’t posted yetPosts you share will be displayed here.\\nShow all activity\\nExperience\\nVP Specialized MarketsElectronic Merchant Systems · Full-timeNov 2024 - Present · 1 yr 4 mosCleveland, Ohio, United States · Hybrid\\nLeadership and Business Acumen\\nAdvisorSparkbrook Consulting · ContractJun 2024 - Oct 2024 · 5 mosCalifornia, United States · Hybrid\\nStrategic Planning, Leadership and +1 skill\\nVP OperationsiPaySmart · Full-timeJun 2023 - May 2024 · 1 yrIrvine, California, United States · On-site\\nLeadership, Business Acumen and +1 skill\\nVice President Of Finance And OperationsPaysafe Group · Full-timeJul 2015 - Jun 2023 · 8 yrsIrvine\\nStrategic Planning, Leadership and +4 skills\\n2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\\nhttps://www.linkedin.com/in/eric-mclean-a522154/ 3/7Show all 8 experiences\\nSenior Financial Analyst/ Finance Manager/ Senior FinanceManagerExperianAug 2012 - Jul 2015 · 3 yrs\\nStrategic Planning, Leadership and +2 skills\\nLed team of analysts in multiple offices responsible for sales forecasting andplanning for revenue and expense, sales compensation, client and contract……see more\\nEducation\\nShow all 3 educations\\nUniversity of California, Irvine Division of Continuing EducationProject Management Certification, Project Management2018 - 2020\\nBusiness Acumen\\nUSC Marshall School of BusinessMBA, Finance2007 - 2010\\nBusiness Acumen and Budgeting\\nSkills\\nShow all 41 skills\\nPrivate Equity\\n2 experiences across iPaySmart and 1 other company\\nMergers & Acquisitions (M&A)\\n1 endorsement\\nVice President Of Finance And Operations at Paysafe Group\\nRecommendations\\nShow all pending\\nYou haven't accepted a recommendation yet\\nReceived Given\\n2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\\nhttps://www.linkedin.com/in/eric-mclean-a522154/ 4/7Interests\\nShow all Top Voices\\nTop Voices Companies Groups Newsletters Schools\\nJeff Weiner· 2ndExecutive Chairman at LinkedIn / Founding Partner Next Play Ventures10,390,179 followers\\nFollowing\\nMohamed El-ErianFinance, Economics Expert2,628,614 followers\\nFollowing\\nProfile language\\nEnglish\\nPublic profile & URL\\nwww.linkedin.com/in/eric-mclean-a522154\\nWho your viewers also viewed Private to you\\nMarcelo Suh· 1st\\nMessage\\nFP&A Manager\\nDJ Sommers · 1st\\nMessage\\nTurning Data into Decision Ready Stories that keep the Business Aligned andMoving | Modern Payments Made Simple\\nAfshin Yazdian· 1st\\nMessage\\nCEO at Kurv | Modern Payments, Made Simple.\\nValentina Phelps· 1st\\nFinance Leader \\n2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\\nhttps://www.linkedin.com/in/eric-mclean-a522154/ 5/7Show all\\nMessage\\nPete Embs· 1st\\nMessage\\nVice President of Financial Planning & Analysis\\nPeople you may knowFrom your company\\nShow all\\nTaylor Treadway\\nConnect\\nRelationship Manager \\nJames Weiland\\nConnect\\nFounder and Board Member\\nJaimee Knight\\nConnect\\nRelationship Manager @ Electronic Merchant Systems\\nLeslie Pochaukas\\nConnect\\nStrategic Advisor & CIO Emeritus at Electronic Merchant Systems\\nAbigail Barrett\\nConnect\\nAdministrative Coordinator at Electronic Merchant Systems\\nYou might likeGroups for you\\nGovernance, Risk and Compliance Management (GRC)252,267 members\\nJoin\\n2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\\nhttps://www.linkedin.com/in/eric-mclean-a522154/ 6/7About Accessibility Talent Solutions\\nProfessionalCommunity Policies Careers MarketingSolutions\\nAd Choices Advertising\\nSales Solutions Mobile Small Business\\nSafety Center\\nQuestions?Visit our Help Center.\\nManage your accountand privacyGo to your Settings.\\nRecommendationtransparencyLearn more aboutRecommended Content.\\nSelect Language\\nLinkedIn Corporation © 2026\\nShow all\\nMicrosoft Excel Users2,177,434 members\\nJoin\\nPrivacy & Terms\\xa0\\n \\xa0 \\xa0\\xa0 \\xa0\\xa0 \\xa0اﻟﻌﺮﺑﻴﺔArabic)\\xa0 \\xa0\\xa0 \\xa0\\xa0 \\xa0\\n2/27/26, 4:30 PM (1) Eric McLean | LinkedIn\\nhttps://www.linkedin.com/in/eric-mclean-a522154/ 7/7\\n\\n##Resume:\\nEric A. McLean\\n 26 Calle Del Rio, Rancho Santa Margarita, CA 92688 • (949) 973-6585 • uscemclean@gmail.com\\n\\n\\n\\nEDUCATION\\n\\nUniversity of California Irvine, Continuing Education\\tIrvine, CA\\nProject Management Certification\\t2020\\n\\nUniversity of Southern California, Marshall School of Business\\tLos Angeles, CA\\nMaster of Business Administration\\t2010\\n\\nBerklee College of Music\\tBoston, MA\\nBachelor of Arts, Music Synthesis\\t2004\\n\\n\\n\\n\\t\\nEXPERIENCE\\n\\nKurvPay \\tCleveland, OH (Remote Position)\\nVP Specialized Markets\\tNov 2024 – Present\\n\\nResponsible for business development and management of specialized business unit focusing on clients operating in direct marketing verticals. \\nGenerated over $2m in EBITDA in first year in newly formed channel through personal business development efforts with a monthly run rate currently at $4m annually at 25% higher margins than rest of business. \\nDesigned and built decision and monitoring tools utilizing complex SQL logic to aid in overall business portfolio risk, economics and pricing tools, investor relations support, additional segmentation performance views, and partner management and support.\\nCreated internal and external partner review packages to provide end-to-end views of partner impacts on sales, economic impacts including losses, risk, pricing, and portfolio composition aiding partnerships in improving LTV of campaigns, managing CAC for their portfolios, understanding ROAS for campaign spending, and identifying areas of opportunity for optimization of risk and recurring transaction erosion.\\nDelivered risk-based pricing tools and recommendations for overall portfolio based on vertical segments, risk profiles, and economic impacts.\\nDirected decisions and policies for underwriting and risk for managed portfolio creating agreed upon structured experiences for partners whilst mitigating loss risk.\\nDesigned and built AI/machine learning tools to aid in identification of linked processing accounts to help mitigate fraud and credit losses.\\nConstructed new KPIs and reporting to bridge regulatory reporting changes and provide early indicators for credit and fraud risk.\\n\\n\\n\\nSparkBrook \\tIrvine, CA\\nOwner\\tJuly 2024 – Nov 2024\\n\\nManagement consulting focused on financial forecasting and analysis, market segmentation and pricing analytics, market and sales optimization, organizational restructuring, regulatory and operational compliance, and process and system improvements. \\nDrove remediation of pricing execution issues generating $6m+ in risk mitigation. \\nProvided insights and strategies eliminating over $7m in client segment risk.\\nCreated product stories, partnership reviews, business cases and project plans for new product implementations and operational programs. \\nConstructed full P&L business forecasts and long-term plans to optimize sales, margin, and risk for restructuring needs.\\n\\niPaySmart \\tIrvine, CA\\nVP of Operations\\tJun 2023 – May 2024\\n\\nOperational leadership for an early-stage, private equity-backed payments company. Oversight over organizational structure engineering, delivery review and process implementation, control planning and implementation, operational compliance, pricing strategies, partnership engagement, client support, and management and investor reviews. \\nDrove compliance review and remediation efforts for financial and industry regulation requirements through policy and procedure construction, project management for audits, technology changes and builds, and legal reviews. \\nOversaw new product deliveries including partner management, client implementations, and support. \\nCreated product stories, technical documentation, delivery plans, user acceptance testing, and client presentation materials. \\nDirected Salesforce implementation for new sales management and operational restructuring. \\nImplemented new pricing tools and client performance analytics leading to improved margin insights for contract negotiations and revenue and cost assurance actions to mitigate losses. \\nBuilt and reviewed materials for board and investor meetings and presentations.\\n\\nPaysafe Group \\tIrvine, CA\\nVP of Finance and Operations\\t2015- Jun 2023\\n\\nOversight and development of financial planning and analysis and business unit operations including forecasting and planning, investor relations support, incentive design and execution, financial operations, agent and merchant experience, quality assurance, business analytics, and revenue and cost assurance functions for Payment Processing division of Paysafe Group.\\n\\nLed team of finance team directors, managers, and analysts with a total organizational chart of 15 headcount responsible for FP&A, financial operations, and global reporting consolidation for Payment Processing division delivering over $100m in EBITDA on annual revenues of over $650m.\\nManaged team of 70 operations and finance professionals located in Sofia, the UK, Canada, Mexico, and the US.\\nNamed director (CFO and COO) responsible for strategy, finance, operations, analytics, product prioritization, and controllership for business unit delivering a 10% CAGR on margin from 2015-2022 responsible for over 25% of group EBITDA delivery. \\nDrove SOX and controllership activities for business unit delivering $100M+ in annual revenue for audit, month-end close, financial disclosures, and financial operations in preparation of NASDAQ listing.\\nManaged investor relations support for Payment Processing division supporting annual reporting, capital markets presentations, and analyst reviews leading to listing on the LSE and private equity sale to CVC and Blackstone.\\nImproved employee engagement scores 10%+ through coaching, restructuring, and cultural initiatives.\\nImplemented pricing and cost assurance programs delivering over $25m in recurring annual margin accretion.\\nDeveloped and executed yearly Annual Operating Plans for ten global business units responsible for delivering $150m+ in EBITDA.\\nAided in the execution of over $500m of acquisitions for the Payment Processing division through forecast and profitability modeling and cost and revenue synergies.\\n\\n\\nExperian North America Credit Services\\tCosta Mesa, CA\\nSr. Manager, Sales Finance\\t\\t\\t\\t\\t\\t\\t\\t\\t 2012 – 2015\\n\\nLed team of analysts in multiple offices responsible for sales forecasting and planning for revenue and expense, sales compensation, client and contract analytics, product and industry analysis, and finance and sales system administration for largest sales organization in Experian.\\n\\nDeveloped strategic operating plans and annual budgets for CSDA sales organization with annual revenue responsibility of $980M and an expense budget of $77M. \\nDesigned, constructed, and implemented database driven solutions for sales performance tracking, revenue driver analysis and forecasting, and process improvement using MS Access/SQL and MS Excel for direct team and business unit partners in a highly matrixed organization.\\nConstructed pricing strategies and ROI modeling for large client contracts. Developed pricing structures for sales contracts contributing over $500 million in total contract value.\\nBuilt modeling structures for sales territory planning and risk and opportunity identification to optimize continued profitable growth and competitive strategy.\\nDirected process improvement projects to enhance organizational collaboration and streamline operational administrative processes creating a 50% reduction in time required for the creation of over 1k monthly reports and forecasts.\\n\\n\\nCox Communications, Inc.\\tRancho Santa Margarita/San Diego, CA\\nRegulatory Analyst/Business Intelligence Analyst/Sr Financial Analyst/Manager Sales Operations \\t 2004 – 2012\\n\\nLed team that developed and managed compensation plans and targets for nine core sales channels with 300+ sales\\nreps responsible for over $900M in annual revenues.\\nConstructed analytical models for seasonal sales forecasts, queue management and call forecasts, customer\\ndiscounting, return on investment of various internal initiatives, and monthly quota setting and incentive plan\\ndesign.\\nStrategic planning and execution of marketing, operations, and sales efforts related to incentives, call routing\\noptimization, vendor management, consumer targeting design and execution, retail staffing and operations, system\\nimplementation and design, employee onboarding and training, discount strategies, pricing, process and metric\\nstandardization, and product implementations and exits.\\nEngineered consolidation of California sales operations, sales force, and financial operations including restructuring\\nand relocation, budgeting and planning, compensation plans and analytics, reporting and CRM systems, consumer\\ntraffic routing, and sales communications.\\nForecasted and managed capital projects, transfer pricing, revenues, and direct expenses.\\nDeveloped decision support systems and made strategic recommendations for senior management regarding\\noperational efficiency and financial performance objectives helping lead to double digit OCF growth.\\nDevelopment and management of local reporting infrastructure primarily using MS SQL Server and Reporting\\nServices.\\nConducted business analysis and managed projects for system development architecture and release of third party or\\ncompany developed enterprise applications.\\nLed reporting design and implementation for predictive network degradation and failure triggering system that\\nreceived Enterprise Vision Award.\\nDesigned reporting and audit tools leading to $2m+ in government subsidies for Cox California.\\n\\n\\nWith this context, please chat with the user, always staying in character as Eric McLean.\"" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "system_prompt" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "def chat(message, history):\n", " messages = [{\"role\": \"system\", \"content\": system_prompt}] + history + [{\"role\": \"user\", \"content\": message}]\n", " response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n", " return response.choices[0].message.content" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Special note for people not using OpenAI\n", "\n", "Some providers, like Groq, might give an error when you send your second message in the chat.\n", "\n", "This is because Gradio shoves some extra fields into the history object. OpenAI doesn't mind; but some other models complain.\n", "\n", "If this happens, the solution is to add this first line to the chat() function above. It cleans up the history variable:\n", "\n", "```python\n", "history = [{\"role\": h[\"role\"], \"content\": h[\"content\"]} for h in history]\n", "```\n", "\n", "You may need to add this in other chat() callback functions in the future, too." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "* Running on local URL: http://127.0.0.1:7861\n", "* To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "grchat = gr.ChatInterface(chat, type=\"messages\")\n", "grchat.launch()\n" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Closing server running on port: 7861\n" ] } ], "source": [ "grchat.close()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## A lot is about to happen...\n", "\n", "1. Be able to ask an LLM to evaluate an answer\n", "2. Be able to rerun if the answer fails evaluation\n", "3. Put this together into 1 workflow\n", "\n", "All without any Agentic framework!" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "# Create a Pydantic model for the Evaluation\n", "\n", "from pydantic import BaseModel\n", "\n", "class Evaluation(BaseModel):\n", " is_acceptable: bool\n", " feedback: str\n" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "evaluator_system_prompt = f\"You are an evaluator that decides whether a response to a question is acceptable. \\\n", "You are provided with a conversation between a User and an Agent. Your task is to decide whether the Agent's latest response is acceptable quality. \\\n", "The Agent is playing the role of {name} and is representing {name} on their website. \\\n", "The Agent has been instructed to be professional and engaging, as if talking to a potential client or future employer who came across the website. \\\n", "The Agent has been provided with context on {name} in the form of their summary and LinkedIn details. Here's the information:\"\n", "\n", "evaluator_system_prompt += f\"\\n\\n## Summary:\\n{summary}\\n\\n## LinkedIn Profile:\\n{linkedin}\\n\\n\"\n", "evaluator_system_prompt += f\"With this context, please evaluate the latest response, replying with whether the response is acceptable and your feedback.\"" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "def evaluator_user_prompt(reply, message, history):\n", " user_prompt = f\"Here's the conversation between the User and the Agent: \\n\\n{history}\\n\\n\"\n", " user_prompt += f\"Here's the latest message from the User: \\n\\n{message}\\n\\n\"\n", " user_prompt += f\"Here's the latest response from the Agent: \\n\\n{reply}\\n\\n\"\n", " user_prompt += \"Please evaluate the response, replying with whether it is acceptable and your feedback.\"\n", " return user_prompt" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "import os\n", "gemini = OpenAI(\n", " api_key=os.getenv(\"GOOGLE_API_KEY\"), \n", " base_url=\"https://generativelanguage.googleapis.com/v1beta/openai/\"\n", ")" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "def evaluate(reply, message, history) -> Evaluation:\n", "\n", " messages = [{\"role\": \"system\", \"content\": evaluator_system_prompt}] + [{\"role\": \"user\", \"content\": evaluator_user_prompt(reply, message, history)}]\n", " response = gemini.beta.chat.completions.parse(model=\"gemini-2.0-flash\", messages=messages, response_format=Evaluation)\n", " return response.choices[0].message.parsed" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "messages = [{\"role\": \"system\", \"content\": system_prompt}] + [{\"role\": \"user\", \"content\": \"do you hold a patent?\"}]\n", "response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n", "reply = response.choices[0].message.content" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "reply" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evaluate(reply, \"do you hold a patent?\", messages[:1])" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "def rerun(reply, message, history, feedback):\n", " updated_system_prompt = system_prompt + \"\\n\\n## Previous answer rejected\\nYou just tried to reply, but the quality control rejected your reply\\n\"\n", " updated_system_prompt += f\"## Your attempted answer:\\n{reply}\\n\\n\"\n", " updated_system_prompt += f\"## Reason for rejection:\\n{feedback}\\n\\n\"\n", " messages = [{\"role\": \"system\", \"content\": updated_system_prompt}] + history + [{\"role\": \"user\", \"content\": message}]\n", " response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n", " return response.choices[0].message.content" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "def chat(message, history):\n", " if \"patent\" in message:\n", " system = system_prompt + \"\\n\\nEverything in your reply needs to be in pig latin - \\\n", " it is mandatory that you respond only and entirely in pig latin\"\n", " else:\n", " system = system_prompt\n", " messages = [{\"role\": \"system\", \"content\": system}] + history + [{\"role\": \"user\", \"content\": message}]\n", " response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n", " reply =response.choices[0].message.content\n", "\n", " evaluation = evaluate(reply, message, history)\n", " \n", " if evaluation.is_acceptable:\n", " print(\"Passed evaluation - returning reply\")\n", " else:\n", " print(\"Failed evaluation - retrying\")\n", " print(evaluation.feedback)\n", " reply = rerun(reply, message, history, evaluation.feedback) \n", " return reply" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "gr.ChatInterface(chat, type=\"messages\").launch()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": ".venv", "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.11" } }, "nbformat": 4, "nbformat_minor": 2 }