Skip to content

Instantly share code, notes, and snippets.

@mgaitan
Created December 3, 2025 23:33
Show Gist options
  • Select an option

  • Save mgaitan/73037fc051f2ec9c5f837ebfc0372af4 to your computer and use it in GitHub Desktop.

Select an option

Save mgaitan/73037fc051f2ec9c5f837ebfc0372af4 to your computer and use it in GitHub Desktop.
$ llm \
  --schema '{
    "type": "object",
    "properties": {
      "customer": {
        "type": "string",
        "description": "Nombre del cliente"
      },
      "items": {
        "type": "array",
        "description": "Productos incluidos en la venta",
        "items": {
          "type": "object",
          "properties": {
            "product": {
              "type": "string",
              "description": "Nombre genérico del producto (galletitas, leche, Pepsi, etc.)"
            },
            "brand": {
              "type": "string",
              "description": "Marca si está mencionada (Sancor, Pepsi, etc.)"
            },
            "quantity": {
              "type": "number",
              "description": "Cantidad numérica (2, 3, etc.)"
            },
            "unit": {
              "type": "string",
              "description": "Unidad de medida (unidades, litros, etc.)"
            },
            "package_size": {
              "type": "string",
              "description": "Presentación del producto (por ejemplo \"1.5 L\", \"1 L\")"
            }
          },
          "required": ["product", "quantity"]
        }
      }
    },
    "required": ["customer", "items"]
  }' \
  --system "Devuelve solo un JSON que represente la venta." \
  "Crear una venta para Juan, con dos galletitas saladas, tres litros de leche Sancor y dos Pepsi de litro y medio"

Out:

{
  "customer": "Juan",
  "items": [
    {
      "product": "galletitas saladas",
      "quantity": 2,
      "unit": "unidades"
    },
    {
      "product": "leche",
      "quantity": 3,
      "brand": "Sancor",
      "unit": "litros"
    },
    {
      "product": "Pepsi",
      "quantity": 2,
      "package_size": "1.5 L",
      "unit": "unidades"
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment