{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Welcome to the Second Lab - Week 1, Day 3\n", "\n", "Today we will work with lots of models! This is a way to get comfortable with APIs." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", "

Important point - please read

\n", " The way I collaborate with you may be different to other courses you've taken. I prefer not to type code while you watch. Rather, I execute Jupyter Labs, like this, and give you an intuition for what's going on. My suggestion is that you carefully execute this yourself, after watching the lecture. Add print statements to understand what's going on, and then come up with your own variations.

If you have time, I'd love it if you submit a PR for changes in the community_contributions folder - instructions in the resources. Also, if you have a Github account, use this to showcase your variations. Not only is this essential practice, but it demonstrates your skills to others, including perhaps future clients or employers...\n", "
\n", "
" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# Start with imports - ask ChatGPT to explain any package that you don't know\n", "\n", "import os\n", "import json\n", "from dotenv import load_dotenv\n", "from openai import OpenAI\n", "from anthropic import Anthropic\n", "from IPython.display import Markdown, display" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Always remember to do this!\n", "load_dotenv(override=True)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "OpenAI API Key exists and begins sk-proj-\n", "Anthropic API Key not set (and this is optional)\n", "Google API Key not set (and this is optional)\n", "DeepSeek API Key not set (and this is optional)\n", "Groq API Key not set (and this is optional)\n" ] } ], "source": [ "# Print the key prefixes to help with any debugging\n", "\n", "openai_api_key = os.getenv('OPENAI_API_KEY')\n", "anthropic_api_key = os.getenv('ANTHROPIC_API_KEY')\n", "google_api_key = os.getenv('GOOGLE_API_KEY')\n", "deepseek_api_key = os.getenv('DEEPSEEK_API_KEY')\n", "groq_api_key = os.getenv('GROQ_API_KEY')\n", "\n", "if openai_api_key:\n", " print(f\"OpenAI API Key exists and begins {openai_api_key[:8]}\")\n", "else:\n", " print(\"OpenAI API Key not set\")\n", " \n", "if anthropic_api_key:\n", " print(f\"Anthropic API Key exists and begins {anthropic_api_key[:7]}\")\n", "else:\n", " print(\"Anthropic API Key not set (and this is optional)\")\n", "\n", "if google_api_key:\n", " print(f\"Google API Key exists and begins {google_api_key[:2]}\")\n", "else:\n", " print(\"Google API Key not set (and this is optional)\")\n", "\n", "if deepseek_api_key:\n", " print(f\"DeepSeek API Key exists and begins {deepseek_api_key[:3]}\")\n", "else:\n", " print(\"DeepSeek API Key not set (and this is optional)\")\n", "\n", "if groq_api_key:\n", " print(f\"Groq API Key exists and begins {groq_api_key[:4]}\")\n", "else:\n", " print(\"Groq API Key not set (and this is optional)\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "request = \"Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. \"\n", "request += \"Answer only with the question, no explanation.\"\n", "messages = [{\"role\": \"user\", \"content\": request}]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'role': 'user',\n", " 'content': 'Please come up with a challenging, nuanced question that I can ask a number of LLMs to evaluate their intelligence. Answer only with the question, no explanation.'}]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "messages" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "You are an independent advisor to the mayor of Port Meridia (population 420,000), a coastal city facing (a) a projected 1.2 m sea-level rise and more intense storm surge over 30 years, (b) 18% unemployment concentrated in neighborhoods adjacent to a large chemical-manufacturing plant that provides 25% of the city’s jobs but routinely discharges pollutants, and (c) a municipal budget that can increase spending by up to 30% over five years only if taxes are raised or federal grants are secured. Devise a detailed, politically feasible 10-year plan that minimizes displacement, protects the city from flooding, phases out the most harmful pollution, and creates inclusive economic opportunity; for each major action state the rationale, estimated cost and funding sources (with realistic grant/tax assumptions), timeline, key stakeholders and likely objections, measurable success metrics, and the three most likely failure modes with specific mitigations; provide probability estimates with confidence intervals that the plan will achieve net positive outcomes for both environmental justice and economic stability within 10 years; conclude with a 150-word executive summary and list all material assumptions you made.\n" ] } ], "source": [ "openai = OpenAI()\n", "response = openai.chat.completions.create(\n", " model=\"gpt-5-mini\",\n", " messages=messages,\n", ")\n", "question = response.choices[0].message.content\n", "print(question)\n" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "competitors = []\n", "answers = []\n", "messages = [{\"role\": \"user\", \"content\": question}]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Note - update since the videos\n", "\n", "I've updated the model names to use the latest models below, like GPT 5 and Claude Sonnet 4.5. It's worth noting that these models can be quite slow - like 1-2 minutes - but they do a great job! Feel free to switch them for faster models if you'd prefer, like the ones I use in the video." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "Executive framing\n", "Port Meridia faces three intertwined challenges: (1) a 1.2 m sea‑level rise with intensified storm surge over 30 years; (2) an 18% unemployment gap concentrated in neighborhoods near a large chemical plant that provides 25% of city jobs but cumulatively degrades air/water quality; (3) a municipal budget capable of up to a 30% spending increase over five years only if taxes rise or federal grants are secured. This plan proposals a coordinated, 10‑year, financially feasible program that minimizes displacement, shields people from flood risk, reduces the most harmful pollution, and creates inclusive economic opportunity. It relies on a mix of federal grants, bonds, private partnerships, and targeted local revenue, with strong community engagement and accountability.\n", "\n", "Ten-year plan at a glance (major actions)\n", "- Action A: Build integrated flood protection for critical assets and vulnerable neighborhoods; expand natural infrastructure; elevate essential facilities; improve drainage and evacuation routes.\n", "- Action B: Accelerate pollution reduction and a just transition for the plant’s workers; upgrade controls; monitor air/water quality; plan relocation/repurposing if needed; ensure community benefits.\n", "- Action C: Deploy inclusive economic development and workforce programs; prioritize local hiring on city projects; diversify the economy toward clean industries and port/logistics.\n", "- Action D: Preserve and expand affordable housing; prevent displacement; use inclusionary zoning, community land trusts, and buyout/relocation supports where risk is highest.\n", "- Action E: Modernize transportation and critical infrastructure to withstand flooding, reduce emissions, and connect neighborhoods to opportunity.\n", "- Action F: Strengthen governance, transparency, and EJ accountability; establish a standing Climate and Justice Authority with community representation.\n", "- Action G: Create a robust, diversified financing strategy; blend federal grants, resilience bonds, public-private partnerships, and targeted local revenue; secure a five‑to‑ten year funding pipeline.\n", "- Action H: Continuous monitoring, evaluation, and adaptive management; deploy independent metrics, public dashboards, and annual reporting to guide adjustments.\n", "\n", "Detailed major actions (with required fields)\n", "\n", "Action A. Flood protection for high‑risk areas and critical infrastructure\n", "- Rationale: 1.2 m sea‑level rise and stronger surges threaten hospitals, water treatment, schools, and large employers; uncontrolled flooding creates displacement risk and undermines the tax base.\n", "- Major components:\n", " - Engineering: hybrid flood defenses (seawalls, surge barriers, tidal gates) sized for design storms and projected sea‑level rise.\n", " - Natural infrastructure: living shorelines, wetlands restoration, dune systems, green streets, bioswales.\n", " - Infrastructure retrofits: flood-proofing for hospitals, water plant, emergency operations center, police/fire stations; elevate critical electrical/IT assets.\n", " - Evacuation and resilience routing: dedicated emergency corridors, upgraded pump stations, backflow prevention.\n", "- Estimated cost and funding sources:\n", " - Cost: $2.0–3.5 billion over 10 years (phased).\n", " - Funding: federal BRIC/NOAA grants, HUD CDBG‑Mitigation, EPA grants, state resilience funds; municipal general obligation bonds; private‑public partnerships; potential modest climate resilience tax or fee with sunset after the first 6–8 years.\n", "- Timeline:\n", " - Years 1–3: design approvals, environmental reviews, early procurement for critical facilities.\n", " - Years 2–6: primary construction of protection for top-priority zones and facilities; begin natural infrastructure projects.\n", " - Years 6–10: expand protections to remaining areas; retrofit additional facilities; optimize operations.\n", "- Key stakeholders and objections:\n", " - Stakeholders: residents in flood zones, hospitals, school districts, port operators, small business associations, environmental groups.\n", " - Likely objections: high up-front cost, potential displacement risks during construction, competing budget needs.\n", "- Measurable success metrics:\n", " - Reduction in modeled flood depths for critical facilities (e.g., >50% in protected zones).\n", " - Percent of critical facilities shielded from projected flood events.\n", " - Kilometers of living shoreline and miles of improved drainage; evacuation time improvements; insured loss reductions.\n", "- Three likely failure modes and mitigations:\n", " - Funding shortfalls or delays: implement phased design with clear milestones; establish reserve contingencies; secure multi-year commitments from federal/state sources.\n", " - Construction disruption in neighborhoods: use tight project management, community liaisons, temporary relocations with stipends; nonessential work scheduled in off-peak seasons.\n", " - Underestimation of sea‑level rise risk: adopt adaptive design with modular extensions and flexible permitting; est. annual review of risk data and design tweaks.\n", "- Confidence/uncertainty: Moderate to high confidence in phased delivery if federal/state funds materialize and procurement is aggressive.\n", "\n", "Action B. Pollution reduction and just transition for the plant\n", "- Rationale: 18% unemployment near a plant that provides 25% of city jobs but incurs pollutant discharges; local health and climate benefits align with EJ goals; long-term local prosperity requires cleaner industry and worker retraining.\n", "- Major components:\n", " - Emissions and discharge controls: upgraded scrubbers, filtration, smokestack improvements, process modifications to reduce hazardous byproducts.\n", " - Regulatory tightening with milestones: enforce pollutant caps; continuous air and water monitoring with public dashboards.\n", " - Transition planning for workers: career counseling, retraining in higher‑skill clean‑tech, port/logistics, healthcare, or energy sectors; wage‑support programs; relocation or redeployment assistance if plant phase‑out or relocation occurs.\n", " - Community benefits agreements (CBAs): job locality targets, local procurement, and long‑term community investment commitments.\n", "- Estimated cost and funding sources:\n", " - Cost: $0.5–1.0 billion for plant upgrades and process changes; $50–120 million for workforce retraining; $200–400 million for transition/relocation supports if needed.\n", " - Funding: EPA/state environmental grants; USDOT/EDA economic development funds for clean‑tech transitions; city bonds; plant capital investments; philanthropic and private capital; potential state green‑jobs grants.\n", "- Timeline:\n", " - Years 1–3: design and begin plant upgrades; establish EJ oversight and CBAs; initiate retraining programs.\n", " - Years 3–7: complete major plant upgrades; scale workforce transitions; monitor air/water metrics and health indicators.\n", " - Years 6–10: evaluate ongoing plant operations; implement relocation/repurposing if warranted; sustain community investments.\n", "- Key stakeholders and objections:\n", " - Stakeholders: plant management, workers and unions, nearby residents, independent monitors, environmental groups.\n", " - Likely objections: plant cost burden, risk of job losses, skepticism about long-term benefits; concerns about compliance burden and reliability of new processes.\n", "- Measurable success metrics:\n", " - Pollutant reductions (tons/year of key pollutants) and compliance with stricter caps.\n", " - Air quality indices in nearby neighborhoods; water quality metrics around discharge points.\n", " - Number of workers retrained and placed in higher‑wage jobs; retained employment in the new sector; CBAs payout and local procurement share.\n", " - Progress toward a cleaner, diversified industrial base in the city.\n", "- Three likely failure modes and mitigations:\n", " - Plant resistance to upgrades or relocation: use binding performance milestones, enforceable penalties for noncompliance, and incentive packages tied to emissions reductions; align with long‑term city economic diversification plans.\n", " - Inadequate worker retraining outcomes: design continuous, sector‑wide retraining with employer partners; offer portable credentials; provide wage‑top‑ups and relocation stipends.\n", " - Cost overruns or delayed permits: reserve contingency funds; adopt modular upgrades; parallel permitting tracks and fast‑tracking where safe.\n", "- Confidence/uncertainty: Moderate confidence; depends on plant cooperation and federal/state grant flows.\n", "\n", "Action C. Inclusive economic development and workforce expansion\n", "- Rationale: Unemployment concentrated in EJ neighborhoods; build an economy that absorbs workers from the plant and other sectors; reduce vulnerability to single-plant shocks.\n", "- Major components:\n", " - Local hiring and supplier requirements: target minimum local hire and procurement share on city projects and major private developments.\n", " - Workforce development: sector partnerships (clean energy, logistics, healthcare, construction, water management); apprenticeships and placement guarantees; industry-recognized credentials.\n", " - Small business and entrepreneurship support: microgrants, credit facilities, technical assistance, access to procurement networks; business incubators in EJ neighborhoods.\n", " - Green economy growth: accelerate training for port-related jobs, climate adaptation services, energy efficiency retrofits for homes/commercial buildings.\n", "- Estimated cost and funding sources:\n", " - Cost: $150–350 million in direct program funding over 10 years (plus leverage from private partners).\n", " - Funding: HUD workforce and economic mobility grants; EDA regional economic development grants; state workforce funds; city general funds; philanthropic and corporate philanthropy; small business loan funds (revolving loan fund).\n", "- Timeline:\n", " - Years 1–2: establish partnerships, design curricula, deploy initial apprenticeship programs.\n", " - Years 2–5: scale apprenticeships and job placement; expand incubator and microgrant programs.\n", " - Years 5–10: broaden sector coverage; evaluate and refine local hiring targets; measure displacement dynamics and wage gains.\n", "- Key stakeholders and objections:\n", " - Stakeholders: local workers and unions, community organizations, employers, higher education institutions, small business associations.\n", " - Likely objections: concerns about program effectiveness, budget competition with other priorities, fears of preferential hiring; ensure transparency and objective metrics.\n", "- Measurable success metrics:\n", " - Number of residents trained and placed; unemployment rate reduction in targeted neighborhoods (goal: cut 18% to ≤9% by year 10); number of local contracts awarded; number of new businesses started; wage growth and retention rates; miles of green infrastructure built with job impact.\n", "- Three failure modes and mitigations:\n", " - Skills mismatch: establish real-time labor market data, employer advisory boards, and flexible credentialing; adjust curricula and pathways quickly.\n", " - Underfunding and program fragmentation: create a centralized repository of funding streams; multi‑agency coordination to avoid duplication; regular audits.\n", " - Low job uptake due to relocation risk or stigma: combine with housing protections and neighborhood revitalization to attract workers; provide relocation stipends and housing subsidies if needed.\n", "- Confidence/uncertainty: Moderate to high confidence; success hinges on sustained employer engagement and funding.\n", "\n", "Action D. Housing affordability, displacement prevention, and resilience\n", "- Rationale: Infrastructure investment raises displacement risk if housing costs rise; pursue a stable, equitable housing stock near job hubs.\n", "- Major components:\n", " - Affordable housing production and preservation: use income‑restricted units, tax credits, inclusionary zoning for new developments, and preservation of existing affordable units.\n", " - Anti‑displacement measures: tenant protections, rent stabilization for vulnerable periods, right to counsel, relocation assistance.\n", " - Community land trusts and deed restrictions: preserve long‑term affordability and community control near flood‑prone areas.\n", " - Acquisition and rehabilitation of at‑risk housing: preemptive buyouts in highly flood‑prone zones, with resident supports and relocation pathways.\n", "- Estimated cost and funding sources:\n", " - Cost: $300–600 million over 10 years (capital plus subsidy layers for preservation; ongoing operating subsidies).\n", " - Funding: federal HOME and CDBG funds; low‑income housing tax credits; state housing funds; bonds; local philanthropy; private investment; rural/state affordable housing set‑asides.\n", "- Timeline:\n", " - Years 1–3: policy design; preliminary acquisitions; preservation commitments; set‑aside funds.\n", " - Years 3–6: commence large‑volume affordable housing development; implement anti‑displacement protections citywide.\n", " - Years 6–10: complete significant housing stock; monitor displacement metrics; scale up ongoing preservation.\n", "- Key stakeholders and objections:\n", " - Stakeholders: residents in affected neighborhoods, tenants’ associations, housing developers, landlords, lenders, community groups.\n", " - Likely objections: concerns about density, neighborhood change, impact fees, and regulatory burdens; address with clear community input and equitable distribution of benefits.\n", "- Measurable success metrics:\n", " - Number of affordable units created/preserved; change in median rents in target areas; displacement incidence; time‑to‑housing of affected residents; number of residents assisted with relocation.\n", "- Three failure modes and mitigations:\n", " - Funding gaps and political opposition: pursue multi‑source funding and broad coalition advocacy; implement phased delivery with milestones.\n", " - Delays due to approvals or construction: expedite with pre‑approved zoning pathways; fast‑track permits for affordable housing; ensure community advisory groups.\n", " - Gentrification pressures: enforce inclusionary policies; protect existing tenants; ensure long‑term affordability after initial 10 years.\n", "- Confidence/uncertainty: High confidence if funding and developer commitments align; risk if housing markets tighten or opposition intensifies.\n", "\n", "Action E. Transportation and infrastructure modernization\n", "- Rationale: Connectivity to jobs and evacuation routes; reduce emissions; improve resilience and economic competitiveness.\n", "- Major components:\n", " - Transit upgrades: electrified buses, expanded routes to EJ neighborhoods, resilience‑minded transit hubs.\n", " - Road and drainage improvements: flood‑resilient drainage networks; elevated road segments where necessary; arterial upgrades for evacuation.\n", " - Port and logistics improvements: climate‑resilient port access, pollution controls at port facilities, security and reliability upgrades.\n", " - Multi‑modal corridors and safety: bike/pedestrian networks; safe routes to schools; last‑mile connectivity to housing and jobs.\n", "- Estimated cost and funding sources:\n", " - Cost: $0.8–1.5 billion over 10 years.\n", " - Funding: federal DOT grants (FTA, TIGER/BUILD), state transportation funds, bonds, public‑private partnerships for port facilities, and EV fleet subsidies.\n", "- Timeline:\n", " - Years 1–3: master plan approvals, procurement for initial electrified fleet, design improvements.\n", " - Years 2–6: construction of protected transit corridors, drainage upgrades, and selected port access improvements.\n", " - Years 6–10: completion of major corridors, full fleet conversion, continuous optimization.\n", "- Key stakeholders and objections:\n", " - Stakeholders: commuters, transit riders, port users, freight businesses, environmental groups.\n", " - Likely objections: tolls or user fees; concerns about construction disruption and route changes; property access and eminent domain concerns.\n", "- Measurable success metrics:\n", " - Transit electrification rate; miles of resilient drainage; commute times; port throughput; reduction in flood‑related incidents impacting transport.\n", "- Three failure modes and mitigations:\n", " - Funding or procurement delays: use design‑build contracts to shorten timelines; secure advance funding from multiple sources.\n", " - Community resistance to tolls or fees: offset by subsidies for low‑income residents and transparent benefit reporting.\n", " - Disruption to trade during construction: provide phasing, off‑hours work when possible, and industry liaison groups.\n", "- Confidence/uncertainty: Moderate; depends on federal/state support and port traffic demands.\n", "\n", "Action F. Governance, transparency, equity oversight\n", "- Rationale: Political feasibility and legitimacy require robust accountability and direct community involvement.\n", "- Major components:\n", " - Establish Port Meridia Climate and Justice Authority (PMAJ) with equitable representation from EJ communities, labor, business, housing, environmental groups.\n", " - Public dashboards: budget, project progress, environmental indicators, health outcomes.\n", " - Independent evaluation: annual third‑party audits; annual progress reports; citizen‑initiated inquiries.\n", "- Estimated cost and funding sources:\n", " - Cost: $20–60 million over 10 years (administrative, staff, and independent monitoring).\n", " - Funding: city general fund; grants for governance innovation; philanthropy.\n", "- Timeline:\n", " - Year 1: chartering, appointment processes, initial reporting framework.\n", " - Years 1–10: ongoing governance operations, annual public reporting and independent audits.\n", "- Key stakeholders and objections:\n", " - Stakeholders: general public, EJ communities, developers, employers.\n", " - Likely objections: concerns about governance complexity, bureaucratic overhead, potential capture by interest groups.\n", "- Measurable success metrics:\n", " - Timeliness and completeness of annual reports; community engagement metrics; rate of project approvals on schedule; reduction in disputes.\n", "- Failure modes and mitigations:\n", " - Governance gridlock: establish clear decision–making rules, time‑boxed advisory cycles, and an ombudsperson.\n", " - Perceived inequities in participation: require representative geographic and demographic quotas; rotate seats to ensure broad representation.\n", "- Confidence/uncertainty: High; governance structures are implementable and essential for legitimacy.\n", "\n", "Action G. Financing strategy and revenue plan\n", "- Rationale: A credible funding mix is essential to unlock the 30% budget uplift without destabilizing finances.\n", "- Major components:\n", " - Federal/state grants: maximize eligibility for HUD resilience and EJ grants, NOAA, EPA, EDA programs; unfunded liability mitigation through grants.\n", " - Resilience bonds: issue municipal bonds tied to climate resilience outcomes; interest rates and issuance terms guided by rating agencies.\n", " - Public-private partnerships: leverage private capital for targeted infrastructure (e.g., port, transit, water treatment improvements) with performance‑based contracts.\n", " - Local revenue tools: phased climate resilience tax or fee; targeted incentives to attract new businesses; reallocation of existing departmental budgets with efficiency measures.\n", " - Insurance and risk transfer: leverage reinsurance for flood risk portfolios to stabilize long‑term costs.\n", "- Estimated cost and funding sources:\n", " - Debt and grants combination to fund $2.0–4.0 billion in capital needs across actions A–E over 10 years.\n", "- Timeline:\n", " - Years 1–2: secure grant commitments; issue initial resilience bonds; finalize tax/fee framework with sunset provisions.\n", " - Years 2–10: issue subsequent bonds as projects commence; monitor revenue streams and adjust as needed.\n", "- Stakeholders and objections:\n", " - Stakeholders: taxpayers, bond markets, lenders, state/federal agencies, businesses.\n", " - Likely objections: tax increases or new fees; concerns about debt burden and intergenerational equity.\n", "- Measurable success metrics:\n", " - Amount of funding secured; share of projects funded via grants vs. debt; debt service coverage ratios; timely allocation of funds; number of projects completed per year.\n", "- Three failure modes and mitigations:\n", " - Grant shortfalls or higher borrowing costs: diversify funding; maintain strong fiscal reserves; pre‑commitment of multiple finance sources.\n", " - Public opposition to taxes/fees: deploy clear ROI reporting, sunset clauses, and equity protections in the design.\n", " - Financing delays due to market conditions: pre‑arranged credit facilities; scalable, modular project phasing.\n", "- Confidence/uncertainty: Moderate; highly contingent on external funding markets and political feasibility of local revenue tools.\n", "\n", "Action H. Monitoring, evaluation, and adaptive management\n", "- Rationale: To ensure progress toward environmental justice and economic stability, with the ability to course‑correct.\n", "- Major components:\n", " - Data and dashboards: flood risk reductions, air/water quality metrics, housing affordability and displacement indicators, employment/sectors metrics, community satisfaction.\n", " - Independent review: third‑party evaluators; annual performance reports; mid‑term and end‑term independent reviews.\n", " - Adaptive management: annual reallocation of funds to high‑performing programs; course corrections for underperforming actions.\n", "- Estimated cost and funding sources:\n", " - Cost: $10–30 million over 10 years for data systems, staff, and evaluation contracts.\n", "- Timeline:\n", " - Ongoing from Year 1 onward; annual reviews and adjustments.\n", "- Stakeholders and objections:\n", " - Stakeholders: residents, EJ communities, city departments, funding partners.\n", " - Likely objections: data transparency concerns; perceived bureaucratic overhead.\n", "- Measurable success metrics:\n", " - Compliance with EJ benchmarks; improvements in housing affordability indices; unemployment reductions; flood protection performance metrics; pollution reductions; public satisfaction scores.\n", "- Failure modes and mitigations:\n", " - Data gaps: implement standardized data collection; ensure interoperability; train staff.\n", " - Misaligned incentives: align performance metrics with equity goals; tie funding to measurable outcomes.\n", "- Confidence/uncertainty: High; data‑driven loop is essential to success and reduces political risk.\n", "\n", "Projected timeline (summary)\n", "- Years 1–3: finalize designs, secure initial funding, begin most critical flood protection work, commence plant upgrades, launch workforce programs, establish PMAJ, begin affordable housing preservation, initiate transit and port improvements.\n", "- Years 3–6: scale major construction and upgrades; advance plant transition; expand housing and local hiring programs; deploy first rounds of resilience bonds; implement governance and EJ dashboards.\n", "- Years 7–10: complete remaining infrastructure protections; solidify a diversified economy; sustain workforce and housing programs; evaluate and adapt programs; ensure long‑term financing stability.\n", "\n", "Measurable success metrics (cross‑cutting)\n", "- Environmental justice: air/groundwater quality improvements in EJ neighborhoods; proportion of residents within EJ areas benefiting from new protections; distributional equity of public investments.\n", "- Economic stability: unemployment rate in target neighborhoods reduced toward 9% or lower; number of local residents employed in higher‑wage jobs; share of city contracts awarded to local firms; new business startups and survival rates; median wage growth in targeted sectors.\n", "- Flood resilience: reductions in modeled flood depths near protected facilities; number of critical facilities safeguarded; evacuation times shortened; flood insurance claims decline.\n", "- Housing: affordable units added/preserved; displacement rates; stabilized rents in target neighborhoods.\n", "- Governance: timely completion of dashboards and reports; stakeholder satisfaction; number of citizen inquiries, resolved within target timeframes.\n", "\n", "Probability estimates and confidence intervals (net positive outcomes for EJ and economic stability)\n", "- Overall assessment approach: expert judgment combined with scenario thinking and sensitivity analysis across funding, climate risk, and program uptake. We present probabilistic ranges to reflect uncertainty in external funding, political appetite, and implementation challenges.\n", "- Probability plan achieves net positive outcomes for environmental justice (EJ) within 10 years:\n", " - Central estimate: 0.58 (58%)\n", " - 90% CI: 0.42 – 0.74\n", " - Interpretation: There is a fairly high chance that EJ indicators (air/water quality improvements, housing protections, equitable access to jobs) improve relative to baseline, assuming steady funding and strong governance.\n", "- Probability plan achieves net positive outcomes for economic stability within 10 years:\n", " - Central estimate: 0.65 (65%)\n", " - 90% CI: 0.50 – 0.78\n", " - Interpretation: A majority chance that unemployment in targeted neighborhoods stays low and that local jobs diversify and stabilize, given robust workforce programs and capital projects.\n", "- Joint probability that both EJ and economic stability show net positive outcomes within 10 years:\n", " - Assuming moderate positive correlation between economic and EJ benefits (ρ ≈ 0.3–0.5), joint probability ≈ 0.35–0.50 (35–50%), with 90% CI roughly 0.24–0.63.\n", "- Note: These are estimated probabilities with wide but plausible ranges; actual outcomes depend on federal grant success, political support for new revenue tools, plant cooperation, construction efficiency, and beneficiary engagement. The plan intentionally builds buffers (phased funding, governance, and adaptive management) to improve these odds.\n", "\n", "Executive summary (150 words)\n", "Port Meridia must harden against 1.2 m sea‑level rise, curb pollution from a major local plant, and grow an inclusive economy that can absorb workers displaced by environmental and industrial change. The 10‑year plan blends aggressive flood protection with nature‑based solutions, a just transition for plant workers, and a diversified, locally anchored economy focused on clean energy, logistics, healthcare, and resilient housing. It pairs a robust funding strategy—federal grants, resilience bonds, and targeted local revenue—with phased implementation to minimize displacement and deliver measurable benefits in EJ outcomes and job creation. A standing Climate and Justice Authority will ensure community voice and ongoing accountability, while dashboards and independent evaluations drive adaptive management. The plan aims for meaningful EJ improvements and a stable, expanding economy within a decade, albeit with identified risks and calibrated mitigations.\n", "\n", "Material assumptions\n", "- Demographic and economic conditions: Port Meridia’s population remains around 420,000; labor market dynamics persist with an 18% unemployment rate in EJ neighborhoods unless targeted programs succeed.\n", "- Sea‑level rise and flood risk: Projections of 1.2 m rise and intensified storm surge over 30 years are used for design; climate uncertainty acknowledged with adaptable protections.\n", "- Plant operations: The chemical plant remains a meaningful but not sole economic driver; cooperation for upgrades and a potential transition are assumed, with workers eligible for retraining and relocation supports.\n", "- Funding and financing: Federal and state grants for resilience and EJ are available; resilient bonds can be issued with favorable terms; local revenue tools are politically feasible with sunset provisions; private‑public partnerships are achievable for select projects.\n", "- Housing and displacement: Availability of federal housing funds, tax credits, and resilient zoning tools; community opposition manageable with targeted outreach and transparent planning.\n", "- Governance: Political willingness to establish a Climate and Justice Authority and maintain robust public dashboards; sustained leadership and community engagement.\n", "- Implementation capability: City departments can execute, coordinate across agencies, and maintain adaptive management with independent evaluators.\n", "- Inflation and cost: Costs reflect 2025–2035 price levels; contingency reserves are included for overruns; financing terms assume moderate interest rates.\n", "- Environmental outcomes: Monitoring data accurately reflect air and water quality changes; EJ neighborhoods see tangible benefits from planned investments.\n", "- External shocks: Plan assumes no extreme, unforeseen events (e.g., regional disasters) that would overwhelm funding or shift priorities; but includes contingency and scalable design to absorb shocks.\n", "\n", "If you’d like, I can tailor the cost ranges, funding allocations by year, or the stakeholder engagement plan to a specific political context or grant program you’re targeting." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# The API we know well\n", "# I've updated this with the latest model, but it can take some time because it likes to think!\n", "# Replace the model with gpt-4.1-mini if you'd prefer not to wait 1-2 mins\n", "\n", "model_name = \"gpt-5-nano\"\n", "\n", "response = openai.chat.completions.create(model=model_name, messages=messages)\n", "answer = response.choices[0].message.content\n", "\n", "display(Markdown(answer))\n", "competitors.append(model_name)\n", "answers.append(answer)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Anthropic has a slightly different API, and Max Tokens is required\n", "\n", "model_name = \"claude-sonnet-4-5\"\n", "\n", "claude = Anthropic()\n", "response = claude.messages.create(model=model_name, messages=messages, max_tokens=1000)\n", "answer = response.content[0].text\n", "\n", "display(Markdown(answer))\n", "competitors.append(model_name)\n", "answers.append(answer)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "gemini = OpenAI(api_key=google_api_key, base_url=\"https://generativelanguage.googleapis.com/v1beta/openai/\")\n", "model_name = \"gemini-2.5-flash\"\n", "\n", "response = gemini.chat.completions.create(model=model_name, messages=messages)\n", "answer = response.choices[0].message.content\n", "\n", "display(Markdown(answer))\n", "competitors.append(model_name)\n", "answers.append(answer)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "deepseek = OpenAI(api_key=deepseek_api_key, base_url=\"https://api.deepseek.com/v1\")\n", "model_name = \"deepseek-chat\"\n", "\n", "response = deepseek.chat.completions.create(model=model_name, messages=messages)\n", "answer = response.choices[0].message.content\n", "\n", "display(Markdown(answer))\n", "competitors.append(model_name)\n", "answers.append(answer)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Updated with the latest Open Source model from OpenAI\n", "\n", "groq = OpenAI(api_key=groq_api_key, base_url=\"https://api.groq.com/openai/v1\")\n", "model_name = \"openai/gpt-oss-120b\"\n", "\n", "response = groq.chat.completions.create(model=model_name, messages=messages)\n", "answer = response.choices[0].message.content\n", "\n", "display(Markdown(answer))\n", "competitors.append(model_name)\n", "answers.append(answer)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## For the next cell, we will use Ollama\n", "\n", "Ollama runs a local web service that gives an OpenAI compatible endpoint, \n", "and runs models locally using high performance C++ code.\n", "\n", "If you don't have Ollama, install it here by visiting https://ollama.com then pressing Download and following the instructions.\n", "\n", "After it's installed, you should be able to visit here: http://localhost:11434 and see the message \"Ollama is running\"\n", "\n", "You might need to restart Cursor (and maybe reboot). Then open a Terminal (control+\\`) and run `ollama serve`\n", "\n", "Useful Ollama commands (run these in the terminal, or with an exclamation mark in this notebook):\n", "\n", "`ollama pull ` downloads a model locally \n", "`ollama ls` lists all the models you've downloaded \n", "`ollama rm ` deletes the specified model from your downloads" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", "

Super important - ignore me at your peril!

\n", " The model called llama3.3 is FAR too large for home computers - it's not intended for personal computing and will consume all your resources! Stick with the nicely sized llama3.2 or llama3.2:1b and if you want larger, try llama3.1 or smaller variants of Qwen, Gemma, Phi or DeepSeek. See the the Ollama models page for a full list of models and sizes.\n", " \n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!ollama pull llama3.2" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "ename": "KeyboardInterrupt", "evalue": "", "output_type": "error", "traceback": [ "\u001b[31m---------------------------------------------------------------------------\u001b[39m", "\u001b[31mKeyboardInterrupt\u001b[39m Traceback (most recent call last)", "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[14]\u001b[39m\u001b[32m, line 4\u001b[39m\n\u001b[32m 1\u001b[39m ollama = OpenAI(base_url=\u001b[33m'\u001b[39m\u001b[33mhttp://localhost:11434/v1\u001b[39m\u001b[33m'\u001b[39m, api_key=\u001b[33m'\u001b[39m\u001b[33mollama\u001b[39m\u001b[33m'\u001b[39m)\n\u001b[32m 2\u001b[39m model_name = \u001b[33m\"\u001b[39m\u001b[33mgemma3:4b\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m4\u001b[39m response = \u001b[43mollama\u001b[49m\u001b[43m.\u001b[49m\u001b[43mchat\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcompletions\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcreate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m=\u001b[49m\u001b[43mmodel_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m=\u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 5\u001b[39m answer = response.choices[\u001b[32m0\u001b[39m].message.content\n\u001b[32m 7\u001b[39m display(Markdown(answer))\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/openai/_utils/_utils.py:286\u001b[39m, in \u001b[36mrequired_args..inner..wrapper\u001b[39m\u001b[34m(*args, **kwargs)\u001b[39m\n\u001b[32m 284\u001b[39m msg = \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mMissing required argument: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mquote(missing[\u001b[32m0\u001b[39m])\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m\n\u001b[32m 285\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(msg)\n\u001b[32m--> \u001b[39m\u001b[32m286\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/openai/resources/chat/completions/completions.py:1147\u001b[39m, in \u001b[36mCompletions.create\u001b[39m\u001b[34m(self, messages, model, audio, frequency_penalty, function_call, functions, logit_bias, logprobs, max_completion_tokens, max_tokens, metadata, modalities, n, parallel_tool_calls, prediction, presence_penalty, prompt_cache_key, reasoning_effort, response_format, safety_identifier, seed, service_tier, stop, store, stream, stream_options, temperature, tool_choice, tools, top_logprobs, top_p, user, verbosity, web_search_options, extra_headers, extra_query, extra_body, timeout)\u001b[39m\n\u001b[32m 1101\u001b[39m \u001b[38;5;129m@required_args\u001b[39m([\u001b[33m\"\u001b[39m\u001b[33mmessages\u001b[39m\u001b[33m\"\u001b[39m, \u001b[33m\"\u001b[39m\u001b[33mmodel\u001b[39m\u001b[33m\"\u001b[39m], [\u001b[33m\"\u001b[39m\u001b[33mmessages\u001b[39m\u001b[33m\"\u001b[39m, \u001b[33m\"\u001b[39m\u001b[33mmodel\u001b[39m\u001b[33m\"\u001b[39m, \u001b[33m\"\u001b[39m\u001b[33mstream\u001b[39m\u001b[33m\"\u001b[39m])\n\u001b[32m 1102\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mcreate\u001b[39m(\n\u001b[32m 1103\u001b[39m \u001b[38;5;28mself\u001b[39m,\n\u001b[32m (...)\u001b[39m\u001b[32m 1144\u001b[39m timeout: \u001b[38;5;28mfloat\u001b[39m | httpx.Timeout | \u001b[38;5;28;01mNone\u001b[39;00m | NotGiven = not_given,\n\u001b[32m 1145\u001b[39m ) -> ChatCompletion | Stream[ChatCompletionChunk]:\n\u001b[32m 1146\u001b[39m validate_response_format(response_format)\n\u001b[32m-> \u001b[39m\u001b[32m1147\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_post\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1148\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m/chat/completions\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 1149\u001b[39m \u001b[43m \u001b[49m\u001b[43mbody\u001b[49m\u001b[43m=\u001b[49m\u001b[43mmaybe_transform\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1150\u001b[39m \u001b[43m \u001b[49m\u001b[43m{\u001b[49m\n\u001b[32m 1151\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmessages\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1152\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmodel\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1153\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43maudio\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43maudio\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1154\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mfrequency_penalty\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfrequency_penalty\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1155\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mfunction_call\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfunction_call\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1156\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mfunctions\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfunctions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1157\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mlogit_bias\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mlogit_bias\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1158\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mlogprobs\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mlogprobs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1159\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmax_completion_tokens\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmax_completion_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1160\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmax_tokens\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmax_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1161\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmetadata\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmetadata\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1162\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmodalities\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodalities\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1163\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mn\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mn\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1164\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mparallel_tool_calls\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mparallel_tool_calls\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1165\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mprediction\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mprediction\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1166\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mpresence_penalty\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mpresence_penalty\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1167\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mprompt_cache_key\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mprompt_cache_key\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1168\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mreasoning_effort\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mreasoning_effort\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1169\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mresponse_format\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mresponse_format\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1170\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43msafety_identifier\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43msafety_identifier\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1171\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mseed\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mseed\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1172\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mservice_tier\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mservice_tier\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1173\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstop\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1174\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstore\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstore\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1175\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstream\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1176\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstream_options\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1177\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtemperature\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtemperature\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1178\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtool_choice\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtool_choice\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1179\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtools\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtools\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1180\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtop_logprobs\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtop_logprobs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1181\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtop_p\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtop_p\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1182\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43muser\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43muser\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1183\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mverbosity\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mverbosity\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1184\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mweb_search_options\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mweb_search_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1185\u001b[39m \u001b[43m \u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1186\u001b[39m \u001b[43m \u001b[49m\u001b[43mcompletion_create_params\u001b[49m\u001b[43m.\u001b[49m\u001b[43mCompletionCreateParamsStreaming\u001b[49m\n\u001b[32m 1187\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\n\u001b[32m 1188\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mcompletion_create_params\u001b[49m\u001b[43m.\u001b[49m\u001b[43mCompletionCreateParamsNonStreaming\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1189\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1190\u001b[39m \u001b[43m \u001b[49m\u001b[43moptions\u001b[49m\u001b[43m=\u001b[49m\u001b[43mmake_request_options\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1191\u001b[39m \u001b[43m \u001b[49m\u001b[43mextra_headers\u001b[49m\u001b[43m=\u001b[49m\u001b[43mextra_headers\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mextra_query\u001b[49m\u001b[43m=\u001b[49m\u001b[43mextra_query\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mextra_body\u001b[49m\u001b[43m=\u001b[49m\u001b[43mextra_body\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimeout\u001b[49m\n\u001b[32m 1192\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1193\u001b[39m \u001b[43m \u001b[49m\u001b[43mcast_to\u001b[49m\u001b[43m=\u001b[49m\u001b[43mChatCompletion\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1194\u001b[39m \u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstream\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[32m 1195\u001b[39m \u001b[43m \u001b[49m\u001b[43mstream_cls\u001b[49m\u001b[43m=\u001b[49m\u001b[43mStream\u001b[49m\u001b[43m[\u001b[49m\u001b[43mChatCompletionChunk\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1196\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/openai/_base_client.py:1259\u001b[39m, in \u001b[36mSyncAPIClient.post\u001b[39m\u001b[34m(self, path, cast_to, body, options, files, stream, stream_cls)\u001b[39m\n\u001b[32m 1245\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mpost\u001b[39m(\n\u001b[32m 1246\u001b[39m \u001b[38;5;28mself\u001b[39m,\n\u001b[32m 1247\u001b[39m path: \u001b[38;5;28mstr\u001b[39m,\n\u001b[32m (...)\u001b[39m\u001b[32m 1254\u001b[39m stream_cls: \u001b[38;5;28mtype\u001b[39m[_StreamT] | \u001b[38;5;28;01mNone\u001b[39;00m = \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[32m 1255\u001b[39m ) -> ResponseT | _StreamT:\n\u001b[32m 1256\u001b[39m opts = FinalRequestOptions.construct(\n\u001b[32m 1257\u001b[39m method=\u001b[33m\"\u001b[39m\u001b[33mpost\u001b[39m\u001b[33m\"\u001b[39m, url=path, json_data=body, files=to_httpx_files(files), **options\n\u001b[32m 1258\u001b[39m )\n\u001b[32m-> \u001b[39m\u001b[32m1259\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m cast(ResponseT, \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcast_to\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mopts\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstream\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream_cls\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstream_cls\u001b[49m\u001b[43m)\u001b[49m)\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/openai/_base_client.py:982\u001b[39m, in \u001b[36mSyncAPIClient.request\u001b[39m\u001b[34m(self, cast_to, options, stream, stream_cls)\u001b[39m\n\u001b[32m 980\u001b[39m response = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 981\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m982\u001b[39m response = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_client\u001b[49m\u001b[43m.\u001b[49m\u001b[43msend\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 983\u001b[39m \u001b[43m \u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 984\u001b[39m \u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstream\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_should_stream_response_body\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m=\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 985\u001b[39m \u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 986\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 987\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m httpx.TimeoutException \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[32m 988\u001b[39m log.debug(\u001b[33m\"\u001b[39m\u001b[33mEncountered httpx.TimeoutException\u001b[39m\u001b[33m\"\u001b[39m, exc_info=\u001b[38;5;28;01mTrue\u001b[39;00m)\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpx/_client.py:914\u001b[39m, in \u001b[36mClient.send\u001b[39m\u001b[34m(self, request, stream, auth, follow_redirects)\u001b[39m\n\u001b[32m 910\u001b[39m \u001b[38;5;28mself\u001b[39m._set_timeout(request)\n\u001b[32m 912\u001b[39m auth = \u001b[38;5;28mself\u001b[39m._build_request_auth(request, auth)\n\u001b[32m--> \u001b[39m\u001b[32m914\u001b[39m response = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_send_handling_auth\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 915\u001b[39m \u001b[43m \u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 916\u001b[39m \u001b[43m \u001b[49m\u001b[43mauth\u001b[49m\u001b[43m=\u001b[49m\u001b[43mauth\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 917\u001b[39m \u001b[43m \u001b[49m\u001b[43mfollow_redirects\u001b[49m\u001b[43m=\u001b[49m\u001b[43mfollow_redirects\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 918\u001b[39m \u001b[43m \u001b[49m\u001b[43mhistory\u001b[49m\u001b[43m=\u001b[49m\u001b[43m[\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 919\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 920\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m 921\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m stream:\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpx/_client.py:942\u001b[39m, in \u001b[36mClient._send_handling_auth\u001b[39m\u001b[34m(self, request, auth, follow_redirects, history)\u001b[39m\n\u001b[32m 939\u001b[39m request = \u001b[38;5;28mnext\u001b[39m(auth_flow)\n\u001b[32m 941\u001b[39m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m942\u001b[39m response = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_send_handling_redirects\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 943\u001b[39m \u001b[43m \u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 944\u001b[39m \u001b[43m \u001b[49m\u001b[43mfollow_redirects\u001b[49m\u001b[43m=\u001b[49m\u001b[43mfollow_redirects\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 945\u001b[39m \u001b[43m \u001b[49m\u001b[43mhistory\u001b[49m\u001b[43m=\u001b[49m\u001b[43mhistory\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 946\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 947\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m 948\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpx/_client.py:979\u001b[39m, in \u001b[36mClient._send_handling_redirects\u001b[39m\u001b[34m(self, request, follow_redirects, history)\u001b[39m\n\u001b[32m 976\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m hook \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m._event_hooks[\u001b[33m\"\u001b[39m\u001b[33mrequest\u001b[39m\u001b[33m\"\u001b[39m]:\n\u001b[32m 977\u001b[39m hook(request)\n\u001b[32m--> \u001b[39m\u001b[32m979\u001b[39m response = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_send_single_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 980\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m 981\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m hook \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m._event_hooks[\u001b[33m\"\u001b[39m\u001b[33mresponse\u001b[39m\u001b[33m\"\u001b[39m]:\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpx/_client.py:1014\u001b[39m, in \u001b[36mClient._send_single_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m 1009\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\n\u001b[32m 1010\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mAttempted to send an async request with a sync Client instance.\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 1011\u001b[39m )\n\u001b[32m 1013\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m request_context(request=request):\n\u001b[32m-> \u001b[39m\u001b[32m1014\u001b[39m response = \u001b[43mtransport\u001b[49m\u001b[43m.\u001b[49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1016\u001b[39m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(response.stream, SyncByteStream)\n\u001b[32m 1018\u001b[39m response.request = request\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpx/_transports/default.py:250\u001b[39m, in \u001b[36mHTTPTransport.handle_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m 237\u001b[39m req = httpcore.Request(\n\u001b[32m 238\u001b[39m method=request.method,\n\u001b[32m 239\u001b[39m url=httpcore.URL(\n\u001b[32m (...)\u001b[39m\u001b[32m 247\u001b[39m extensions=request.extensions,\n\u001b[32m 248\u001b[39m )\n\u001b[32m 249\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m map_httpcore_exceptions():\n\u001b[32m--> \u001b[39m\u001b[32m250\u001b[39m resp = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_pool\u001b[49m\u001b[43m.\u001b[49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mreq\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 252\u001b[39m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(resp.stream, typing.Iterable)\n\u001b[32m 254\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m Response(\n\u001b[32m 255\u001b[39m status_code=resp.status,\n\u001b[32m 256\u001b[39m headers=resp.headers,\n\u001b[32m 257\u001b[39m stream=ResponseStream(resp.stream),\n\u001b[32m 258\u001b[39m extensions=resp.extensions,\n\u001b[32m 259\u001b[39m )\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py:256\u001b[39m, in \u001b[36mConnectionPool.handle_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m 253\u001b[39m closing = \u001b[38;5;28mself\u001b[39m._assign_requests_to_connections()\n\u001b[32m 255\u001b[39m \u001b[38;5;28mself\u001b[39m._close_connections(closing)\n\u001b[32m--> \u001b[39m\u001b[32m256\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m exc \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 258\u001b[39m \u001b[38;5;66;03m# Return the response. Note that in this case we still have to manage\u001b[39;00m\n\u001b[32m 259\u001b[39m \u001b[38;5;66;03m# the point at which the response is closed.\u001b[39;00m\n\u001b[32m 260\u001b[39m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(response.stream, typing.Iterable)\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py:236\u001b[39m, in \u001b[36mConnectionPool.handle_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m 232\u001b[39m connection = pool_request.wait_for_connection(timeout=timeout)\n\u001b[32m 234\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m 235\u001b[39m \u001b[38;5;66;03m# Send the request on the assigned connection.\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m236\u001b[39m response = \u001b[43mconnection\u001b[49m\u001b[43m.\u001b[49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 237\u001b[39m \u001b[43m \u001b[49m\u001b[43mpool_request\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrequest\u001b[49m\n\u001b[32m 238\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 239\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m ConnectionNotAvailable:\n\u001b[32m 240\u001b[39m \u001b[38;5;66;03m# In some cases a connection may initially be available to\u001b[39;00m\n\u001b[32m 241\u001b[39m \u001b[38;5;66;03m# handle a request, but then become unavailable.\u001b[39;00m\n\u001b[32m 242\u001b[39m \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[32m 243\u001b[39m \u001b[38;5;66;03m# In this case we clear the connection and try again.\u001b[39;00m\n\u001b[32m 244\u001b[39m pool_request.clear_connection()\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpcore/_sync/connection.py:103\u001b[39m, in \u001b[36mHTTPConnection.handle_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m 100\u001b[39m \u001b[38;5;28mself\u001b[39m._connect_failed = \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[32m 101\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m exc\n\u001b[32m--> \u001b[39m\u001b[32m103\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_connection\u001b[49m\u001b[43m.\u001b[49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpcore/_sync/http11.py:136\u001b[39m, in \u001b[36mHTTP11Connection.handle_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m 134\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m Trace(\u001b[33m\"\u001b[39m\u001b[33mresponse_closed\u001b[39m\u001b[33m\"\u001b[39m, logger, request) \u001b[38;5;28;01mas\u001b[39;00m trace:\n\u001b[32m 135\u001b[39m \u001b[38;5;28mself\u001b[39m._response_closed()\n\u001b[32m--> \u001b[39m\u001b[32m136\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m exc\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpcore/_sync/http11.py:106\u001b[39m, in \u001b[36mHTTP11Connection.handle_request\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m 95\u001b[39m \u001b[38;5;28;01mpass\u001b[39;00m\n\u001b[32m 97\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m Trace(\n\u001b[32m 98\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mreceive_response_headers\u001b[39m\u001b[33m\"\u001b[39m, logger, request, kwargs\n\u001b[32m 99\u001b[39m ) \u001b[38;5;28;01mas\u001b[39;00m trace:\n\u001b[32m 100\u001b[39m (\n\u001b[32m 101\u001b[39m http_version,\n\u001b[32m 102\u001b[39m status,\n\u001b[32m 103\u001b[39m reason_phrase,\n\u001b[32m 104\u001b[39m headers,\n\u001b[32m 105\u001b[39m trailing_data,\n\u001b[32m--> \u001b[39m\u001b[32m106\u001b[39m ) = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_receive_response_headers\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 107\u001b[39m trace.return_value = (\n\u001b[32m 108\u001b[39m http_version,\n\u001b[32m 109\u001b[39m status,\n\u001b[32m 110\u001b[39m reason_phrase,\n\u001b[32m 111\u001b[39m headers,\n\u001b[32m 112\u001b[39m )\n\u001b[32m 114\u001b[39m network_stream = \u001b[38;5;28mself\u001b[39m._network_stream\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpcore/_sync/http11.py:177\u001b[39m, in \u001b[36mHTTP11Connection._receive_response_headers\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m 174\u001b[39m timeout = timeouts.get(\u001b[33m\"\u001b[39m\u001b[33mread\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[32m 176\u001b[39m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m177\u001b[39m event = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_receive_event\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 178\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(event, h11.Response):\n\u001b[32m 179\u001b[39m \u001b[38;5;28;01mbreak\u001b[39;00m\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpcore/_sync/http11.py:217\u001b[39m, in \u001b[36mHTTP11Connection._receive_event\u001b[39m\u001b[34m(self, timeout)\u001b[39m\n\u001b[32m 214\u001b[39m event = \u001b[38;5;28mself\u001b[39m._h11_state.next_event()\n\u001b[32m 216\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m event \u001b[38;5;129;01mis\u001b[39;00m h11.NEED_DATA:\n\u001b[32m--> \u001b[39m\u001b[32m217\u001b[39m data = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_network_stream\u001b[49m\u001b[43m.\u001b[49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 218\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mREAD_NUM_BYTES\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimeout\u001b[49m\n\u001b[32m 219\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 221\u001b[39m \u001b[38;5;66;03m# If we feed this case through h11 we'll raise an exception like:\u001b[39;00m\n\u001b[32m 222\u001b[39m \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[32m 223\u001b[39m \u001b[38;5;66;03m# httpcore.RemoteProtocolError: can't handle event type\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 227\u001b[39m \u001b[38;5;66;03m# perspective. Instead we handle this case distinctly and treat\u001b[39;00m\n\u001b[32m 228\u001b[39m \u001b[38;5;66;03m# it as a ConnectError.\u001b[39;00m\n\u001b[32m 229\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m data == \u001b[33mb\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m\"\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m._h11_state.their_state == h11.SEND_RESPONSE:\n", "\u001b[36mFile \u001b[39m\u001b[32m~/Code/AI/agents/.venv/lib/python3.12/site-packages/httpcore/_backends/sync.py:128\u001b[39m, in \u001b[36mSyncStream.read\u001b[39m\u001b[34m(self, max_bytes, timeout)\u001b[39m\n\u001b[32m 126\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m map_exceptions(exc_map):\n\u001b[32m 127\u001b[39m \u001b[38;5;28mself\u001b[39m._sock.settimeout(timeout)\n\u001b[32m--> \u001b[39m\u001b[32m128\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_sock\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrecv\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmax_bytes\u001b[49m\u001b[43m)\u001b[49m\n", "\u001b[31mKeyboardInterrupt\u001b[39m: " ] } ], "source": [ "ollama = OpenAI(base_url='http://localhost:11434/v1', api_key='ollama')\n", "model_name = \"gemma3:4b\"\n", "\n", "response = ollama.chat.completions.create(model=model_name, messages=messages)\n", "answer = response.choices[0].message.content\n", "\n", "display(Markdown(answer))\n", "competitors.append(model_name)\n", "answers.append(answer)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# So where are we?\n", "\n", "print(competitors)\n", "print(answers)\n" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Competitor: gpt-5-nano\n", "\n", "Executive framing\n", "Port Meridia faces three intertwined challenges: (1) a 1.2 m sea‑level rise with intensified storm surge over 30 years; (2) an 18% unemployment gap concentrated in neighborhoods near a large chemical plant that provides 25% of city jobs but cumulatively degrades air/water quality; (3) a municipal budget capable of up to a 30% spending increase over five years only if taxes rise or federal grants are secured. This plan proposals a coordinated, 10‑year, financially feasible program that minimizes displacement, shields people from flood risk, reduces the most harmful pollution, and creates inclusive economic opportunity. It relies on a mix of federal grants, bonds, private partnerships, and targeted local revenue, with strong community engagement and accountability.\n", "\n", "Ten-year plan at a glance (major actions)\n", "- Action A: Build integrated flood protection for critical assets and vulnerable neighborhoods; expand natural infrastructure; elevate essential facilities; improve drainage and evacuation routes.\n", "- Action B: Accelerate pollution reduction and a just transition for the plant’s workers; upgrade controls; monitor air/water quality; plan relocation/repurposing if needed; ensure community benefits.\n", "- Action C: Deploy inclusive economic development and workforce programs; prioritize local hiring on city projects; diversify the economy toward clean industries and port/logistics.\n", "- Action D: Preserve and expand affordable housing; prevent displacement; use inclusionary zoning, community land trusts, and buyout/relocation supports where risk is highest.\n", "- Action E: Modernize transportation and critical infrastructure to withstand flooding, reduce emissions, and connect neighborhoods to opportunity.\n", "- Action F: Strengthen governance, transparency, and EJ accountability; establish a standing Climate and Justice Authority with community representation.\n", "- Action G: Create a robust, diversified financing strategy; blend federal grants, resilience bonds, public-private partnerships, and targeted local revenue; secure a five‑to‑ten year funding pipeline.\n", "- Action H: Continuous monitoring, evaluation, and adaptive management; deploy independent metrics, public dashboards, and annual reporting to guide adjustments.\n", "\n", "Detailed major actions (with required fields)\n", "\n", "Action A. Flood protection for high‑risk areas and critical infrastructure\n", "- Rationale: 1.2 m sea‑level rise and stronger surges threaten hospitals, water treatment, schools, and large employers; uncontrolled flooding creates displacement risk and undermines the tax base.\n", "- Major components:\n", " - Engineering: hybrid flood defenses (seawalls, surge barriers, tidal gates) sized for design storms and projected sea‑level rise.\n", " - Natural infrastructure: living shorelines, wetlands restoration, dune systems, green streets, bioswales.\n", " - Infrastructure retrofits: flood-proofing for hospitals, water plant, emergency operations center, police/fire stations; elevate critical electrical/IT assets.\n", " - Evacuation and resilience routing: dedicated emergency corridors, upgraded pump stations, backflow prevention.\n", "- Estimated cost and funding sources:\n", " - Cost: $2.0–3.5 billion over 10 years (phased).\n", " - Funding: federal BRIC/NOAA grants, HUD CDBG‑Mitigation, EPA grants, state resilience funds; municipal general obligation bonds; private‑public partnerships; potential modest climate resilience tax or fee with sunset after the first 6–8 years.\n", "- Timeline:\n", " - Years 1–3: design approvals, environmental reviews, early procurement for critical facilities.\n", " - Years 2–6: primary construction of protection for top-priority zones and facilities; begin natural infrastructure projects.\n", " - Years 6–10: expand protections to remaining areas; retrofit additional facilities; optimize operations.\n", "- Key stakeholders and objections:\n", " - Stakeholders: residents in flood zones, hospitals, school districts, port operators, small business associations, environmental groups.\n", " - Likely objections: high up-front cost, potential displacement risks during construction, competing budget needs.\n", "- Measurable success metrics:\n", " - Reduction in modeled flood depths for critical facilities (e.g., >50% in protected zones).\n", " - Percent of critical facilities shielded from projected flood events.\n", " - Kilometers of living shoreline and miles of improved drainage; evacuation time improvements; insured loss reductions.\n", "- Three likely failure modes and mitigations:\n", " - Funding shortfalls or delays: implement phased design with clear milestones; establish reserve contingencies; secure multi-year commitments from federal/state sources.\n", " - Construction disruption in neighborhoods: use tight project management, community liaisons, temporary relocations with stipends; nonessential work scheduled in off-peak seasons.\n", " - Underestimation of sea‑level rise risk: adopt adaptive design with modular extensions and flexible permitting; est. annual review of risk data and design tweaks.\n", "- Confidence/uncertainty: Moderate to high confidence in phased delivery if federal/state funds materialize and procurement is aggressive.\n", "\n", "Action B. Pollution reduction and just transition for the plant\n", "- Rationale: 18% unemployment near a plant that provides 25% of city jobs but incurs pollutant discharges; local health and climate benefits align with EJ goals; long-term local prosperity requires cleaner industry and worker retraining.\n", "- Major components:\n", " - Emissions and discharge controls: upgraded scrubbers, filtration, smokestack improvements, process modifications to reduce hazardous byproducts.\n", " - Regulatory tightening with milestones: enforce pollutant caps; continuous air and water monitoring with public dashboards.\n", " - Transition planning for workers: career counseling, retraining in higher‑skill clean‑tech, port/logistics, healthcare, or energy sectors; wage‑support programs; relocation or redeployment assistance if plant phase‑out or relocation occurs.\n", " - Community benefits agreements (CBAs): job locality targets, local procurement, and long‑term community investment commitments.\n", "- Estimated cost and funding sources:\n", " - Cost: $0.5–1.0 billion for plant upgrades and process changes; $50–120 million for workforce retraining; $200–400 million for transition/relocation supports if needed.\n", " - Funding: EPA/state environmental grants; USDOT/EDA economic development funds for clean‑tech transitions; city bonds; plant capital investments; philanthropic and private capital; potential state green‑jobs grants.\n", "- Timeline:\n", " - Years 1–3: design and begin plant upgrades; establish EJ oversight and CBAs; initiate retraining programs.\n", " - Years 3–7: complete major plant upgrades; scale workforce transitions; monitor air/water metrics and health indicators.\n", " - Years 6–10: evaluate ongoing plant operations; implement relocation/repurposing if warranted; sustain community investments.\n", "- Key stakeholders and objections:\n", " - Stakeholders: plant management, workers and unions, nearby residents, independent monitors, environmental groups.\n", " - Likely objections: plant cost burden, risk of job losses, skepticism about long-term benefits; concerns about compliance burden and reliability of new processes.\n", "- Measurable success metrics:\n", " - Pollutant reductions (tons/year of key pollutants) and compliance with stricter caps.\n", " - Air quality indices in nearby neighborhoods; water quality metrics around discharge points.\n", " - Number of workers retrained and placed in higher‑wage jobs; retained employment in the new sector; CBAs payout and local procurement share.\n", " - Progress toward a cleaner, diversified industrial base in the city.\n", "- Three likely failure modes and mitigations:\n", " - Plant resistance to upgrades or relocation: use binding performance milestones, enforceable penalties for noncompliance, and incentive packages tied to emissions reductions; align with long‑term city economic diversification plans.\n", " - Inadequate worker retraining outcomes: design continuous, sector‑wide retraining with employer partners; offer portable credentials; provide wage‑top‑ups and relocation stipends.\n", " - Cost overruns or delayed permits: reserve contingency funds; adopt modular upgrades; parallel permitting tracks and fast‑tracking where safe.\n", "- Confidence/uncertainty: Moderate confidence; depends on plant cooperation and federal/state grant flows.\n", "\n", "Action C. Inclusive economic development and workforce expansion\n", "- Rationale: Unemployment concentrated in EJ neighborhoods; build an economy that absorbs workers from the plant and other sectors; reduce vulnerability to single-plant shocks.\n", "- Major components:\n", " - Local hiring and supplier requirements: target minimum local hire and procurement share on city projects and major private developments.\n", " - Workforce development: sector partnerships (clean energy, logistics, healthcare, construction, water management); apprenticeships and placement guarantees; industry-recognized credentials.\n", " - Small business and entrepreneurship support: microgrants, credit facilities, technical assistance, access to procurement networks; business incubators in EJ neighborhoods.\n", " - Green economy growth: accelerate training for port-related jobs, climate adaptation services, energy efficiency retrofits for homes/commercial buildings.\n", "- Estimated cost and funding sources:\n", " - Cost: $150–350 million in direct program funding over 10 years (plus leverage from private partners).\n", " - Funding: HUD workforce and economic mobility grants; EDA regional economic development grants; state workforce funds; city general funds; philanthropic and corporate philanthropy; small business loan funds (revolving loan fund).\n", "- Timeline:\n", " - Years 1–2: establish partnerships, design curricula, deploy initial apprenticeship programs.\n", " - Years 2–5: scale apprenticeships and job placement; expand incubator and microgrant programs.\n", " - Years 5–10: broaden sector coverage; evaluate and refine local hiring targets; measure displacement dynamics and wage gains.\n", "- Key stakeholders and objections:\n", " - Stakeholders: local workers and unions, community organizations, employers, higher education institutions, small business associations.\n", " - Likely objections: concerns about program effectiveness, budget competition with other priorities, fears of preferential hiring; ensure transparency and objective metrics.\n", "- Measurable success metrics:\n", " - Number of residents trained and placed; unemployment rate reduction in targeted neighborhoods (goal: cut 18% to ≤9% by year 10); number of local contracts awarded; number of new businesses started; wage growth and retention rates; miles of green infrastructure built with job impact.\n", "- Three failure modes and mitigations:\n", " - Skills mismatch: establish real-time labor market data, employer advisory boards, and flexible credentialing; adjust curricula and pathways quickly.\n", " - Underfunding and program fragmentation: create a centralized repository of funding streams; multi‑agency coordination to avoid duplication; regular audits.\n", " - Low job uptake due to relocation risk or stigma: combine with housing protections and neighborhood revitalization to attract workers; provide relocation stipends and housing subsidies if needed.\n", "- Confidence/uncertainty: Moderate to high confidence; success hinges on sustained employer engagement and funding.\n", "\n", "Action D. Housing affordability, displacement prevention, and resilience\n", "- Rationale: Infrastructure investment raises displacement risk if housing costs rise; pursue a stable, equitable housing stock near job hubs.\n", "- Major components:\n", " - Affordable housing production and preservation: use income‑restricted units, tax credits, inclusionary zoning for new developments, and preservation of existing affordable units.\n", " - Anti‑displacement measures: tenant protections, rent stabilization for vulnerable periods, right to counsel, relocation assistance.\n", " - Community land trusts and deed restrictions: preserve long‑term affordability and community control near flood‑prone areas.\n", " - Acquisition and rehabilitation of at‑risk housing: preemptive buyouts in highly flood‑prone zones, with resident supports and relocation pathways.\n", "- Estimated cost and funding sources:\n", " - Cost: $300–600 million over 10 years (capital plus subsidy layers for preservation; ongoing operating subsidies).\n", " - Funding: federal HOME and CDBG funds; low‑income housing tax credits; state housing funds; bonds; local philanthropy; private investment; rural/state affordable housing set‑asides.\n", "- Timeline:\n", " - Years 1–3: policy design; preliminary acquisitions; preservation commitments; set‑aside funds.\n", " - Years 3–6: commence large‑volume affordable housing development; implement anti‑displacement protections citywide.\n", " - Years 6–10: complete significant housing stock; monitor displacement metrics; scale up ongoing preservation.\n", "- Key stakeholders and objections:\n", " - Stakeholders: residents in affected neighborhoods, tenants’ associations, housing developers, landlords, lenders, community groups.\n", " - Likely objections: concerns about density, neighborhood change, impact fees, and regulatory burdens; address with clear community input and equitable distribution of benefits.\n", "- Measurable success metrics:\n", " - Number of affordable units created/preserved; change in median rents in target areas; displacement incidence; time‑to‑housing of affected residents; number of residents assisted with relocation.\n", "- Three failure modes and mitigations:\n", " - Funding gaps and political opposition: pursue multi‑source funding and broad coalition advocacy; implement phased delivery with milestones.\n", " - Delays due to approvals or construction: expedite with pre‑approved zoning pathways; fast‑track permits for affordable housing; ensure community advisory groups.\n", " - Gentrification pressures: enforce inclusionary policies; protect existing tenants; ensure long‑term affordability after initial 10 years.\n", "- Confidence/uncertainty: High confidence if funding and developer commitments align; risk if housing markets tighten or opposition intensifies.\n", "\n", "Action E. Transportation and infrastructure modernization\n", "- Rationale: Connectivity to jobs and evacuation routes; reduce emissions; improve resilience and economic competitiveness.\n", "- Major components:\n", " - Transit upgrades: electrified buses, expanded routes to EJ neighborhoods, resilience‑minded transit hubs.\n", " - Road and drainage improvements: flood‑resilient drainage networks; elevated road segments where necessary; arterial upgrades for evacuation.\n", " - Port and logistics improvements: climate‑resilient port access, pollution controls at port facilities, security and reliability upgrades.\n", " - Multi‑modal corridors and safety: bike/pedestrian networks; safe routes to schools; last‑mile connectivity to housing and jobs.\n", "- Estimated cost and funding sources:\n", " - Cost: $0.8–1.5 billion over 10 years.\n", " - Funding: federal DOT grants (FTA, TIGER/BUILD), state transportation funds, bonds, public‑private partnerships for port facilities, and EV fleet subsidies.\n", "- Timeline:\n", " - Years 1–3: master plan approvals, procurement for initial electrified fleet, design improvements.\n", " - Years 2–6: construction of protected transit corridors, drainage upgrades, and selected port access improvements.\n", " - Years 6–10: completion of major corridors, full fleet conversion, continuous optimization.\n", "- Key stakeholders and objections:\n", " - Stakeholders: commuters, transit riders, port users, freight businesses, environmental groups.\n", " - Likely objections: tolls or user fees; concerns about construction disruption and route changes; property access and eminent domain concerns.\n", "- Measurable success metrics:\n", " - Transit electrification rate; miles of resilient drainage; commute times; port throughput; reduction in flood‑related incidents impacting transport.\n", "- Three failure modes and mitigations:\n", " - Funding or procurement delays: use design‑build contracts to shorten timelines; secure advance funding from multiple sources.\n", " - Community resistance to tolls or fees: offset by subsidies for low‑income residents and transparent benefit reporting.\n", " - Disruption to trade during construction: provide phasing, off‑hours work when possible, and industry liaison groups.\n", "- Confidence/uncertainty: Moderate; depends on federal/state support and port traffic demands.\n", "\n", "Action F. Governance, transparency, equity oversight\n", "- Rationale: Political feasibility and legitimacy require robust accountability and direct community involvement.\n", "- Major components:\n", " - Establish Port Meridia Climate and Justice Authority (PMAJ) with equitable representation from EJ communities, labor, business, housing, environmental groups.\n", " - Public dashboards: budget, project progress, environmental indicators, health outcomes.\n", " - Independent evaluation: annual third‑party audits; annual progress reports; citizen‑initiated inquiries.\n", "- Estimated cost and funding sources:\n", " - Cost: $20–60 million over 10 years (administrative, staff, and independent monitoring).\n", " - Funding: city general fund; grants for governance innovation; philanthropy.\n", "- Timeline:\n", " - Year 1: chartering, appointment processes, initial reporting framework.\n", " - Years 1–10: ongoing governance operations, annual public reporting and independent audits.\n", "- Key stakeholders and objections:\n", " - Stakeholders: general public, EJ communities, developers, employers.\n", " - Likely objections: concerns about governance complexity, bureaucratic overhead, potential capture by interest groups.\n", "- Measurable success metrics:\n", " - Timeliness and completeness of annual reports; community engagement metrics; rate of project approvals on schedule; reduction in disputes.\n", "- Failure modes and mitigations:\n", " - Governance gridlock: establish clear decision–making rules, time‑boxed advisory cycles, and an ombudsperson.\n", " - Perceived inequities in participation: require representative geographic and demographic quotas; rotate seats to ensure broad representation.\n", "- Confidence/uncertainty: High; governance structures are implementable and essential for legitimacy.\n", "\n", "Action G. Financing strategy and revenue plan\n", "- Rationale: A credible funding mix is essential to unlock the 30% budget uplift without destabilizing finances.\n", "- Major components:\n", " - Federal/state grants: maximize eligibility for HUD resilience and EJ grants, NOAA, EPA, EDA programs; unfunded liability mitigation through grants.\n", " - Resilience bonds: issue municipal bonds tied to climate resilience outcomes; interest rates and issuance terms guided by rating agencies.\n", " - Public-private partnerships: leverage private capital for targeted infrastructure (e.g., port, transit, water treatment improvements) with performance‑based contracts.\n", " - Local revenue tools: phased climate resilience tax or fee; targeted incentives to attract new businesses; reallocation of existing departmental budgets with efficiency measures.\n", " - Insurance and risk transfer: leverage reinsurance for flood risk portfolios to stabilize long‑term costs.\n", "- Estimated cost and funding sources:\n", " - Debt and grants combination to fund $2.0–4.0 billion in capital needs across actions A–E over 10 years.\n", "- Timeline:\n", " - Years 1–2: secure grant commitments; issue initial resilience bonds; finalize tax/fee framework with sunset provisions.\n", " - Years 2–10: issue subsequent bonds as projects commence; monitor revenue streams and adjust as needed.\n", "- Stakeholders and objections:\n", " - Stakeholders: taxpayers, bond markets, lenders, state/federal agencies, businesses.\n", " - Likely objections: tax increases or new fees; concerns about debt burden and intergenerational equity.\n", "- Measurable success metrics:\n", " - Amount of funding secured; share of projects funded via grants vs. debt; debt service coverage ratios; timely allocation of funds; number of projects completed per year.\n", "- Three failure modes and mitigations:\n", " - Grant shortfalls or higher borrowing costs: diversify funding; maintain strong fiscal reserves; pre‑commitment of multiple finance sources.\n", " - Public opposition to taxes/fees: deploy clear ROI reporting, sunset clauses, and equity protections in the design.\n", " - Financing delays due to market conditions: pre‑arranged credit facilities; scalable, modular project phasing.\n", "- Confidence/uncertainty: Moderate; highly contingent on external funding markets and political feasibility of local revenue tools.\n", "\n", "Action H. Monitoring, evaluation, and adaptive management\n", "- Rationale: To ensure progress toward environmental justice and economic stability, with the ability to course‑correct.\n", "- Major components:\n", " - Data and dashboards: flood risk reductions, air/water quality metrics, housing affordability and displacement indicators, employment/sectors metrics, community satisfaction.\n", " - Independent review: third‑party evaluators; annual performance reports; mid‑term and end‑term independent reviews.\n", " - Adaptive management: annual reallocation of funds to high‑performing programs; course corrections for underperforming actions.\n", "- Estimated cost and funding sources:\n", " - Cost: $10–30 million over 10 years for data systems, staff, and evaluation contracts.\n", "- Timeline:\n", " - Ongoing from Year 1 onward; annual reviews and adjustments.\n", "- Stakeholders and objections:\n", " - Stakeholders: residents, EJ communities, city departments, funding partners.\n", " - Likely objections: data transparency concerns; perceived bureaucratic overhead.\n", "- Measurable success metrics:\n", " - Compliance with EJ benchmarks; improvements in housing affordability indices; unemployment reductions; flood protection performance metrics; pollution reductions; public satisfaction scores.\n", "- Failure modes and mitigations:\n", " - Data gaps: implement standardized data collection; ensure interoperability; train staff.\n", " - Misaligned incentives: align performance metrics with equity goals; tie funding to measurable outcomes.\n", "- Confidence/uncertainty: High; data‑driven loop is essential to success and reduces political risk.\n", "\n", "Projected timeline (summary)\n", "- Years 1–3: finalize designs, secure initial funding, begin most critical flood protection work, commence plant upgrades, launch workforce programs, establish PMAJ, begin affordable housing preservation, initiate transit and port improvements.\n", "- Years 3–6: scale major construction and upgrades; advance plant transition; expand housing and local hiring programs; deploy first rounds of resilience bonds; implement governance and EJ dashboards.\n", "- Years 7–10: complete remaining infrastructure protections; solidify a diversified economy; sustain workforce and housing programs; evaluate and adapt programs; ensure long‑term financing stability.\n", "\n", "Measurable success metrics (cross‑cutting)\n", "- Environmental justice: air/groundwater quality improvements in EJ neighborhoods; proportion of residents within EJ areas benefiting from new protections; distributional equity of public investments.\n", "- Economic stability: unemployment rate in target neighborhoods reduced toward 9% or lower; number of local residents employed in higher‑wage jobs; share of city contracts awarded to local firms; new business startups and survival rates; median wage growth in targeted sectors.\n", "- Flood resilience: reductions in modeled flood depths near protected facilities; number of critical facilities safeguarded; evacuation times shortened; flood insurance claims decline.\n", "- Housing: affordable units added/preserved; displacement rates; stabilized rents in target neighborhoods.\n", "- Governance: timely completion of dashboards and reports; stakeholder satisfaction; number of citizen inquiries, resolved within target timeframes.\n", "\n", "Probability estimates and confidence intervals (net positive outcomes for EJ and economic stability)\n", "- Overall assessment approach: expert judgment combined with scenario thinking and sensitivity analysis across funding, climate risk, and program uptake. We present probabilistic ranges to reflect uncertainty in external funding, political appetite, and implementation challenges.\n", "- Probability plan achieves net positive outcomes for environmental justice (EJ) within 10 years:\n", " - Central estimate: 0.58 (58%)\n", " - 90% CI: 0.42 – 0.74\n", " - Interpretation: There is a fairly high chance that EJ indicators (air/water quality improvements, housing protections, equitable access to jobs) improve relative to baseline, assuming steady funding and strong governance.\n", "- Probability plan achieves net positive outcomes for economic stability within 10 years:\n", " - Central estimate: 0.65 (65%)\n", " - 90% CI: 0.50 – 0.78\n", " - Interpretation: A majority chance that unemployment in targeted neighborhoods stays low and that local jobs diversify and stabilize, given robust workforce programs and capital projects.\n", "- Joint probability that both EJ and economic stability show net positive outcomes within 10 years:\n", " - Assuming moderate positive correlation between economic and EJ benefits (ρ ≈ 0.3–0.5), joint probability ≈ 0.35–0.50 (35–50%), with 90% CI roughly 0.24–0.63.\n", "- Note: These are estimated probabilities with wide but plausible ranges; actual outcomes depend on federal grant success, political support for new revenue tools, plant cooperation, construction efficiency, and beneficiary engagement. The plan intentionally builds buffers (phased funding, governance, and adaptive management) to improve these odds.\n", "\n", "Executive summary (150 words)\n", "Port Meridia must harden against 1.2 m sea‑level rise, curb pollution from a major local plant, and grow an inclusive economy that can absorb workers displaced by environmental and industrial change. The 10‑year plan blends aggressive flood protection with nature‑based solutions, a just transition for plant workers, and a diversified, locally anchored economy focused on clean energy, logistics, healthcare, and resilient housing. It pairs a robust funding strategy—federal grants, resilience bonds, and targeted local revenue—with phased implementation to minimize displacement and deliver measurable benefits in EJ outcomes and job creation. A standing Climate and Justice Authority will ensure community voice and ongoing accountability, while dashboards and independent evaluations drive adaptive management. The plan aims for meaningful EJ improvements and a stable, expanding economy within a decade, albeit with identified risks and calibrated mitigations.\n", "\n", "Material assumptions\n", "- Demographic and economic conditions: Port Meridia’s population remains around 420,000; labor market dynamics persist with an 18% unemployment rate in EJ neighborhoods unless targeted programs succeed.\n", "- Sea‑level rise and flood risk: Projections of 1.2 m rise and intensified storm surge over 30 years are used for design; climate uncertainty acknowledged with adaptable protections.\n", "- Plant operations: The chemical plant remains a meaningful but not sole economic driver; cooperation for upgrades and a potential transition are assumed, with workers eligible for retraining and relocation supports.\n", "- Funding and financing: Federal and state grants for resilience and EJ are available; resilient bonds can be issued with favorable terms; local revenue tools are politically feasible with sunset provisions; private‑public partnerships are achievable for select projects.\n", "- Housing and displacement: Availability of federal housing funds, tax credits, and resilient zoning tools; community opposition manageable with targeted outreach and transparent planning.\n", "- Governance: Political willingness to establish a Climate and Justice Authority and maintain robust public dashboards; sustained leadership and community engagement.\n", "- Implementation capability: City departments can execute, coordinate across agencies, and maintain adaptive management with independent evaluators.\n", "- Inflation and cost: Costs reflect 2025–2035 price levels; contingency reserves are included for overruns; financing terms assume moderate interest rates.\n", "- Environmental outcomes: Monitoring data accurately reflect air and water quality changes; EJ neighborhoods see tangible benefits from planned investments.\n", "- External shocks: Plan assumes no extreme, unforeseen events (e.g., regional disasters) that would overwhelm funding or shift priorities; but includes contingency and scalable design to absorb shocks.\n", "\n", "If you’d like, I can tailor the cost ranges, funding allocations by year, or the stakeholder engagement plan to a specific political context or grant program you’re targeting.\n" ] } ], "source": [ "# It's nice to know how to use \"zip\"\n", "for competitor, answer in zip(competitors, answers):\n", " print(f\"Competitor: {competitor}\\n\\n{answer}\")\n" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "# Let's bring this together - note the use of \"enumerate\"\n", "\n", "together = \"\"\n", "for index, answer in enumerate(answers):\n", " together += f\"# Response from competitor {index+1}\\n\\n\"\n", " together += answer + \"\\n\\n\"" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "# Response from competitor 1\n", "\n", "Executive framing\n", "Port Meridia faces three intertwined challenges: (1) a 1.2 m sea‑level rise with intensified storm surge over 30 years; (2) an 18% unemployment gap concentrated in neighborhoods near a large chemical plant that provides 25% of city jobs but cumulatively degrades air/water quality; (3) a municipal budget capable of up to a 30% spending increase over five years only if taxes rise or federal grants are secured. This plan proposals a coordinated, 10‑year, financially feasible program that minimizes displacement, shields people from flood risk, reduces the most harmful pollution, and creates inclusive economic opportunity. It relies on a mix of federal grants, bonds, private partnerships, and targeted local revenue, with strong community engagement and accountability.\n", "\n", "Ten-year plan at a glance (major actions)\n", "- Action A: Build integrated flood protection for critical assets and vulnerable neighborhoods; expand natural infrastructure; elevate essential facilities; improve drainage and evacuation routes.\n", "- Action B: Accelerate pollution reduction and a just transition for the plant’s workers; upgrade controls; monitor air/water quality; plan relocation/repurposing if needed; ensure community benefits.\n", "- Action C: Deploy inclusive economic development and workforce programs; prioritize local hiring on city projects; diversify the economy toward clean industries and port/logistics.\n", "- Action D: Preserve and expand affordable housing; prevent displacement; use inclusionary zoning, community land trusts, and buyout/relocation supports where risk is highest.\n", "- Action E: Modernize transportation and critical infrastructure to withstand flooding, reduce emissions, and connect neighborhoods to opportunity.\n", "- Action F: Strengthen governance, transparency, and EJ accountability; establish a standing Climate and Justice Authority with community representation.\n", "- Action G: Create a robust, diversified financing strategy; blend federal grants, resilience bonds, public-private partnerships, and targeted local revenue; secure a five‑to‑ten year funding pipeline.\n", "- Action H: Continuous monitoring, evaluation, and adaptive management; deploy independent metrics, public dashboards, and annual reporting to guide adjustments.\n", "\n", "Detailed major actions (with required fields)\n", "\n", "Action A. Flood protection for high‑risk areas and critical infrastructure\n", "- Rationale: 1.2 m sea‑level rise and stronger surges threaten hospitals, water treatment, schools, and large employers; uncontrolled flooding creates displacement risk and undermines the tax base.\n", "- Major components:\n", " - Engineering: hybrid flood defenses (seawalls, surge barriers, tidal gates) sized for design storms and projected sea‑level rise.\n", " - Natural infrastructure: living shorelines, wetlands restoration, dune systems, green streets, bioswales.\n", " - Infrastructure retrofits: flood-proofing for hospitals, water plant, emergency operations center, police/fire stations; elevate critical electrical/IT assets.\n", " - Evacuation and resilience routing: dedicated emergency corridors, upgraded pump stations, backflow prevention.\n", "- Estimated cost and funding sources:\n", " - Cost: $2.0–3.5 billion over 10 years (phased).\n", " - Funding: federal BRIC/NOAA grants, HUD CDBG‑Mitigation, EPA grants, state resilience funds; municipal general obligation bonds; private‑public partnerships; potential modest climate resilience tax or fee with sunset after the first 6–8 years.\n", "- Timeline:\n", " - Years 1–3: design approvals, environmental reviews, early procurement for critical facilities.\n", " - Years 2–6: primary construction of protection for top-priority zones and facilities; begin natural infrastructure projects.\n", " - Years 6–10: expand protections to remaining areas; retrofit additional facilities; optimize operations.\n", "- Key stakeholders and objections:\n", " - Stakeholders: residents in flood zones, hospitals, school districts, port operators, small business associations, environmental groups.\n", " - Likely objections: high up-front cost, potential displacement risks during construction, competing budget needs.\n", "- Measurable success metrics:\n", " - Reduction in modeled flood depths for critical facilities (e.g., >50% in protected zones).\n", " - Percent of critical facilities shielded from projected flood events.\n", " - Kilometers of living shoreline and miles of improved drainage; evacuation time improvements; insured loss reductions.\n", "- Three likely failure modes and mitigations:\n", " - Funding shortfalls or delays: implement phased design with clear milestones; establish reserve contingencies; secure multi-year commitments from federal/state sources.\n", " - Construction disruption in neighborhoods: use tight project management, community liaisons, temporary relocations with stipends; nonessential work scheduled in off-peak seasons.\n", " - Underestimation of sea‑level rise risk: adopt adaptive design with modular extensions and flexible permitting; est. annual review of risk data and design tweaks.\n", "- Confidence/uncertainty: Moderate to high confidence in phased delivery if federal/state funds materialize and procurement is aggressive.\n", "\n", "Action B. Pollution reduction and just transition for the plant\n", "- Rationale: 18% unemployment near a plant that provides 25% of city jobs but incurs pollutant discharges; local health and climate benefits align with EJ goals; long-term local prosperity requires cleaner industry and worker retraining.\n", "- Major components:\n", " - Emissions and discharge controls: upgraded scrubbers, filtration, smokestack improvements, process modifications to reduce hazardous byproducts.\n", " - Regulatory tightening with milestones: enforce pollutant caps; continuous air and water monitoring with public dashboards.\n", " - Transition planning for workers: career counseling, retraining in higher‑skill clean‑tech, port/logistics, healthcare, or energy sectors; wage‑support programs; relocation or redeployment assistance if plant phase‑out or relocation occurs.\n", " - Community benefits agreements (CBAs): job locality targets, local procurement, and long‑term community investment commitments.\n", "- Estimated cost and funding sources:\n", " - Cost: $0.5–1.0 billion for plant upgrades and process changes; $50–120 million for workforce retraining; $200–400 million for transition/relocation supports if needed.\n", " - Funding: EPA/state environmental grants; USDOT/EDA economic development funds for clean‑tech transitions; city bonds; plant capital investments; philanthropic and private capital; potential state green‑jobs grants.\n", "- Timeline:\n", " - Years 1–3: design and begin plant upgrades; establish EJ oversight and CBAs; initiate retraining programs.\n", " - Years 3–7: complete major plant upgrades; scale workforce transitions; monitor air/water metrics and health indicators.\n", " - Years 6–10: evaluate ongoing plant operations; implement relocation/repurposing if warranted; sustain community investments.\n", "- Key stakeholders and objections:\n", " - Stakeholders: plant management, workers and unions, nearby residents, independent monitors, environmental groups.\n", " - Likely objections: plant cost burden, risk of job losses, skepticism about long-term benefits; concerns about compliance burden and reliability of new processes.\n", "- Measurable success metrics:\n", " - Pollutant reductions (tons/year of key pollutants) and compliance with stricter caps.\n", " - Air quality indices in nearby neighborhoods; water quality metrics around discharge points.\n", " - Number of workers retrained and placed in higher‑wage jobs; retained employment in the new sector; CBAs payout and local procurement share.\n", " - Progress toward a cleaner, diversified industrial base in the city.\n", "- Three likely failure modes and mitigations:\n", " - Plant resistance to upgrades or relocation: use binding performance milestones, enforceable penalties for noncompliance, and incentive packages tied to emissions reductions; align with long‑term city economic diversification plans.\n", " - Inadequate worker retraining outcomes: design continuous, sector‑wide retraining with employer partners; offer portable credentials; provide wage‑top‑ups and relocation stipends.\n", " - Cost overruns or delayed permits: reserve contingency funds; adopt modular upgrades; parallel permitting tracks and fast‑tracking where safe.\n", "- Confidence/uncertainty: Moderate confidence; depends on plant cooperation and federal/state grant flows.\n", "\n", "Action C. Inclusive economic development and workforce expansion\n", "- Rationale: Unemployment concentrated in EJ neighborhoods; build an economy that absorbs workers from the plant and other sectors; reduce vulnerability to single-plant shocks.\n", "- Major components:\n", " - Local hiring and supplier requirements: target minimum local hire and procurement share on city projects and major private developments.\n", " - Workforce development: sector partnerships (clean energy, logistics, healthcare, construction, water management); apprenticeships and placement guarantees; industry-recognized credentials.\n", " - Small business and entrepreneurship support: microgrants, credit facilities, technical assistance, access to procurement networks; business incubators in EJ neighborhoods.\n", " - Green economy growth: accelerate training for port-related jobs, climate adaptation services, energy efficiency retrofits for homes/commercial buildings.\n", "- Estimated cost and funding sources:\n", " - Cost: $150–350 million in direct program funding over 10 years (plus leverage from private partners).\n", " - Funding: HUD workforce and economic mobility grants; EDA regional economic development grants; state workforce funds; city general funds; philanthropic and corporate philanthropy; small business loan funds (revolving loan fund).\n", "- Timeline:\n", " - Years 1–2: establish partnerships, design curricula, deploy initial apprenticeship programs.\n", " - Years 2–5: scale apprenticeships and job placement; expand incubator and microgrant programs.\n", " - Years 5–10: broaden sector coverage; evaluate and refine local hiring targets; measure displacement dynamics and wage gains.\n", "- Key stakeholders and objections:\n", " - Stakeholders: local workers and unions, community organizations, employers, higher education institutions, small business associations.\n", " - Likely objections: concerns about program effectiveness, budget competition with other priorities, fears of preferential hiring; ensure transparency and objective metrics.\n", "- Measurable success metrics:\n", " - Number of residents trained and placed; unemployment rate reduction in targeted neighborhoods (goal: cut 18% to ≤9% by year 10); number of local contracts awarded; number of new businesses started; wage growth and retention rates; miles of green infrastructure built with job impact.\n", "- Three failure modes and mitigations:\n", " - Skills mismatch: establish real-time labor market data, employer advisory boards, and flexible credentialing; adjust curricula and pathways quickly.\n", " - Underfunding and program fragmentation: create a centralized repository of funding streams; multi‑agency coordination to avoid duplication; regular audits.\n", " - Low job uptake due to relocation risk or stigma: combine with housing protections and neighborhood revitalization to attract workers; provide relocation stipends and housing subsidies if needed.\n", "- Confidence/uncertainty: Moderate to high confidence; success hinges on sustained employer engagement and funding.\n", "\n", "Action D. Housing affordability, displacement prevention, and resilience\n", "- Rationale: Infrastructure investment raises displacement risk if housing costs rise; pursue a stable, equitable housing stock near job hubs.\n", "- Major components:\n", " - Affordable housing production and preservation: use income‑restricted units, tax credits, inclusionary zoning for new developments, and preservation of existing affordable units.\n", " - Anti‑displacement measures: tenant protections, rent stabilization for vulnerable periods, right to counsel, relocation assistance.\n", " - Community land trusts and deed restrictions: preserve long‑term affordability and community control near flood‑prone areas.\n", " - Acquisition and rehabilitation of at‑risk housing: preemptive buyouts in highly flood‑prone zones, with resident supports and relocation pathways.\n", "- Estimated cost and funding sources:\n", " - Cost: $300–600 million over 10 years (capital plus subsidy layers for preservation; ongoing operating subsidies).\n", " - Funding: federal HOME and CDBG funds; low‑income housing tax credits; state housing funds; bonds; local philanthropy; private investment; rural/state affordable housing set‑asides.\n", "- Timeline:\n", " - Years 1–3: policy design; preliminary acquisitions; preservation commitments; set‑aside funds.\n", " - Years 3–6: commence large‑volume affordable housing development; implement anti‑displacement protections citywide.\n", " - Years 6–10: complete significant housing stock; monitor displacement metrics; scale up ongoing preservation.\n", "- Key stakeholders and objections:\n", " - Stakeholders: residents in affected neighborhoods, tenants’ associations, housing developers, landlords, lenders, community groups.\n", " - Likely objections: concerns about density, neighborhood change, impact fees, and regulatory burdens; address with clear community input and equitable distribution of benefits.\n", "- Measurable success metrics:\n", " - Number of affordable units created/preserved; change in median rents in target areas; displacement incidence; time‑to‑housing of affected residents; number of residents assisted with relocation.\n", "- Three failure modes and mitigations:\n", " - Funding gaps and political opposition: pursue multi‑source funding and broad coalition advocacy; implement phased delivery with milestones.\n", " - Delays due to approvals or construction: expedite with pre‑approved zoning pathways; fast‑track permits for affordable housing; ensure community advisory groups.\n", " - Gentrification pressures: enforce inclusionary policies; protect existing tenants; ensure long‑term affordability after initial 10 years.\n", "- Confidence/uncertainty: High confidence if funding and developer commitments align; risk if housing markets tighten or opposition intensifies.\n", "\n", "Action E. Transportation and infrastructure modernization\n", "- Rationale: Connectivity to jobs and evacuation routes; reduce emissions; improve resilience and economic competitiveness.\n", "- Major components:\n", " - Transit upgrades: electrified buses, expanded routes to EJ neighborhoods, resilience‑minded transit hubs.\n", " - Road and drainage improvements: flood‑resilient drainage networks; elevated road segments where necessary; arterial upgrades for evacuation.\n", " - Port and logistics improvements: climate‑resilient port access, pollution controls at port facilities, security and reliability upgrades.\n", " - Multi‑modal corridors and safety: bike/pedestrian networks; safe routes to schools; last‑mile connectivity to housing and jobs.\n", "- Estimated cost and funding sources:\n", " - Cost: $0.8–1.5 billion over 10 years.\n", " - Funding: federal DOT grants (FTA, TIGER/BUILD), state transportation funds, bonds, public‑private partnerships for port facilities, and EV fleet subsidies.\n", "- Timeline:\n", " - Years 1–3: master plan approvals, procurement for initial electrified fleet, design improvements.\n", " - Years 2–6: construction of protected transit corridors, drainage upgrades, and selected port access improvements.\n", " - Years 6–10: completion of major corridors, full fleet conversion, continuous optimization.\n", "- Key stakeholders and objections:\n", " - Stakeholders: commuters, transit riders, port users, freight businesses, environmental groups.\n", " - Likely objections: tolls or user fees; concerns about construction disruption and route changes; property access and eminent domain concerns.\n", "- Measurable success metrics:\n", " - Transit electrification rate; miles of resilient drainage; commute times; port throughput; reduction in flood‑related incidents impacting transport.\n", "- Three failure modes and mitigations:\n", " - Funding or procurement delays: use design‑build contracts to shorten timelines; secure advance funding from multiple sources.\n", " - Community resistance to tolls or fees: offset by subsidies for low‑income residents and transparent benefit reporting.\n", " - Disruption to trade during construction: provide phasing, off‑hours work when possible, and industry liaison groups.\n", "- Confidence/uncertainty: Moderate; depends on federal/state support and port traffic demands.\n", "\n", "Action F. Governance, transparency, equity oversight\n", "- Rationale: Political feasibility and legitimacy require robust accountability and direct community involvement.\n", "- Major components:\n", " - Establish Port Meridia Climate and Justice Authority (PMAJ) with equitable representation from EJ communities, labor, business, housing, environmental groups.\n", " - Public dashboards: budget, project progress, environmental indicators, health outcomes.\n", " - Independent evaluation: annual third‑party audits; annual progress reports; citizen‑initiated inquiries.\n", "- Estimated cost and funding sources:\n", " - Cost: $20–60 million over 10 years (administrative, staff, and independent monitoring).\n", " - Funding: city general fund; grants for governance innovation; philanthropy.\n", "- Timeline:\n", " - Year 1: chartering, appointment processes, initial reporting framework.\n", " - Years 1–10: ongoing governance operations, annual public reporting and independent audits.\n", "- Key stakeholders and objections:\n", " - Stakeholders: general public, EJ communities, developers, employers.\n", " - Likely objections: concerns about governance complexity, bureaucratic overhead, potential capture by interest groups.\n", "- Measurable success metrics:\n", " - Timeliness and completeness of annual reports; community engagement metrics; rate of project approvals on schedule; reduction in disputes.\n", "- Failure modes and mitigations:\n", " - Governance gridlock: establish clear decision–making rules, time‑boxed advisory cycles, and an ombudsperson.\n", " - Perceived inequities in participation: require representative geographic and demographic quotas; rotate seats to ensure broad representation.\n", "- Confidence/uncertainty: High; governance structures are implementable and essential for legitimacy.\n", "\n", "Action G. Financing strategy and revenue plan\n", "- Rationale: A credible funding mix is essential to unlock the 30% budget uplift without destabilizing finances.\n", "- Major components:\n", " - Federal/state grants: maximize eligibility for HUD resilience and EJ grants, NOAA, EPA, EDA programs; unfunded liability mitigation through grants.\n", " - Resilience bonds: issue municipal bonds tied to climate resilience outcomes; interest rates and issuance terms guided by rating agencies.\n", " - Public-private partnerships: leverage private capital for targeted infrastructure (e.g., port, transit, water treatment improvements) with performance‑based contracts.\n", " - Local revenue tools: phased climate resilience tax or fee; targeted incentives to attract new businesses; reallocation of existing departmental budgets with efficiency measures.\n", " - Insurance and risk transfer: leverage reinsurance for flood risk portfolios to stabilize long‑term costs.\n", "- Estimated cost and funding sources:\n", " - Debt and grants combination to fund $2.0–4.0 billion in capital needs across actions A–E over 10 years.\n", "- Timeline:\n", " - Years 1–2: secure grant commitments; issue initial resilience bonds; finalize tax/fee framework with sunset provisions.\n", " - Years 2–10: issue subsequent bonds as projects commence; monitor revenue streams and adjust as needed.\n", "- Stakeholders and objections:\n", " - Stakeholders: taxpayers, bond markets, lenders, state/federal agencies, businesses.\n", " - Likely objections: tax increases or new fees; concerns about debt burden and intergenerational equity.\n", "- Measurable success metrics:\n", " - Amount of funding secured; share of projects funded via grants vs. debt; debt service coverage ratios; timely allocation of funds; number of projects completed per year.\n", "- Three failure modes and mitigations:\n", " - Grant shortfalls or higher borrowing costs: diversify funding; maintain strong fiscal reserves; pre‑commitment of multiple finance sources.\n", " - Public opposition to taxes/fees: deploy clear ROI reporting, sunset clauses, and equity protections in the design.\n", " - Financing delays due to market conditions: pre‑arranged credit facilities; scalable, modular project phasing.\n", "- Confidence/uncertainty: Moderate; highly contingent on external funding markets and political feasibility of local revenue tools.\n", "\n", "Action H. Monitoring, evaluation, and adaptive management\n", "- Rationale: To ensure progress toward environmental justice and economic stability, with the ability to course‑correct.\n", "- Major components:\n", " - Data and dashboards: flood risk reductions, air/water quality metrics, housing affordability and displacement indicators, employment/sectors metrics, community satisfaction.\n", " - Independent review: third‑party evaluators; annual performance reports; mid‑term and end‑term independent reviews.\n", " - Adaptive management: annual reallocation of funds to high‑performing programs; course corrections for underperforming actions.\n", "- Estimated cost and funding sources:\n", " - Cost: $10–30 million over 10 years for data systems, staff, and evaluation contracts.\n", "- Timeline:\n", " - Ongoing from Year 1 onward; annual reviews and adjustments.\n", "- Stakeholders and objections:\n", " - Stakeholders: residents, EJ communities, city departments, funding partners.\n", " - Likely objections: data transparency concerns; perceived bureaucratic overhead.\n", "- Measurable success metrics:\n", " - Compliance with EJ benchmarks; improvements in housing affordability indices; unemployment reductions; flood protection performance metrics; pollution reductions; public satisfaction scores.\n", "- Failure modes and mitigations:\n", " - Data gaps: implement standardized data collection; ensure interoperability; train staff.\n", " - Misaligned incentives: align performance metrics with equity goals; tie funding to measurable outcomes.\n", "- Confidence/uncertainty: High; data‑driven loop is essential to success and reduces political risk.\n", "\n", "Projected timeline (summary)\n", "- Years 1–3: finalize designs, secure initial funding, begin most critical flood protection work, commence plant upgrades, launch workforce programs, establish PMAJ, begin affordable housing preservation, initiate transit and port improvements.\n", "- Years 3–6: scale major construction and upgrades; advance plant transition; expand housing and local hiring programs; deploy first rounds of resilience bonds; implement governance and EJ dashboards.\n", "- Years 7–10: complete remaining infrastructure protections; solidify a diversified economy; sustain workforce and housing programs; evaluate and adapt programs; ensure long‑term financing stability.\n", "\n", "Measurable success metrics (cross‑cutting)\n", "- Environmental justice: air/groundwater quality improvements in EJ neighborhoods; proportion of residents within EJ areas benefiting from new protections; distributional equity of public investments.\n", "- Economic stability: unemployment rate in target neighborhoods reduced toward 9% or lower; number of local residents employed in higher‑wage jobs; share of city contracts awarded to local firms; new business startups and survival rates; median wage growth in targeted sectors.\n", "- Flood resilience: reductions in modeled flood depths near protected facilities; number of critical facilities safeguarded; evacuation times shortened; flood insurance claims decline.\n", "- Housing: affordable units added/preserved; displacement rates; stabilized rents in target neighborhoods.\n", "- Governance: timely completion of dashboards and reports; stakeholder satisfaction; number of citizen inquiries, resolved within target timeframes.\n", "\n", "Probability estimates and confidence intervals (net positive outcomes for EJ and economic stability)\n", "- Overall assessment approach: expert judgment combined with scenario thinking and sensitivity analysis across funding, climate risk, and program uptake. We present probabilistic ranges to reflect uncertainty in external funding, political appetite, and implementation challenges.\n", "- Probability plan achieves net positive outcomes for environmental justice (EJ) within 10 years:\n", " - Central estimate: 0.58 (58%)\n", " - 90% CI: 0.42 – 0.74\n", " - Interpretation: There is a fairly high chance that EJ indicators (air/water quality improvements, housing protections, equitable access to jobs) improve relative to baseline, assuming steady funding and strong governance.\n", "- Probability plan achieves net positive outcomes for economic stability within 10 years:\n", " - Central estimate: 0.65 (65%)\n", " - 90% CI: 0.50 – 0.78\n", " - Interpretation: A majority chance that unemployment in targeted neighborhoods stays low and that local jobs diversify and stabilize, given robust workforce programs and capital projects.\n", "- Joint probability that both EJ and economic stability show net positive outcomes within 10 years:\n", " - Assuming moderate positive correlation between economic and EJ benefits (ρ ≈ 0.3–0.5), joint probability ≈ 0.35–0.50 (35–50%), with 90% CI roughly 0.24–0.63.\n", "- Note: These are estimated probabilities with wide but plausible ranges; actual outcomes depend on federal grant success, political support for new revenue tools, plant cooperation, construction efficiency, and beneficiary engagement. The plan intentionally builds buffers (phased funding, governance, and adaptive management) to improve these odds.\n", "\n", "Executive summary (150 words)\n", "Port Meridia must harden against 1.2 m sea‑level rise, curb pollution from a major local plant, and grow an inclusive economy that can absorb workers displaced by environmental and industrial change. The 10‑year plan blends aggressive flood protection with nature‑based solutions, a just transition for plant workers, and a diversified, locally anchored economy focused on clean energy, logistics, healthcare, and resilient housing. It pairs a robust funding strategy—federal grants, resilience bonds, and targeted local revenue—with phased implementation to minimize displacement and deliver measurable benefits in EJ outcomes and job creation. A standing Climate and Justice Authority will ensure community voice and ongoing accountability, while dashboards and independent evaluations drive adaptive management. The plan aims for meaningful EJ improvements and a stable, expanding economy within a decade, albeit with identified risks and calibrated mitigations.\n", "\n", "Material assumptions\n", "- Demographic and economic conditions: Port Meridia’s population remains around 420,000; labor market dynamics persist with an 18% unemployment rate in EJ neighborhoods unless targeted programs succeed.\n", "- Sea‑level rise and flood risk: Projections of 1.2 m rise and intensified storm surge over 30 years are used for design; climate uncertainty acknowledged with adaptable protections.\n", "- Plant operations: The chemical plant remains a meaningful but not sole economic driver; cooperation for upgrades and a potential transition are assumed, with workers eligible for retraining and relocation supports.\n", "- Funding and financing: Federal and state grants for resilience and EJ are available; resilient bonds can be issued with favorable terms; local revenue tools are politically feasible with sunset provisions; private‑public partnerships are achievable for select projects.\n", "- Housing and displacement: Availability of federal housing funds, tax credits, and resilient zoning tools; community opposition manageable with targeted outreach and transparent planning.\n", "- Governance: Political willingness to establish a Climate and Justice Authority and maintain robust public dashboards; sustained leadership and community engagement.\n", "- Implementation capability: City departments can execute, coordinate across agencies, and maintain adaptive management with independent evaluators.\n", "- Inflation and cost: Costs reflect 2025–2035 price levels; contingency reserves are included for overruns; financing terms assume moderate interest rates.\n", "- Environmental outcomes: Monitoring data accurately reflect air and water quality changes; EJ neighborhoods see tangible benefits from planned investments.\n", "- External shocks: Plan assumes no extreme, unforeseen events (e.g., regional disasters) that would overwhelm funding or shift priorities; but includes contingency and scalable design to absorb shocks.\n", "\n", "If you’d like, I can tailor the cost ranges, funding allocations by year, or the stakeholder engagement plan to a specific political context or grant program you’re targeting.\n", "\n", "\n" ] } ], "source": [ "print(together)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "judge = f\"\"\"You are judging a competition between {len(competitors)} competitors.\n", "Each model has been given this question:\n", "\n", "{question}\n", "\n", "Your job is to evaluate each response for clarity and strength of argument, and rank them in order of best to worst.\n", "Respond with JSON, and only JSON, with the following format:\n", "{{\"results\": [\"best competitor number\", \"second best competitor number\", \"third best competitor number\", ...]}}\n", "\n", "Here are the responses from each competitor:\n", "\n", "{together}\n", "\n", "Now respond with the JSON with the ranked order of the competitors, nothing else. Do not include markdown formatting or code blocks.\"\"\"\n" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "You are judging a competition between 1 competitors.\n", "Each model has been given this question:\n", "\n", "You are an independent advisor to the mayor of Port Meridia (population 420,000), a coastal city facing (a) a projected 1.2 m sea-level rise and more intense storm surge over 30 years, (b) 18% unemployment concentrated in neighborhoods adjacent to a large chemical-manufacturing plant that provides 25% of the city’s jobs but routinely discharges pollutants, and (c) a municipal budget that can increase spending by up to 30% over five years only if taxes are raised or federal grants are secured. Devise a detailed, politically feasible 10-year plan that minimizes displacement, protects the city from flooding, phases out the most harmful pollution, and creates inclusive economic opportunity; for each major action state the rationale, estimated cost and funding sources (with realistic grant/tax assumptions), timeline, key stakeholders and likely objections, measurable success metrics, and the three most likely failure modes with specific mitigations; provide probability estimates with confidence intervals that the plan will achieve net positive outcomes for both environmental justice and economic stability within 10 years; conclude with a 150-word executive summary and list all material assumptions you made.\n", "\n", "Your job is to evaluate each response for clarity and strength of argument, and rank them in order of best to worst.\n", "Respond with JSON, and only JSON, with the following format:\n", "{\"results\": [\"best competitor number\", \"second best competitor number\", \"third best competitor number\", ...]}\n", "\n", "Here are the responses from each competitor:\n", "\n", "# Response from competitor 1\n", "\n", "Executive framing\n", "Port Meridia faces three intertwined challenges: (1) a 1.2 m sea‑level rise with intensified storm surge over 30 years; (2) an 18% unemployment gap concentrated in neighborhoods near a large chemical plant that provides 25% of city jobs but cumulatively degrades air/water quality; (3) a municipal budget capable of up to a 30% spending increase over five years only if taxes rise or federal grants are secured. This plan proposals a coordinated, 10‑year, financially feasible program that minimizes displacement, shields people from flood risk, reduces the most harmful pollution, and creates inclusive economic opportunity. It relies on a mix of federal grants, bonds, private partnerships, and targeted local revenue, with strong community engagement and accountability.\n", "\n", "Ten-year plan at a glance (major actions)\n", "- Action A: Build integrated flood protection for critical assets and vulnerable neighborhoods; expand natural infrastructure; elevate essential facilities; improve drainage and evacuation routes.\n", "- Action B: Accelerate pollution reduction and a just transition for the plant’s workers; upgrade controls; monitor air/water quality; plan relocation/repurposing if needed; ensure community benefits.\n", "- Action C: Deploy inclusive economic development and workforce programs; prioritize local hiring on city projects; diversify the economy toward clean industries and port/logistics.\n", "- Action D: Preserve and expand affordable housing; prevent displacement; use inclusionary zoning, community land trusts, and buyout/relocation supports where risk is highest.\n", "- Action E: Modernize transportation and critical infrastructure to withstand flooding, reduce emissions, and connect neighborhoods to opportunity.\n", "- Action F: Strengthen governance, transparency, and EJ accountability; establish a standing Climate and Justice Authority with community representation.\n", "- Action G: Create a robust, diversified financing strategy; blend federal grants, resilience bonds, public-private partnerships, and targeted local revenue; secure a five‑to‑ten year funding pipeline.\n", "- Action H: Continuous monitoring, evaluation, and adaptive management; deploy independent metrics, public dashboards, and annual reporting to guide adjustments.\n", "\n", "Detailed major actions (with required fields)\n", "\n", "Action A. Flood protection for high‑risk areas and critical infrastructure\n", "- Rationale: 1.2 m sea‑level rise and stronger surges threaten hospitals, water treatment, schools, and large employers; uncontrolled flooding creates displacement risk and undermines the tax base.\n", "- Major components:\n", " - Engineering: hybrid flood defenses (seawalls, surge barriers, tidal gates) sized for design storms and projected sea‑level rise.\n", " - Natural infrastructure: living shorelines, wetlands restoration, dune systems, green streets, bioswales.\n", " - Infrastructure retrofits: flood-proofing for hospitals, water plant, emergency operations center, police/fire stations; elevate critical electrical/IT assets.\n", " - Evacuation and resilience routing: dedicated emergency corridors, upgraded pump stations, backflow prevention.\n", "- Estimated cost and funding sources:\n", " - Cost: $2.0–3.5 billion over 10 years (phased).\n", " - Funding: federal BRIC/NOAA grants, HUD CDBG‑Mitigation, EPA grants, state resilience funds; municipal general obligation bonds; private‑public partnerships; potential modest climate resilience tax or fee with sunset after the first 6–8 years.\n", "- Timeline:\n", " - Years 1–3: design approvals, environmental reviews, early procurement for critical facilities.\n", " - Years 2–6: primary construction of protection for top-priority zones and facilities; begin natural infrastructure projects.\n", " - Years 6–10: expand protections to remaining areas; retrofit additional facilities; optimize operations.\n", "- Key stakeholders and objections:\n", " - Stakeholders: residents in flood zones, hospitals, school districts, port operators, small business associations, environmental groups.\n", " - Likely objections: high up-front cost, potential displacement risks during construction, competing budget needs.\n", "- Measurable success metrics:\n", " - Reduction in modeled flood depths for critical facilities (e.g., >50% in protected zones).\n", " - Percent of critical facilities shielded from projected flood events.\n", " - Kilometers of living shoreline and miles of improved drainage; evacuation time improvements; insured loss reductions.\n", "- Three likely failure modes and mitigations:\n", " - Funding shortfalls or delays: implement phased design with clear milestones; establish reserve contingencies; secure multi-year commitments from federal/state sources.\n", " - Construction disruption in neighborhoods: use tight project management, community liaisons, temporary relocations with stipends; nonessential work scheduled in off-peak seasons.\n", " - Underestimation of sea‑level rise risk: adopt adaptive design with modular extensions and flexible permitting; est. annual review of risk data and design tweaks.\n", "- Confidence/uncertainty: Moderate to high confidence in phased delivery if federal/state funds materialize and procurement is aggressive.\n", "\n", "Action B. Pollution reduction and just transition for the plant\n", "- Rationale: 18% unemployment near a plant that provides 25% of city jobs but incurs pollutant discharges; local health and climate benefits align with EJ goals; long-term local prosperity requires cleaner industry and worker retraining.\n", "- Major components:\n", " - Emissions and discharge controls: upgraded scrubbers, filtration, smokestack improvements, process modifications to reduce hazardous byproducts.\n", " - Regulatory tightening with milestones: enforce pollutant caps; continuous air and water monitoring with public dashboards.\n", " - Transition planning for workers: career counseling, retraining in higher‑skill clean‑tech, port/logistics, healthcare, or energy sectors; wage‑support programs; relocation or redeployment assistance if plant phase‑out or relocation occurs.\n", " - Community benefits agreements (CBAs): job locality targets, local procurement, and long‑term community investment commitments.\n", "- Estimated cost and funding sources:\n", " - Cost: $0.5–1.0 billion for plant upgrades and process changes; $50–120 million for workforce retraining; $200–400 million for transition/relocation supports if needed.\n", " - Funding: EPA/state environmental grants; USDOT/EDA economic development funds for clean‑tech transitions; city bonds; plant capital investments; philanthropic and private capital; potential state green‑jobs grants.\n", "- Timeline:\n", " - Years 1–3: design and begin plant upgrades; establish EJ oversight and CBAs; initiate retraining programs.\n", " - Years 3–7: complete major plant upgrades; scale workforce transitions; monitor air/water metrics and health indicators.\n", " - Years 6–10: evaluate ongoing plant operations; implement relocation/repurposing if warranted; sustain community investments.\n", "- Key stakeholders and objections:\n", " - Stakeholders: plant management, workers and unions, nearby residents, independent monitors, environmental groups.\n", " - Likely objections: plant cost burden, risk of job losses, skepticism about long-term benefits; concerns about compliance burden and reliability of new processes.\n", "- Measurable success metrics:\n", " - Pollutant reductions (tons/year of key pollutants) and compliance with stricter caps.\n", " - Air quality indices in nearby neighborhoods; water quality metrics around discharge points.\n", " - Number of workers retrained and placed in higher‑wage jobs; retained employment in the new sector; CBAs payout and local procurement share.\n", " - Progress toward a cleaner, diversified industrial base in the city.\n", "- Three likely failure modes and mitigations:\n", " - Plant resistance to upgrades or relocation: use binding performance milestones, enforceable penalties for noncompliance, and incentive packages tied to emissions reductions; align with long‑term city economic diversification plans.\n", " - Inadequate worker retraining outcomes: design continuous, sector‑wide retraining with employer partners; offer portable credentials; provide wage‑top‑ups and relocation stipends.\n", " - Cost overruns or delayed permits: reserve contingency funds; adopt modular upgrades; parallel permitting tracks and fast‑tracking where safe.\n", "- Confidence/uncertainty: Moderate confidence; depends on plant cooperation and federal/state grant flows.\n", "\n", "Action C. Inclusive economic development and workforce expansion\n", "- Rationale: Unemployment concentrated in EJ neighborhoods; build an economy that absorbs workers from the plant and other sectors; reduce vulnerability to single-plant shocks.\n", "- Major components:\n", " - Local hiring and supplier requirements: target minimum local hire and procurement share on city projects and major private developments.\n", " - Workforce development: sector partnerships (clean energy, logistics, healthcare, construction, water management); apprenticeships and placement guarantees; industry-recognized credentials.\n", " - Small business and entrepreneurship support: microgrants, credit facilities, technical assistance, access to procurement networks; business incubators in EJ neighborhoods.\n", " - Green economy growth: accelerate training for port-related jobs, climate adaptation services, energy efficiency retrofits for homes/commercial buildings.\n", "- Estimated cost and funding sources:\n", " - Cost: $150–350 million in direct program funding over 10 years (plus leverage from private partners).\n", " - Funding: HUD workforce and economic mobility grants; EDA regional economic development grants; state workforce funds; city general funds; philanthropic and corporate philanthropy; small business loan funds (revolving loan fund).\n", "- Timeline:\n", " - Years 1–2: establish partnerships, design curricula, deploy initial apprenticeship programs.\n", " - Years 2–5: scale apprenticeships and job placement; expand incubator and microgrant programs.\n", " - Years 5–10: broaden sector coverage; evaluate and refine local hiring targets; measure displacement dynamics and wage gains.\n", "- Key stakeholders and objections:\n", " - Stakeholders: local workers and unions, community organizations, employers, higher education institutions, small business associations.\n", " - Likely objections: concerns about program effectiveness, budget competition with other priorities, fears of preferential hiring; ensure transparency and objective metrics.\n", "- Measurable success metrics:\n", " - Number of residents trained and placed; unemployment rate reduction in targeted neighborhoods (goal: cut 18% to ≤9% by year 10); number of local contracts awarded; number of new businesses started; wage growth and retention rates; miles of green infrastructure built with job impact.\n", "- Three failure modes and mitigations:\n", " - Skills mismatch: establish real-time labor market data, employer advisory boards, and flexible credentialing; adjust curricula and pathways quickly.\n", " - Underfunding and program fragmentation: create a centralized repository of funding streams; multi‑agency coordination to avoid duplication; regular audits.\n", " - Low job uptake due to relocation risk or stigma: combine with housing protections and neighborhood revitalization to attract workers; provide relocation stipends and housing subsidies if needed.\n", "- Confidence/uncertainty: Moderate to high confidence; success hinges on sustained employer engagement and funding.\n", "\n", "Action D. Housing affordability, displacement prevention, and resilience\n", "- Rationale: Infrastructure investment raises displacement risk if housing costs rise; pursue a stable, equitable housing stock near job hubs.\n", "- Major components:\n", " - Affordable housing production and preservation: use income‑restricted units, tax credits, inclusionary zoning for new developments, and preservation of existing affordable units.\n", " - Anti‑displacement measures: tenant protections, rent stabilization for vulnerable periods, right to counsel, relocation assistance.\n", " - Community land trusts and deed restrictions: preserve long‑term affordability and community control near flood‑prone areas.\n", " - Acquisition and rehabilitation of at‑risk housing: preemptive buyouts in highly flood‑prone zones, with resident supports and relocation pathways.\n", "- Estimated cost and funding sources:\n", " - Cost: $300–600 million over 10 years (capital plus subsidy layers for preservation; ongoing operating subsidies).\n", " - Funding: federal HOME and CDBG funds; low‑income housing tax credits; state housing funds; bonds; local philanthropy; private investment; rural/state affordable housing set‑asides.\n", "- Timeline:\n", " - Years 1–3: policy design; preliminary acquisitions; preservation commitments; set‑aside funds.\n", " - Years 3–6: commence large‑volume affordable housing development; implement anti‑displacement protections citywide.\n", " - Years 6–10: complete significant housing stock; monitor displacement metrics; scale up ongoing preservation.\n", "- Key stakeholders and objections:\n", " - Stakeholders: residents in affected neighborhoods, tenants’ associations, housing developers, landlords, lenders, community groups.\n", " - Likely objections: concerns about density, neighborhood change, impact fees, and regulatory burdens; address with clear community input and equitable distribution of benefits.\n", "- Measurable success metrics:\n", " - Number of affordable units created/preserved; change in median rents in target areas; displacement incidence; time‑to‑housing of affected residents; number of residents assisted with relocation.\n", "- Three failure modes and mitigations:\n", " - Funding gaps and political opposition: pursue multi‑source funding and broad coalition advocacy; implement phased delivery with milestones.\n", " - Delays due to approvals or construction: expedite with pre‑approved zoning pathways; fast‑track permits for affordable housing; ensure community advisory groups.\n", " - Gentrification pressures: enforce inclusionary policies; protect existing tenants; ensure long‑term affordability after initial 10 years.\n", "- Confidence/uncertainty: High confidence if funding and developer commitments align; risk if housing markets tighten or opposition intensifies.\n", "\n", "Action E. Transportation and infrastructure modernization\n", "- Rationale: Connectivity to jobs and evacuation routes; reduce emissions; improve resilience and economic competitiveness.\n", "- Major components:\n", " - Transit upgrades: electrified buses, expanded routes to EJ neighborhoods, resilience‑minded transit hubs.\n", " - Road and drainage improvements: flood‑resilient drainage networks; elevated road segments where necessary; arterial upgrades for evacuation.\n", " - Port and logistics improvements: climate‑resilient port access, pollution controls at port facilities, security and reliability upgrades.\n", " - Multi‑modal corridors and safety: bike/pedestrian networks; safe routes to schools; last‑mile connectivity to housing and jobs.\n", "- Estimated cost and funding sources:\n", " - Cost: $0.8–1.5 billion over 10 years.\n", " - Funding: federal DOT grants (FTA, TIGER/BUILD), state transportation funds, bonds, public‑private partnerships for port facilities, and EV fleet subsidies.\n", "- Timeline:\n", " - Years 1–3: master plan approvals, procurement for initial electrified fleet, design improvements.\n", " - Years 2–6: construction of protected transit corridors, drainage upgrades, and selected port access improvements.\n", " - Years 6–10: completion of major corridors, full fleet conversion, continuous optimization.\n", "- Key stakeholders and objections:\n", " - Stakeholders: commuters, transit riders, port users, freight businesses, environmental groups.\n", " - Likely objections: tolls or user fees; concerns about construction disruption and route changes; property access and eminent domain concerns.\n", "- Measurable success metrics:\n", " - Transit electrification rate; miles of resilient drainage; commute times; port throughput; reduction in flood‑related incidents impacting transport.\n", "- Three failure modes and mitigations:\n", " - Funding or procurement delays: use design‑build contracts to shorten timelines; secure advance funding from multiple sources.\n", " - Community resistance to tolls or fees: offset by subsidies for low‑income residents and transparent benefit reporting.\n", " - Disruption to trade during construction: provide phasing, off‑hours work when possible, and industry liaison groups.\n", "- Confidence/uncertainty: Moderate; depends on federal/state support and port traffic demands.\n", "\n", "Action F. Governance, transparency, equity oversight\n", "- Rationale: Political feasibility and legitimacy require robust accountability and direct community involvement.\n", "- Major components:\n", " - Establish Port Meridia Climate and Justice Authority (PMAJ) with equitable representation from EJ communities, labor, business, housing, environmental groups.\n", " - Public dashboards: budget, project progress, environmental indicators, health outcomes.\n", " - Independent evaluation: annual third‑party audits; annual progress reports; citizen‑initiated inquiries.\n", "- Estimated cost and funding sources:\n", " - Cost: $20–60 million over 10 years (administrative, staff, and independent monitoring).\n", " - Funding: city general fund; grants for governance innovation; philanthropy.\n", "- Timeline:\n", " - Year 1: chartering, appointment processes, initial reporting framework.\n", " - Years 1–10: ongoing governance operations, annual public reporting and independent audits.\n", "- Key stakeholders and objections:\n", " - Stakeholders: general public, EJ communities, developers, employers.\n", " - Likely objections: concerns about governance complexity, bureaucratic overhead, potential capture by interest groups.\n", "- Measurable success metrics:\n", " - Timeliness and completeness of annual reports; community engagement metrics; rate of project approvals on schedule; reduction in disputes.\n", "- Failure modes and mitigations:\n", " - Governance gridlock: establish clear decision–making rules, time‑boxed advisory cycles, and an ombudsperson.\n", " - Perceived inequities in participation: require representative geographic and demographic quotas; rotate seats to ensure broad representation.\n", "- Confidence/uncertainty: High; governance structures are implementable and essential for legitimacy.\n", "\n", "Action G. Financing strategy and revenue plan\n", "- Rationale: A credible funding mix is essential to unlock the 30% budget uplift without destabilizing finances.\n", "- Major components:\n", " - Federal/state grants: maximize eligibility for HUD resilience and EJ grants, NOAA, EPA, EDA programs; unfunded liability mitigation through grants.\n", " - Resilience bonds: issue municipal bonds tied to climate resilience outcomes; interest rates and issuance terms guided by rating agencies.\n", " - Public-private partnerships: leverage private capital for targeted infrastructure (e.g., port, transit, water treatment improvements) with performance‑based contracts.\n", " - Local revenue tools: phased climate resilience tax or fee; targeted incentives to attract new businesses; reallocation of existing departmental budgets with efficiency measures.\n", " - Insurance and risk transfer: leverage reinsurance for flood risk portfolios to stabilize long‑term costs.\n", "- Estimated cost and funding sources:\n", " - Debt and grants combination to fund $2.0–4.0 billion in capital needs across actions A–E over 10 years.\n", "- Timeline:\n", " - Years 1–2: secure grant commitments; issue initial resilience bonds; finalize tax/fee framework with sunset provisions.\n", " - Years 2–10: issue subsequent bonds as projects commence; monitor revenue streams and adjust as needed.\n", "- Stakeholders and objections:\n", " - Stakeholders: taxpayers, bond markets, lenders, state/federal agencies, businesses.\n", " - Likely objections: tax increases or new fees; concerns about debt burden and intergenerational equity.\n", "- Measurable success metrics:\n", " - Amount of funding secured; share of projects funded via grants vs. debt; debt service coverage ratios; timely allocation of funds; number of projects completed per year.\n", "- Three failure modes and mitigations:\n", " - Grant shortfalls or higher borrowing costs: diversify funding; maintain strong fiscal reserves; pre‑commitment of multiple finance sources.\n", " - Public opposition to taxes/fees: deploy clear ROI reporting, sunset clauses, and equity protections in the design.\n", " - Financing delays due to market conditions: pre‑arranged credit facilities; scalable, modular project phasing.\n", "- Confidence/uncertainty: Moderate; highly contingent on external funding markets and political feasibility of local revenue tools.\n", "\n", "Action H. Monitoring, evaluation, and adaptive management\n", "- Rationale: To ensure progress toward environmental justice and economic stability, with the ability to course‑correct.\n", "- Major components:\n", " - Data and dashboards: flood risk reductions, air/water quality metrics, housing affordability and displacement indicators, employment/sectors metrics, community satisfaction.\n", " - Independent review: third‑party evaluators; annual performance reports; mid‑term and end‑term independent reviews.\n", " - Adaptive management: annual reallocation of funds to high‑performing programs; course corrections for underperforming actions.\n", "- Estimated cost and funding sources:\n", " - Cost: $10–30 million over 10 years for data systems, staff, and evaluation contracts.\n", "- Timeline:\n", " - Ongoing from Year 1 onward; annual reviews and adjustments.\n", "- Stakeholders and objections:\n", " - Stakeholders: residents, EJ communities, city departments, funding partners.\n", " - Likely objections: data transparency concerns; perceived bureaucratic overhead.\n", "- Measurable success metrics:\n", " - Compliance with EJ benchmarks; improvements in housing affordability indices; unemployment reductions; flood protection performance metrics; pollution reductions; public satisfaction scores.\n", "- Failure modes and mitigations:\n", " - Data gaps: implement standardized data collection; ensure interoperability; train staff.\n", " - Misaligned incentives: align performance metrics with equity goals; tie funding to measurable outcomes.\n", "- Confidence/uncertainty: High; data‑driven loop is essential to success and reduces political risk.\n", "\n", "Projected timeline (summary)\n", "- Years 1–3: finalize designs, secure initial funding, begin most critical flood protection work, commence plant upgrades, launch workforce programs, establish PMAJ, begin affordable housing preservation, initiate transit and port improvements.\n", "- Years 3–6: scale major construction and upgrades; advance plant transition; expand housing and local hiring programs; deploy first rounds of resilience bonds; implement governance and EJ dashboards.\n", "- Years 7–10: complete remaining infrastructure protections; solidify a diversified economy; sustain workforce and housing programs; evaluate and adapt programs; ensure long‑term financing stability.\n", "\n", "Measurable success metrics (cross‑cutting)\n", "- Environmental justice: air/groundwater quality improvements in EJ neighborhoods; proportion of residents within EJ areas benefiting from new protections; distributional equity of public investments.\n", "- Economic stability: unemployment rate in target neighborhoods reduced toward 9% or lower; number of local residents employed in higher‑wage jobs; share of city contracts awarded to local firms; new business startups and survival rates; median wage growth in targeted sectors.\n", "- Flood resilience: reductions in modeled flood depths near protected facilities; number of critical facilities safeguarded; evacuation times shortened; flood insurance claims decline.\n", "- Housing: affordable units added/preserved; displacement rates; stabilized rents in target neighborhoods.\n", "- Governance: timely completion of dashboards and reports; stakeholder satisfaction; number of citizen inquiries, resolved within target timeframes.\n", "\n", "Probability estimates and confidence intervals (net positive outcomes for EJ and economic stability)\n", "- Overall assessment approach: expert judgment combined with scenario thinking and sensitivity analysis across funding, climate risk, and program uptake. We present probabilistic ranges to reflect uncertainty in external funding, political appetite, and implementation challenges.\n", "- Probability plan achieves net positive outcomes for environmental justice (EJ) within 10 years:\n", " - Central estimate: 0.58 (58%)\n", " - 90% CI: 0.42 – 0.74\n", " - Interpretation: There is a fairly high chance that EJ indicators (air/water quality improvements, housing protections, equitable access to jobs) improve relative to baseline, assuming steady funding and strong governance.\n", "- Probability plan achieves net positive outcomes for economic stability within 10 years:\n", " - Central estimate: 0.65 (65%)\n", " - 90% CI: 0.50 – 0.78\n", " - Interpretation: A majority chance that unemployment in targeted neighborhoods stays low and that local jobs diversify and stabilize, given robust workforce programs and capital projects.\n", "- Joint probability that both EJ and economic stability show net positive outcomes within 10 years:\n", " - Assuming moderate positive correlation between economic and EJ benefits (ρ ≈ 0.3–0.5), joint probability ≈ 0.35–0.50 (35–50%), with 90% CI roughly 0.24–0.63.\n", "- Note: These are estimated probabilities with wide but plausible ranges; actual outcomes depend on federal grant success, political support for new revenue tools, plant cooperation, construction efficiency, and beneficiary engagement. The plan intentionally builds buffers (phased funding, governance, and adaptive management) to improve these odds.\n", "\n", "Executive summary (150 words)\n", "Port Meridia must harden against 1.2 m sea‑level rise, curb pollution from a major local plant, and grow an inclusive economy that can absorb workers displaced by environmental and industrial change. The 10‑year plan blends aggressive flood protection with nature‑based solutions, a just transition for plant workers, and a diversified, locally anchored economy focused on clean energy, logistics, healthcare, and resilient housing. It pairs a robust funding strategy—federal grants, resilience bonds, and targeted local revenue—with phased implementation to minimize displacement and deliver measurable benefits in EJ outcomes and job creation. A standing Climate and Justice Authority will ensure community voice and ongoing accountability, while dashboards and independent evaluations drive adaptive management. The plan aims for meaningful EJ improvements and a stable, expanding economy within a decade, albeit with identified risks and calibrated mitigations.\n", "\n", "Material assumptions\n", "- Demographic and economic conditions: Port Meridia’s population remains around 420,000; labor market dynamics persist with an 18% unemployment rate in EJ neighborhoods unless targeted programs succeed.\n", "- Sea‑level rise and flood risk: Projections of 1.2 m rise and intensified storm surge over 30 years are used for design; climate uncertainty acknowledged with adaptable protections.\n", "- Plant operations: The chemical plant remains a meaningful but not sole economic driver; cooperation for upgrades and a potential transition are assumed, with workers eligible for retraining and relocation supports.\n", "- Funding and financing: Federal and state grants for resilience and EJ are available; resilient bonds can be issued with favorable terms; local revenue tools are politically feasible with sunset provisions; private‑public partnerships are achievable for select projects.\n", "- Housing and displacement: Availability of federal housing funds, tax credits, and resilient zoning tools; community opposition manageable with targeted outreach and transparent planning.\n", "- Governance: Political willingness to establish a Climate and Justice Authority and maintain robust public dashboards; sustained leadership and community engagement.\n", "- Implementation capability: City departments can execute, coordinate across agencies, and maintain adaptive management with independent evaluators.\n", "- Inflation and cost: Costs reflect 2025–2035 price levels; contingency reserves are included for overruns; financing terms assume moderate interest rates.\n", "- Environmental outcomes: Monitoring data accurately reflect air and water quality changes; EJ neighborhoods see tangible benefits from planned investments.\n", "- External shocks: Plan assumes no extreme, unforeseen events (e.g., regional disasters) that would overwhelm funding or shift priorities; but includes contingency and scalable design to absorb shocks.\n", "\n", "If you’d like, I can tailor the cost ranges, funding allocations by year, or the stakeholder engagement plan to a specific political context or grant program you’re targeting.\n", "\n", "\n", "\n", "Now respond with the JSON with the ranked order of the competitors, nothing else. Do not include markdown formatting or code blocks.\n" ] } ], "source": [ "print(judge)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "judge_messages = [{\"role\": \"user\", \"content\": judge}]" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\"results\": [\"1\"]}\n" ] } ], "source": [ "# Judgement time!\n", "\n", "openai = OpenAI()\n", "response = openai.chat.completions.create(\n", " model=\"gpt-5-mini\",\n", " messages=judge_messages,\n", ")\n", "results = response.choices[0].message.content\n", "print(results)\n" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Rank 1: gpt-5-nano\n" ] } ], "source": [ "# OK let's turn this into results!\n", "\n", "results_dict = json.loads(results)\n", "ranks = results_dict[\"results\"]\n", "for index, result in enumerate(ranks):\n", " competitor = competitors[int(result)-1]\n", " print(f\"Rank {index+1}: {competitor}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", "

Exercise

\n", " Which pattern(s) did this use? Try updating this to add another Agentic design pattern.\n", " \n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", "

Commercial implications

\n", " These kinds of patterns - to send a task to multiple models, and evaluate results,\n", " are common where you need to improve the quality of your LLM response. This approach can be universally applied\n", " to business projects where accuracy is critical.\n", " \n", "
" ] } ], "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.12" } }, "nbformat": 4, "nbformat_minor": 2 }