{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "263b11c8",
   "metadata": {},
   "source": [
    "# LLM workflow examples\n",
    "\n",
    "Anton Antonov  \n",
    "[LLM::Functions at GitHub](https://github.com/antononcube/Raku-LLM-Functions)  \n",
    "[RakuForPrediction at WordPress](https://rakuforprediction.wordpress.com)   \n",
    "May 2025"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d779a01f",
   "metadata": {},
   "source": [
    "----\n",
    "\n",
    "## Introduction"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "39e5caa7",
   "metadata": {},
   "source": [
    "This notebook has examples of using Large Language Models (LLMs) for different _programmer_ tasks using Raku's LLM packages\n",
    "[\"LLM::Functions\"](https://raku.land/zef:antononcube/LLM::Functions) and [\"LLM::Prompts\"](https://raku.land/zef:antononcube/LLM::Prompts). \n",
    "\n",
    "**Remark:** Under the hood of \"LLM::Functions\" specialized LLM Web API services packages are used, like, [\"WWW::OpenAI\"](https://raku.land/zef:antononcube/WWW::OpenAI), [\"WWW::Gemini\"](https://raku.land/zef:antononcube/WWW::Gemini), [\"WWW::LLaMA\"](https://raku.land/zef:antononcube/WWW::LLaMA), and others. "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b6132b39",
   "metadata": {},
   "source": [
    "-----\n",
    "\n",
    "## Setup"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0d5cb43b",
   "metadata": {},
   "source": [
    "These packages are loaded by default if using [\"Jupyter::Chatbook\"](https://raku.land/zef:antononcube/Jupyter::Chatbook):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cabbabd0",
   "metadata": {},
   "outputs": [],
   "source": [
    "#use LLM::Functions;\n",
    "#use LLM::Prompts;\n",
    "#use Text::SubParsers;\n",
    "#use Data::TypeSystem;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "67afe365",
   "metadata": {},
   "source": [
    "Visualization package:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "6a2c1878",
   "metadata": {},
   "outputs": [],
   "source": [
    "use JavaScript::Google::Charts;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3fa96b2a",
   "metadata": {},
   "source": [
    "Define LLM models access configurations:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "995dfb27",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(24 24 24)"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "my $conf4o = llm-configuration(‘chatgpt’, model => “gpt-4o”, max-tokens => 8192, temperature => 0.45);\n",
    "my $conf41 = llm-configuration(‘chatgpt’, model => “gpt-4.1”, max-tokens => 8192, temperature => 0.45);\n",
    "my $conf41-mini = llm-configuration(‘chatgpt’, model => “gpt-4.1-mini”, max-tokens => 8192, temperature => 0.45);\n",
    "\n",
    "($conf4o, $conf41, $conf41-mini)».Hash».elems"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2ab436dd",
   "metadata": {},
   "source": [
    "-----\n",
    "\n",
    "## Code translation"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e87c22d9",
   "metadata": {},
   "source": [
    "Make an LLM function that translates between programming languages:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a25db65f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-> **@args, *%args { #`(Block|3175731999944) ... }"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "my &fTrans = llm-function( -> $code, $lang = ‘Raku’ { llm-prompt(“CodeWriterX”)($lang) ~ “\\n\\n” ~ $code}, e => $conf4o)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f54b89ae",
   "metadata": {},
   "source": [
    "Here is code (with Markdown code fences indicating the programming language):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "d4a5f163",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "```raku\n",
       "100.rand xx 20\n",
       "```\n"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "my $code = q:to/END/;\n",
    "```raku\n",
    "100.rand xx 20\n",
    "```\n",
    "END"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aeb28967",
   "metadata": {},
   "source": [
    "Here is a translation:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "19544170",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "```python\n",
      "import random\n",
      "\n",
      "[random.uniform(0, 100) for _ in range(20)]\n",
      "```\n"
     ]
    }
   ],
   "source": [
    "say &fTrans($code, ‘Python’)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9d468598",
   "metadata": {},
   "source": [
    "----\n",
    "\n",
    "## Retrieving information for further computations"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "837da0d9",
   "metadata": {},
   "source": [
    "In this subsection we show to retrieve information into Raku array of hashmaps that can be further tabulated, queried, or visualized."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "779b3323",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Vector(Struct([Area, GrossIncome2024, Population, State], [Int, Int, Int, Str]), 27)"
      ]
     },
     "execution_count": 115,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "my $res = llm-synthesize(\n",
    "    [\n",
    "        \"Make a dataset of Brazil's states.\",\n",
    "        \"Return an array of dictionaries, each dictionary with keys: State, Population, Area, GrossIncome2024.\",\n",
    "        llm-prompt('NothingElse')('JSON')\n",
    "    ],\n",
    "    e => $conf41-mini,\n",
    "    form => sub-parser('JSON'):drop\n",
    ");\n",
    "\n",
    "deduce-type($res)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "729bb30c",
   "metadata": {},
   "source": [
    "Tabulate the result:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "id": "720f5f38",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table border=\"1\"><thead><tr><th>State</th><th>Population</th><th>Area</th><th>GrossIncome2024</th></tr></thead><tbody><tr><td>Acre</td><td>894470</td><td>164123</td><td>8500000000</td></tr><tr><td>Alagoas</td><td>3351543</td><td>27767</td><td>32000000000</td></tr><tr><td>Amapá</td><td>877613</td><td>142828</td><td>9000000000</td></tr><tr><td>Amazonas</td><td>4207714</td><td>1559159</td><td>60000000000</td></tr><tr><td>Bahia</td><td>14873064</td><td>564733</td><td>150000000000</td></tr><tr><td>Ceará</td><td>9132078</td><td>148920</td><td>110000000000</td></tr><tr><td>Distrito Federal</td><td>3055149</td><td>5779</td><td>140000000000</td></tr><tr><td>Espírito Santo</td><td>4064052</td><td>46077</td><td>90000000000</td></tr><tr><td>Goiás</td><td>7113540</td><td>340086</td><td>120000000000</td></tr><tr><td>Maranhão</td><td>7114598</td><td>331937</td><td>60000000000</td></tr><tr><td>Mato Grosso</td><td>3625476</td><td>903357</td><td>70000000000</td></tr><tr><td>Mato Grosso do Sul</td><td>2778986</td><td>357125</td><td>50000000000</td></tr><tr><td>Minas Gerais</td><td>21168791</td><td>586528</td><td>300000000000</td></tr><tr><td>Pará</td><td>8602865</td><td>1247954</td><td>90000000000</td></tr><tr><td>Paraíba</td><td>4039277</td><td>56585</td><td>40000000000</td></tr><tr><td>Paraná</td><td>11433957</td><td>199307</td><td>180000000000</td></tr><tr><td>Pernambuco</td><td>9557071</td><td>98311</td><td>110000000000</td></tr><tr><td>Piauí</td><td>3273227</td><td>251577</td><td>25000000000</td></tr><tr><td>Rio de Janeiro</td><td>17463349</td><td>43696</td><td>280000000000</td></tr><tr><td>Rio Grande do Norte</td><td>3506853</td><td>52811</td><td>35000000000</td></tr><tr><td>Rio Grande do Sul</td><td>11329605</td><td>281748</td><td>190000000000</td></tr><tr><td>Rondônia</td><td>1827637</td><td>237576</td><td>20000000000</td></tr><tr><td>Roraima</td><td>631181</td><td>224300</td><td>10000000000</td></tr><tr><td>Santa Catarina</td><td>7264941</td><td>95736</td><td>130000000000</td></tr><tr><td>São Paulo</td><td>46289333</td><td>248222</td><td>700000000000</td></tr><tr><td>Sergipe</td><td>2298696</td><td>21915</td><td>20000000000</td></tr><tr><td>Tocantins</td><td>1590248</td><td>277620</td><td>15000000000</td></tr></tbody></table>"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#% html\n",
    "my @field-names = <State Population Area GrossIncome2024>;\n",
    "$res ==> to-html(:@field-names)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4feee11d",
   "metadata": {},
   "source": [
    "Make a bubble chart:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "id": "59cd36f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\n",
       "  <head>\n",
       "    <!--Load the AJAX API-->\n",
       "    <script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>\n",
       "    <script type=\"text/javascript\">\n",
       "\n",
       "      // Load the Visualization API and the corechart package.\n",
       "      google.charts.load('current', {'packages':['corechart']});\n",
       "      google.charts.load('current', {'packages':['gauge']});\n",
       "      google.charts.load('current', {'packages':['wordtree']});\n",
       "      google.charts.load('current', {'packages':['geochart']});\n",
       "      google.charts.load('current', {'packages':['table']});\n",
       "      google.charts.load('current', {'packages':['line']});\n",
       "      google.charts.load('current', {'packages':['sankey']});\n",
       "      google.charts.load('current', {'packages':['timeline']});\n",
       "\n",
       "      // Set a callback to run when the Google Visualization API is loaded.\n",
       "      google.charts.setOnLoadCallback(drawChart);\n",
       "\n",
       "      // Callback that creates and populates a data table,\n",
       "      // instantiates the chart, passes in the data, and draws it.\n",
       "      function drawChart() {\n",
       "\n",
       "        // Create the data table.\n",
       "        var data = new google.visualization.DataTable();\n",
       "\t\tdata.addColumn('string', 'group');\n",
       "\t\tdata.addColumn('number', 'x');\n",
       "\t\tdata.addColumn('number', 'y');\n",
       "\t\tdata.addColumn('number', 'size');\n",
       "\t\tdata.addRows([\n",
       "\t\t['Acre', 894470, 164123, 8500000000],\n",
       "\t\t['Alagoas', 3351543, 27767, 32000000000],\n",
       "\t\t['Amapá', 877613, 142828, 9000000000],\n",
       "\t\t['Amazonas', 4207714, 1559159, 60000000000],\n",
       "\t\t['Bahia', 14873064, 564733, 150000000000],\n",
       "\t\t['Ceará', 9132078, 148920, 110000000000],\n",
       "\t\t['Distrito Federal', 3055149, 5779, 140000000000],\n",
       "\t\t['Espírito Santo', 4064052, 46077, 90000000000],\n",
       "\t\t['Goiás', 7113540, 340086, 120000000000],\n",
       "\t\t['Maranhão', 7114598, 331937, 60000000000],\n",
       "\t\t['Mato Grosso', 3625476, 903357, 70000000000],\n",
       "\t\t['Mato Grosso do Sul', 2778986, 357125, 50000000000],\n",
       "\t\t['Minas Gerais', 21168791, 586528, 300000000000],\n",
       "\t\t['Pará', 8602865, 1247954, 90000000000],\n",
       "\t\t['Paraíba', 4039277, 56585, 40000000000],\n",
       "\t\t['Paraná', 11433957, 199307, 180000000000],\n",
       "\t\t['Pernambuco', 9557071, 98311, 110000000000],\n",
       "\t\t['Piauí', 3273227, 251577, 25000000000],\n",
       "\t\t['Rio de Janeiro', 17463349, 43696, 280000000000],\n",
       "\t\t['Rio Grande do Norte', 3506853, 52811, 35000000000],\n",
       "\t\t['Rio Grande do Sul', 11329605, 281748, 190000000000],\n",
       "\t\t['Rondônia', 1827637, 237576, 20000000000],\n",
       "\t\t['Roraima', 631181, 224300, 10000000000],\n",
       "\t\t['Santa Catarina', 7264941, 95736, 130000000000],\n",
       "\t\t['São Paulo', 46289333, 248222, 700000000000],\n",
       "\t\t['Sergipe', 2298696, 21915, 20000000000],\n",
       "\t\t['Tocantins', 1590248, 277620, 15000000000]\n",
       "\t\t]);\n",
       "\n",
       "        // Set chart options\n",
       "        var options =\n",
       "            {\n",
       "              \"vAxis\": {\n",
       "                \"title\": \"Area\"\n",
       "              },\n",
       "              \"title\": \"Brazil states\",\n",
       "              \"height\": 400,\n",
       "              \"hAxis\": {\n",
       "                \"title\": \"Population\"\n",
       "              },\n",
       "              \"width\": 600\n",
       "            };\n",
       "\n",
       "        // Instantiate and draw our chart, passing in some options.\n",
       "        var chart = new google.visualization.BubbleChart(document.getElementById('BrazilBubbles'));\n",
       "        chart.draw(data, options);\n",
       "      }\n",
       "    </script>\n",
       "  </head>\n",
       "\n",
       "  <body>\n",
       "    <!--Div that will hold the pie chart-->\n",
       "    <div id=\"BrazilBubbles\"></div>\n",
       "  </body>\n",
       "</html>\n"
      ]
     },
     "execution_count": 119,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#% html\n",
    "my @dsBubbles = $res.kv.map( -> $i, %r { %( group => %r<State>, x => %r<Population>, y => %r<Area>, size => %r<GrossIncome2024> ) });\n",
    "my @column-names = <group x y size>;\n",
    "\n",
    "js-google-charts(\n",
    "    'BubbleChart', \n",
    "    @dsBubbles, \n",
    "    :@column-names,\n",
    "    title => 'Brazil states',\n",
    "    hAxis => { title => 'Population'},\n",
    "    vAxis => { title => 'Area'},\n",
    "    div-id => 'BrazilBubbles', \n",
    "    format => 'html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "217a8de4",
   "metadata": {},
   "source": [
    "-----\n",
    "\n",
    "## Vision: image description"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4a852684",
   "metadata": {},
   "source": [
    "AI / LLM vision can be done with the subs `llm-vision-synthesize` and `llm-vision-function`. For multi-modal the main functions `llm-synthesize` and `llm-function` can be used."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f00fc634",
   "metadata": {},
   "source": [
    "Here is an image URL:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "4b5d834e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Raccoon_in_Central_Park_%2835264%29.jpg/960px-Raccoon_in_Central_Park_%2835264%29.jpg\" style=\"width:600px;\">"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#% markdown\n",
    "my $url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Raccoon_in_Central_Park_%2835264%29.jpg/960px-Raccoon_in_Central_Park_%2835264%29.jpg';\n",
    "\n",
    "\"<img src=\\\"$url\\\" style=\\\"width:600px;\\\">\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5895cc1c",
   "metadata": {},
   "source": [
    "Using the specialized vision sub:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "57a5f62a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "The image shows a raccoon standing on a forest floor. The raccoon has a bushy tail with black rings and a distinctive black mask around its eyes. The background includes rocks and trees, indicating a natural setting."
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "llm-vision-synthesize('Describe briefly what do you see in this image:', $url)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "455f48fe",
   "metadata": {},
   "source": [
    "Another call using a (recent) multi-modal LLM:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ff5f64f8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "The image shows a raccoon standing on a paved path in a park setting. The raccoon is looking directly at the camera, and there is greenery, including grass and trees, in the background. The scene appears to be taken during the day with natural light."
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "llm-synthesize(\"Describe briefly what do you see in this image:\\n $url\", e => $conf41-mini)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "88c989fd",
   "metadata": {},
   "source": [
    "----\n",
    "## Vision: reproducing a diagram"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "16397cd8",
   "metadata": {},
   "source": [
    "This subsection shows how the values of a certain statistics plot can be \"read\" and make a similar plot (via Raku.) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "a28ac823",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "```html\n",
       "<a href=\"https://example.com\">\n",
       "  <img src=\"image.jpg\" alt=\"Description\" style=\"width:200px;\">\n",
       "</a>\n",
       "```"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#% chat html\n",
    "How to specify the with of image link."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "eaf5c372",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "<img src=\"https://www.nationwidegroup.org/wp-content/uploads/2024/11/statistic_id1345543_us-consumers_-participation-by-shopping-event-during-thanksgiving-week-2020-2024.png\" style=\"width:600px;\">"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#% markdown\n",
    "my $urlBarChart = 'https://www.nationwidegroup.org/wp-content/uploads/2024/11/statistic_id1345543_us-consumers_-participation-by-shopping-event-during-thanksgiving-week-2020-2024.png';\n",
    "\n",
    "\"<img src=\\\"$urlBarChart\\\" style=\\\"width:600px;\\\">\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "46fdaae5",
   "metadata": {},
   "source": [
    "Here we get a nested hashmap (dictionary) of the consumer data into different days and years:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "d27bd38b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Vector(Pair(Atom((Str)), Assoc(Atom((Str)), Atom((Int)), 5)), 4)"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "my $res = llm-vision-synthesize([\n",
    "    \"For the given image make a JSON dictionary of the different years for the different days.\",\n",
    "    llm-prompt(\"NothingElse\")(\"JSON\")\n",
    "    ],\n",
    "    $urlBarChart,\n",
    "    e => $conf41,\n",
    "    form => sub-parser('JSON'):drop\n",
    ");\n",
    "\n",
    "deduce-type($res)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "64abd0b4",
   "metadata": {},
   "source": [
    "Here we make a plot using [\"JavaScript::Google::Charts\"](https://raku.land/zef:antononcube/JavaScript::Google::Charts):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "077b382a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\n",
       "  <head>\n",
       "    <!--Load the AJAX API-->\n",
       "    <script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>\n",
       "    <script type=\"text/javascript\">\n",
       "\n",
       "      // Load the Visualization API and the corechart package.\n",
       "      google.charts.load('current', {'packages':['corechart']});\n",
       "      google.charts.load('current', {'packages':['gauge']});\n",
       "      google.charts.load('current', {'packages':['wordtree']});\n",
       "      google.charts.load('current', {'packages':['geochart']});\n",
       "      google.charts.load('current', {'packages':['table']});\n",
       "      google.charts.load('current', {'packages':['line']});\n",
       "      google.charts.load('current', {'packages':['sankey']});\n",
       "      google.charts.load('current', {'packages':['timeline']});\n",
       "\n",
       "      // Set a callback to run when the Google Visualization API is loaded.\n",
       "      google.charts.setOnLoadCallback(drawChart);\n",
       "\n",
       "      // Callback that creates and populates a data table,\n",
       "      // instantiates the chart, passes in the data, and draws it.\n",
       "      function drawChart() {\n",
       "\n",
       "        // Create the data table.\n",
       "        var data = new google.visualization.DataTable();\n",
       "\t\tdata.addColumn('string', 'Group');\n",
       "\t\tdata.addColumn('number', '2024');\n",
       "\t\tdata.addColumn('number', '2023');\n",
       "\t\tdata.addColumn('number', '2022');\n",
       "\t\tdata.addColumn('number', '2021');\n",
       "\t\tdata.addColumn('number', '2020');\n",
       "\t\tdata.addRows([\n",
       "\t\t['Thanksgiving Day', 21, 12, 8, 9, 8],\n",
       "\t\t['Small Business Saturday', 20, 14, 16, 16, 14],\n",
       "\t\t['Black Friday', 47, 31, 29, 25, 24],\n",
       "\t\t['Cyber Monday', 43, 31, 30, 27, 29]\n",
       "\t\t]);\n",
       "\n",
       "        // Set chart options\n",
       "        var options =\n",
       "            {\n",
       "              \"width\": 600,\n",
       "              \"height\": 400,\n",
       "              \"backgroundColor\": \"GhostWhite\",\n",
       "              \"bar\": {\n",
       "                \"groupWidth\": \"75%\"\n",
       "              }\n",
       "            };\n",
       "\n",
       "        // Instantiate and draw our chart, passing in some options.\n",
       "        var chart = new google.visualization.ColumnChart(document.getElementById('visionBars'));\n",
       "        chart.draw(data, options);\n",
       "      }\n",
       "    </script>\n",
       "  </head>\n",
       "\n",
       "  <body>\n",
       "    <!--Div that will hold the pie chart-->\n",
       "    <div id=\"visionBars\"></div>\n",
       "  </body>\n",
       "</html>\n"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#% html\n",
    "my @dsBar = $res.map({ [|$_.value.clone, Group => $_.key]})».Hash;\n",
    "\n",
    "js-google-charts('BarChart',\n",
    "        @dsBar,\n",
    "        :!horizontal,\n",
    "        backgroundColor => 'GhostWhite',\n",
    "        bar => { groupWidth => '75%' },\n",
    "        div-id => 'visionBars',\n",
    "        format => 'html');"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "91e2adb0",
   "metadata": {},
   "source": [
    "**Remark:** The order of the days and years is arbitrary due to Raku's non-ordered hashmaps."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c13cc1ee",
   "metadata": {},
   "source": [
    "-----\n",
    "\n",
    "## References"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fa6c4038",
   "metadata": {},
   "source": [
    "### Articles\n",
    "\n",
    "[AA1] Anton Antonov,\n",
    "[\"Workflows with LLM functions\"](https://rakuforprediction.wordpress.com/2023/08/01/workflows-with-llm-functions/),\n",
    "(2023),\n",
    "[RakuForPrediction at WordPress](https://rakuforprediction.wordpress.com)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "00628877",
   "metadata": {},
   "source": [
    "\n",
    "### Notebooks\n",
    "\n",
    "[AAn1] Anton Antonov,\n",
    "[\"Workflows with LLM functions (in Raku)\"](https://community.wolfram.com/groups/-/m/t/2982320),\n",
    "(2023),\n",
    "[Wolfram Community](https://community.wolfram.com).\n",
    "\n",
    "[AAn2] Anton Antonov,\n",
    "[\"Workflows with LLM functions (in Python)\"](https://community.wolfram.com/groups/-/m/t/3027081),\n",
    "(2023),\n",
    "[Wolfram Community](https://community.wolfram.com).\n",
    "\n",
    "[AAn3] Anton Antonov,\n",
    "[\"Workflows with LLM functions (in WL)\"](https://community.wolfram.com/groups/-/m/t/3027081),\n",
    "(2023),\n",
    "[Wolfram Community](https://community.wolfram.com).\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8ffeb1ef",
   "metadata": {},
   "source": [
    "### Packages"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "801e2d7d",
   "metadata": {},
   "source": [
    "[AAp1] Anton Antonov,\n",
    "[LLM::Functions Raku package](https://github.com/antononcube/Raku-LLM-Functions),\n",
    "(2023-2024),\n",
    "[GitHub/antononcube](https://github.com/antononcube).\n",
    "([raku.land](https://raku.land/zef:antononcube/LLM::Functions)).\n",
    "\n",
    "[AAp2] Anton Antonov,\n",
    "[LLM::Prompts Raku package](https://github.com/antononcube/Raku-LLM-Prompts),\n",
    "(2023-2024),\n",
    "[GitHub/antononcube](https://github.com/antononcube).\n",
    "([raku.land](https://raku.land/zef:antononcube/LLM::Prompts)).\n",
    "\n",
    "[AAp3] Anton Antonov,\n",
    "[Jupyter::Chatbook Raku package](https://github.com/antononcube/Raku-Jupyter-Chatbook),\n",
    "(2023-2024),\n",
    "[GitHub/antononcube](https://github.com/antononcube).\n",
    "([raku.land](https://raku.land/zef:antononcube/Jupyter::Chatbook)).\n",
    "\n",
    "[AAp4] Anton Antonov,\n",
    "[JavaScript::Google::Charts Raku package](https://github.com/antononcube/Raku-JavaScript-Google-Charts),\n",
    "(2024),\n",
    "[GitHub/antononcube](https://github.com/antononcube).\n",
    "([raku.land](https://raku.land/zef:antononcube/JavaScript::Google::Charts)).\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ca646e6c",
   "metadata": {},
   "source": [
    "### Videos\n",
    "\n",
    "[AAv1] Anton Antonov,\n",
    "[\"Robust LLM pipelines (Mathematica, Python, Raku)\"](https://youtu.be/QOsVTCQZq_s),\n",
    "(2024),\n",
    "[YouTube/@AAA4Predictions](https://www.youtube.com/@AAA4Predictions).\n",
    "\n",
    "[AAv2] Anton Antonov,\n",
    "[\"Integrating Large Language Models with Raku\"](https://www.youtube.com/watch?v=-OxKqRrQvh0),\n",
    "(2023),\n",
    "[The Raku Conference 2023 at YouTube](https://www.youtube.com/@therakuconference6823)."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "RakuChatbook",
   "language": "raku",
   "name": "raku"
  },
  "language_info": {
   "file_extension": ".raku",
   "mimetype": "text/x-raku",
   "name": "raku",
   "version": "6.d"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
