Sunday, November 16, 2025

AI: OpenAI GPT-5.1

 GPT-5.1 is Here! (Major Update) - YouTube

GPT-5.1 gets faster, chattier, and smarter with better personality, tighter instruction-following, adaptive reasoning, and major accuracy boosts.

Web: HTML DOM API: tables

HTMLTableElement - Web APIs | MDN

The HTMLTableElement interface provides special properties and methods (beyond the regular HTMLElement object interface it also has available to it by inheritance) for manipulating the layout and presentation of tables in an HTML document.

 Abandonware of the web: do you know that there is an HTML tables API? | Christian Heilmann

let table = [
  ['one','two','three'],
  ['four','five','six']
];
let b = document.body;
let t = document.createElement('table');
b.appendChild(t);
table.forEach((row,ri) => {
  let r = t.insertRow(ri);
  row.forEach((l,i) => {
    let c = r.insertCell(i);
    c.innerText = l;  
  })
});

// You can then access each table cell with an index (with t being a reference to the table):
console.log(t.rows[1].cells[1]);
// => <td>five</td>

// You can also delete and create cells and rows, if you want to add a row to the end of the table with a cell, all you need to do is:
t.insertRow(-1);
t.rows[2].insertCell(0);
t.rows[2].cells[0].innerText = 'foo';

// here is "default alternative"... not much different... and simpler than React :)
table.forEach((row) => {
  let r = document.createElement('tr');
  t.appendChild(r);
  row.forEach((l) => {
    let c = document.createElement('td');
    c.innerText = l;
    r.appendChild(c);
  })
});


Azure OpenAI API examples

Azure AI API is complicated :) But is works.

Azure OpenAI is "legacy" only for OpenAI API
Azure AI Foundry is "generic", that also includes OpenAI
Azure AI Services, used to be "Cognitive Services", is "native" Microsoft's non-LLM AI services

Azure AI Foundry Docs

openai/openai-node: Official JavaScript / TypeScript library for the OpenAI API @GitHub

JavaScript

baseURL: "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/"

import { OpenAI } from "openai";

const endpoint = process.env.AZURE_OPENAI_ENDPOINT
const apiKey = process.env.AZURE_OPENAI_API_KEY
const baseURL = `${endpoint}/openai/v1/`  
const model = 'gpt-4.1' // model deployment name

const client = new OpenAI({
    baseURL,
    apiKey,
    maxRetries: 0, // default is 2; Configure the default for all requests
});

// == responses ===
const response1 = await client.responses.create({
  model,
  instructions: 'You are a helpful AI agent',
  input: 'how tall is triglav?',
});
console.log(response1.output_text);

// == streaming ===
const stream = await client.responses.create({
  model,
  input: 'Provide a brief history of the attention is all you need paper.',
  stream: true,
});
for await (const event of stream) {
  if (event.type === 'response.output_text.delta' && event.delta) {
    process.stdout.write(event.delta);
  }
}

// == chat ==
const response2 = await client.chat.completions.create({
    messages: [
      { role:"system", content: "You are a helpful assistant." },
      { role:"user", content: "I am going to Paris, what should I see?" }
    ],
    max_completion_tokens: 13107,
    temperature: 1,
    top_p: 1,
    frequency_penalty: 0,
    presence_penalty: 0,
    model,
});
if (response2?.error !== undefined && response2.status !== "200") {
    throw response2.error;
}
console.log(response2.choices[0].message.content);

// == retries, configure per-request:
const response3 = await client.chat.completions.create(
    { messages: [{ role: 'user', content: 'How can I get the name of the current day in Node.js?' }], model },
    { maxRetries: 5 }
);
if (response3?.error !== undefined && response3.status !== "200") {
    console.error(response3.status, response3.error);
} else {
    console.log(response3.choices[0].message.content);
}

// == tools, use MCP server

const response4 = await client.responses.create({
  model,
  tools: [
    {
      type: "mcp",
      server_label: "microsoft_learn",
      server_description: "Microsoft Learn MCP server for searching and fetching Microsoft documentation.",
      server_url: "https://learn.microsoft.com/api/mcp",
      require_approval: "never",
    },
  ],
  input: "Search for information about Azure Functions",
});
console.log(response4.output_text);