{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Prompt Engineering Techniques for Developers\n",
        "Xenors practice notebook. Run each cell and compare the output with the tutorial page.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Validate model JSON instead of trusting it\n",
        "Treat model output as untrusted input and validate it like an API response.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import json\n",
        "raw='{\"priority\":\"high\",\"score\":0.87}'\n",
        "obj=json.loads(raw)\n",
        "assert obj['priority'] in {'low','medium','high'}\n",
        "assert 0<=obj['score']<=1\n",
        "print(obj)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Expected/checkpoint**\n",
        "```text\n{'priority': 'high', 'score': 0.87}\n```\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Create a tiny regression test set\n",
        "Prompt changes should be tested against stable examples before deployment.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "tests=[('2+2','4'),('capital of France','Paris')]\n",
        "for prompt,expected in tests:\n",
        "    print(prompt,'-> expected:',expected)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Expected/checkpoint**\n",
        "```text\n2+2 -> expected: 4\ncapital of France -> expected: Paris\n```\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.x"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}