Thuta Learning
API Tutorial
AdvancedWeb Developmentအလယ်အလတ်

Copilot / GitHub Models Note

API Tutorialသင်ခန်းစာ 2230 မိနစ်

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • GitHub Models ဘာဖြစ်သွားလဲ၊ Copilot က ဘာကြောင့် တိုက်ရိုက်အစားထိုးလို့ မရလဲ ဆိုတာ ပြောပြနိုင်ဖို့
  • Copilot SDK နဲ့ cloud agent REST API လို ရှိနေတဲ့ programmable Copilot surface တွေရဲ့ နာမည်နဲ့ အသုံးကို ပြောနိုင်ဖို့
  • ရိုးရိုး audit တစ်ခုနဲ့ codebase ထဲက ရုပ်သိမ်းပြီးသား endpoint တွေကို ရှာနိုင်ဖို့
  • App နဲ့ AI service ကြားမှာ provider adapter ထားပြီး ရုပ်သိမ်းတာကို configuration ပြောင်းရုံ ဖြစ်အောင် လုပ်နိုင်ဖို့

ရိုးရိုးလေး ရှင်းပြမယ်

ရိုးရိုးလေး ရှင်းရရင်

API တချို့က ရုတ်တရက် ပျောက်သွားတတ်ပါတယ်။ GitHub Models က GitHub token နဲ့ hosted model တွေကို ခေါ်ခွင့်ပေးခဲ့ပါတယ်။ GitHub ရဲ့ documentation မှာ ယခု 2026 ဇူလိုင် 30 အထိ လုံးဝရုပ်သိမ်းပြီးပြီလို့ ဖော်ပြထားပါတယ်။ Playground၊ model catalog၊ inference API နဲ့ bring-your-own-key feature တွေ မရှိတော့ပါဘူး။

GitHub Copilot ကတော့ တခြားအရာပါ။ Editor၊ command line နဲ့ GitHub ပေါ်မှာ ရှိတဲ့ assistant တစ်ခုဖြစ်ပြီး curl နဲ့ ခေါ်လို့ရတဲ့ ယေဘုယျ chat endpoint မဟုတ်ပါဘူး။ ပိတ်သွားတဲ့ ဆိုင်တစ်ဆိုင်ကို စဉ်းစားကြည့်ပါ။ သူ့လိပ်စာက ကိုယ့် supplier စာရင်းမှာ ရှိနေနိုင်ပြီး ကိုယ့် Copilot subscription ကတော့ တခြားအရာရောင်းတဲ့ တခြားဆိုင်ရဲ့ အဖွဲ့ဝင်ကတ်ပါ။

Problem → Why → Solution

ပြဿနာ: မရှိတော့တဲ့ service ကို debug လုပ်နေခြင်း

အဖွဲ့သားအသစ်တစ်ယောက်က GitHub Models endpoint အတွက် curl command ပါတဲ့ blog post တစ်ခုကို တွေ့ပြီး project ထဲ paste လုပ်ပါတယ်။ Code ထဲမှာ ဘာမှ မှားတယ်လို့ မထင်ရလို့ call ကျတဲ့အခါ team က token permission လိုနေတာ ဒါမှမဟုတ် Copilot licence ပြဿနာလို့ သံသယဝင်ပါတယ်။ ပိတ်လိုက်ပြီးသား service တစ်ခုအတွက် authentication ကို နေ့လည်ခင်းတစ်ခုလုံး debug လုပ်ကြပါတယ်။

ပြောင်းပြန်အမှားကလည်း အဲဒီလောက်ပဲ ဖြစ်တတ်ပါတယ်။ ကုမ္ပဏီက Copilot အတွက် ပေးထားလို့ တခြား chat API လိုပဲ ခေါ်လို့ရမယ်လို့ ယူဆပြီး အဲဒီယူဆချက်ပေါ် feature တစ်ခု design လုပ်တာပါ။ အမှားနှစ်ခုစလုံးက product နာမည်ကို API စာချုပ်လို့ သဘောထားမိလို့ ဖြစ်တာပါ။

from-a-2025-post.js
// copied from a blog post written while GitHub Models was available
const res = await fetch("https://models.github.ai/inference/chat/completions", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.GITHUB_TOKEN },
  body: JSON.stringify({
    model: "<model-id>",
    messages: [{ role: "user", content: "Hello" }],
  }),
});

Call site ငါးဆယ်ထက် adapter တစ်ခုက ဘာကြောင့် ပိုကောင်းလဲ

ရုပ်သိမ်းတာက ကိုယ့် code အပြင်ဘက်က ဆုံးဖြတ်ချက်ပါ။ ကိုယ်ထိန်းချုပ်လို့ရတာက provider တစ်ခုအကြောင်း သိတဲ့နေရာ ဘယ်နှစ်နေရာရှိလဲ ဆိုတာပါ။ URL၊ header နဲ့ response path တွေက adapter တစ်ခုထဲမှာရှိရင် ရုပ်သိမ်းတာက file တစ်ခုပဲ ပြောင်းစေပါတယ်။ App တစ်ခုလုံး ပြန့်နေရင်တော့ ငါးဆယ်နေရာ ပြောင်းရပြီး တချို့ကို လွတ်သွားပါလိမ့်မယ်။

Core concept: ဘာပျောက်သွားလဲ၊ ဘာရှိလဲ၊ ဘယ်လိုကူးပြောင်းမလဲ

ဒီ lesson က service တစ်ခုထက် skill တစ်ခုအကြောင်း ပိုပါတယ်။ ရုပ်သိမ်းကြောင်း အသိပေးချက်ကို တည်ငြိမ်စွာဖတ်ပြီး လုံခြုံစွာ ပြန်တည်ဆောက်တဲ့ skill ပါ။ အောက်ပါအချက်တွေက GitHub ရဲ့ documentation ကနေ ယူထားတာပါ။

၁။ ရုပ်သိမ်းကြောင်း အသိပေးချက်ထဲက စကား

GitHub ရဲ့ documentation က GitHub Models ကို 2026 ဇူလိုင် 30 မှာ လုံးဝရုပ်သိမ်းခဲ့ပြီး သူ့ရဲ့ playground၊ model catalog၊ inference API နဲ့ bring-your-own-key feature တွေကို customer တစ်ယောက်မှ မသုံးနိုင်တော့ဘူးလို့ ဆိုပါတယ်။ Model access အတွက် Azure AI Foundry ကိုနဲ့ GitHub ပေါ်က AI workflow တွေအတွက် GitHub Copilot ကို ညွှန်ပါတယ်။ models.inference.ai.azure.com နဲ့ models.github.ai/inference လို hostname အဟောင်းတွေက ရုပ်သိမ်းခင်က tutorial များစွာမှာ ပေါ်ပါတယ်။

၂။ Copilot က chat endpoint မဟုတ်ဘဲ product ပါ

GitHub ရဲ့ Copilot documentation က သူ့အပေါ်မှာ တည်ဆောက်နိုင်တဲ့ နည်းလမ်းတွေကို စာရင်းပြုထားပြီး ယေဘုယျ public chat-completions endpoint ကတော့ အဲဒီထဲမှာ မပါပါဘူး။ အစားရှိတာတွေထဲမှာ Copilot CLI ကနေ Copilot ကို မောင်းတဲ့ Copilot SDK (ဥပမာ TypeScript အတွက် @github/copilot-sdk)၊ repository တစ်ခုပေါ်မှာ Copilot cloud agent task တွေ စတင်ဖို့ public preview REST API၊ Copilot CLI ကို program နဲ့သုံးတာ၊ usage metrics API တွေ ပါပါတယ်။

၃။ အမှတ်တံဆိပ်နဲ့မဟုတ်ဘဲ အလုပ်နဲ့ ရွေးပါ

ကိုယ့် back end ထဲမှာ model output အစစ်လိုရင် model provider ကို ခေါ်ပါ၊ အရင် lesson တွေပြသလို Anthropic၊ Google၊ OpenAI၊ Hugging Face ဒါမှမဟုတ် Azure AI Foundry ပါ။ ကိုယ့် tool ထဲမှာ Copilot-powered assistant လိုချင်ရင် SDK ကို ကြည့်ပါ။ Script တစ်ခုက coding task ကို agent ဆီ ပေးချင်ရင် cloud agent API ကို ကြည့်ပါ။

၄။ Inventory၊ contract နဲ့ adapter နဲ့ ကူးပြောင်းပါ

ပထမဆုံး code နဲ့ configuration ထဲမှာ ရုပ်သိမ်းပြီးသား hostname တွေနဲ့ GitHub Models အတွက်ပဲ ဖန်တီးခဲ့တဲ့ token တွေကို ရှာပါ။ ပြီးရင် ကိုယ့် app လိုအပ်တဲ့ contract ကို ရေးပါ၊ prompt တစ်ခုပေးရင် စာသား ဒါမှမဟုတ် ရှင်းလင်းတဲ့ failure ပြန်ပေးရမယ်။ Provider တစ်ခုချင်းစီအတွက် အဲဒီ contract အနောက်မှာ adapter တစ်ခုထားပြီး adapter တစ်ခုစီကို mock server နဲ့ စမ်းပါ။ နောက်ရုပ်သိမ်းတာက adapter အသစ်တစ်ခုပဲ ကုန်ကျစေပါတယ်။

ငါလုပ်ချင်တာကြည့်ရမယ့်နေရာမှတ်ချက်
ငါ့ back end မှာ prompt ကို ဖြည့်စေModel provider APIToken အလိုက်ပေးရ၊ key က server မှာ
Copilot assistant ထည့်သွင်းCopilot SDKauthenticate လုပ်ထားတဲ့ Copilot CLI လို
Script ကနေ coding task စတင်Cloud agent REST APIPublic preview၊ ပြောင်းနိုင်
Copilot usage အစီရင်ခံUsage metrics APIusage-metrics docs ကိုကြည့်
Mental model: notice၊ inventory၊ contract၊ adapter
  1. Notice က ဘာပျောက်လဲ ပြော
  2. Inventory က ဆက်သုံးနေတာကို ရှာ
  3. Contract က app လိုတာကို ပြော
  4. Adapter က provider တစ်ခုရဲ့ shape ကို ဖုံး

Adapter က provider တစ်ခုရဲ့ URL၊ header နဲ့ response path ကို သိတဲ့ file တစ်ခုတည်းပါ။ ကျန်တာအားလုံးက contract နဲ့ပဲ ပြောပါတယ်။

အခြေခံ ပုံစံ

javascript
const provider = {
  path: "/<endpoint-path>",
  headers: () => ({ authorization: "Bearer " + process.env.PROVIDER_KEY }),
  body: (prompt) => ({ /* the shape this provider documents */ }),
  read: (data) => data.<path-to-the-generated-text>,
};

// The app only ever calls the contract, never a provider directly.
const { text, provider: usedProvider } = await complete(base, [provider], prompt);

Provider တစ်ခုချင်းစီက ဘယ်ကို ခေါ်ရမလဲ၊ request ကို ဘယ်လိုလက်မှတ်ထိုးရမလဲ၊ ထုတ်ပေးတဲ့စာသားက ဘယ်မှာရှိလဲ ဆိုတာကို ပြောတဲ့ object တစ်ခုပါ။ App က provider chain တစ်ခုနဲ့ complete() ကို ခေါ်ပြီး URL ကို ကိုယ်တိုင် ဘယ်တော့မှ မထိပါဘူး။

Provider chain နဲ့ ရုပ်သိမ်းပြီးသား host audit

Script က ပထမဆုံး နမူနာ file သုံးခုကို ရုပ်သိမ်းပြီးသား hostname အတွက် audit လုပ်ပါတယ်။ ပြီးတော့ route သုံးခုပါတဲ့ stand-in server ကို စတင်ပါတယ်။ အမြဲကျတဲ့ simulate လုပ်ထားတဲ့ ရုပ်သိမ်းပြီးသား host၊ messages shape နဲ့ ဖြေတဲ့ provider တစ်ခုနဲ့ chat shape နဲ့ ဖြေတဲ့ provider တစ်ခုပါ။ complete() က provider တွေကို အစီအစဉ်အတိုင်း စမ်းပြီး ကျတာကို ကျော်၊ ပထမအဖြေကို return ပြန်ပါတယ်။ ရုပ်သိမ်းပြီးသား host ကို simulate လုပ်တာပါ၊ ပိတ်လိုက်တဲ့ service က ဘာပြန်မလဲ ဘယ်သူမှ အာမမခံနိုင်လို့ 2xx မဟုတ်တဲ့ reply အားလုံးကို တူညီစွာ ကိုင်တွယ်ပါတယ်။

provider-chain.mjs
import http from "node:http";

// Stand-in server. The retired host is only simulated: we do not know what a real
// retired endpoint answers today, so the adapter must treat any failure alike.
const server = http.createServer((req, res) => {
  const json = (status, body) => {
    res.writeHead(status, { "content-type": "application/json" });
    res.end(JSON.stringify(body));
  };
  req.resume();
  req.on("end", () => {
    if (req.url.startsWith("/retired/")) return json(404, { message: "gone" });
    if (req.url === "/messages-shape/v1/messages") {
      if (req.headers["x-api-key"] !== "demo-key") return json(401, { type: "error" });
      const content = [{ type: "text", text: "answer in the messages shape" }];
      return json(200, { content });
    }
    if (req.url === "/chat-shape/v1/chat/completions") {
      const message = { content: "answer in the chat shape" };
      return json(200, { choices: [{ message }] });
    }
    json(404, {});
  });
});

// One adapter object per provider: where to call, how to sign, how to read the text.
const textOf = (blocks) =>
  blocks.filter((b) => b.type === "text").map((b) => b.text).join("");
const providers = {
  retired: {
    path: "/retired/inference/chat/completions",
    headers: () => ({ authorization: "Bearer old-token" }),
    body: (prompt) => ({ messages: [{ role: "user", content: prompt }] }),
    read: (data) => data.choices[0].message.content,
  },
  messagesShape: {
    path: "/messages-shape/v1/messages",
    headers: () => ({ "x-api-key": "demo-key" }),
    body: (prompt) => ({ max_tokens: 64, messages: [{ role: "user", content: prompt }] }),
    read: (data) => textOf(data.content),
  },
  chatShape: {
    path: "/chat-shape/v1/chat/completions",
    headers: () => ({ authorization: "Bearer demo-token" }),
    body: (prompt) => ({ messages: [{ role: "user", content: prompt }] }),
    read: (data) => data.choices[0].message.content,
  },
};

// The contract: give me a prompt, get text back or a clear failure.
async function complete(base, chain, prompt) {
  const skipped = [];
  for (const name of chain) {
    const p = providers[name];
    try {
      const res = await fetch(base + p.path, {
        method: "POST",
        headers: { "content-type": "application/json", ...p.headers() },
        body: JSON.stringify(p.body(prompt)),
      });
      if (!res.ok) {
        skipped.push(name + ": HTTP " + res.status);
        continue;
      }
      return { provider: name, text: p.read(await res.json()), skipped };
    } catch (err) {
      skipped.push(name + ": " + err.message);
    }
  }
  throw new Error("every provider failed: " + skipped.join("; "));
}

// A first inventory step: find hostnames of the retired service in your files.
const RETIRED = ["models.inference.ai.azure.com", "models.github.ai"];
function audit(files) {
  const findings = [];
  for (const [file, text] of Object.entries(files)) {
    text.split("\n").forEach((line, i) => {
      for (const host of RETIRED) {
        if (line.includes(host)) findings.push(file + ":" + (i + 1) + " uses " + host);
      }
    });
  }
  return findings;
}

console.log("audit findings:");
const sampleFiles = {
  "src/ai.js": 'const BASE = "https://models.github.ai/inference";\nconst ok = true;',
  ".env.example": "GITHUB_TOKEN=\nAI_ENDPOINT=https://models.inference.ai.azure.com\n",
  "src/util.js": "export const sum = (a, b) => a + b;",
};
for (const finding of audit(sampleFiles)) console.log("  " + finding);

await new Promise((resolve) => server.listen(0, resolve));
const base = "http://127.0.0.1:" + server.address().port;

const answer = await complete(base, ["retired", "messagesShape", "chatShape"], "Hi");
console.log("answered by:", answer.provider);
console.log("skipped:", answer.skipped.join("; "));
console.log("text:", answer.text);

const second = await complete(base, ["chatShape"], "Hi");
console.log("second chain answered by:", second.provider);

try {
  await complete(base, ["retired"], "Hi");
} catch (err) {
  console.log("error:", err.message);
}
server.close();

Code ကို တစ်ပိုင်းချင်း ရှင်းပြမယ်

  1. One object per providerread: (data) => textOf(data.content),

    Provider တစ်ခုစီက သူ့ response path ကိုယ်ပိုင် ကိုင်ထားပါတယ်။ messages shape က text block တွေကိုဖတ်ပြီး chat shape က choices[0].message.content ကို ဖတ်ပါတယ်၊ caller တွေက ကွာခြားချက်ကို မမြင်ရပါဘူး။

  2. Same interface for allconst p = providers[name];

    complete() က provider ကို နာမည်နဲ့ရှာပြီး အားလုံးအတွက် member လေးခု တူတူကို သုံးပါတယ်။ ဒါက contract ကို လက်တွေ့သုံးတာပါ။

  3. Any failure is a skipskipped.push(name + ": HTTP " + res.status);

    2xx မဟုတ်တဲ့ reply ကို မှတ်ထားပြီး loop က ရှေ့ဆက်ပါတယ်။ Network error ပစ်လာရင်လည်း catch block မှာ အဲဒီအတိုင်း မှတ်ပါတယ်။

  4. First answer winsreturn { provider: name, text: p.read(await res.json()), skipped };

    ရလဒ်က ဘယ်သူဖြေလဲ၊ လမ်းမှာ ဘာတွေကို ကျော်လာလဲ ပြောပြပါတယ်။ ကူးပြောင်းပြီးနောက် log စာကြောင်းတစ်ခုမှာ လိုချင်တာ အဲဒါပါပဲ။

  5. Audit by hostnameif (line.includes(host)) findings.push(file + ":" + (i + 1) + " uses " + host);

    ပထမ inventory အတွက် string search ရိုးရိုးနဲ့ လုံလောက်ပါတယ်။ src/ai.js နဲ့ .env.example အတွက် file နဲ့ line ကို ပြောပြပြီး သန့်တဲ့ file အကြောင်း ဘာမှမပြောပါဘူး။

  6. Fail loudly when all failthrow new Error("every provider failed: " + skipped.join("; "));

    Chain တစ်ခုလုံးကျရင် caller က စာသားအလွတ်တိတ်တိတ်လေးအစား အကြောင်းရင်းအားလုံးကို စာရင်းပြတဲ့ error တစ်ခု ရပါတယ်။

You should see
audit findings:
  src/ai.js:1 uses models.github.ai
  .env.example:2 uses models.inference.ai.azure.com
answered by: messagesShape
skipped: retired: HTTP 404
text: answer in the messages shape
second chain answered by: chatShape
error: every provider failed: retired: HTTP 404

Copilot surface တွေ ဘယ်လိုပုံစံလဲ

Copilot SDK က Copilot CLI ကတစ်ဆင့် Copilot ကို မောင်းပါတယ်၊ CLI ကို install လုပ်ပြီး authenticate လုပ်ထားရမယ်။ GitHub quickstart အရ Node.js၊ Python နဲ့ .NET SDK တွေက CLI ကို ထည့်ပေးထားပါတယ်။ အောက်က snippet က quickstart ရဲ့ အနည်းဆုံး TypeScript နမူနာကို လိုက်ထားတာပါ။ ပုံဥပမာပါ၊ package နာမည်နဲ့ option တွေ ပြောင်းနိုင်လို့ လက်ရှိ docs ကို စစ်ပါ။

copilot-sdk.ts
// Illustrative - check the current docs; needs Copilot access and the Copilot CLI.
import { CopilotClient } from "@github/copilot-sdk";

const client = new CopilotClient();
const session = await client.createSession({ model: "auto" });
const response = await session.sendAndWait({ prompt: "What is 2 + 2?" });
console.log(response?.data.content);
await client.stop();

Cloud agent API က repository တစ်ခုပေါ်မှာ coding task တစ်ခု စတင်ပေးပါတယ်။ Public preview ဖြစ်ပြီး ပြောင်းလဲနိုင်ပါတယ်၊ personal access token၊ OAuth app token ဒါမှမဟုတ် GitHub App user-to-server token လို user-to-server token တွေကိုပဲ လက်ခံပြီး GitHub App installation token ကို support မလုပ်ပါဘူး။ Reply မှာ task id နဲ့ queued၊ in_progress ဒါမှမဟုတ် completed လို state ပါပါတယ်။

bash
# Illustrative - public preview, so check the current docs first.
# Needs a user-to-server token (for example a personal access token) in GITHUB_TOKEN.
curl -X POST https://api.github.com/agents/repos/OWNER/REPO/tasks \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer $GITHUB_TOKEN" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  -d '{"prompt": "Add a section on local setup to the README"}'

Contract test ရေးခြင်း

Contract test ဆိုတာ ကိုယ့် adapter ကို mock server နဲ့ run တဲ့ script တိုတိုတစ်ခုပါ။ Mock ကို အပြုအမူသုံးမျိုး ပေးပါ။ Provider ရဲ့ docs ပါ shape နဲ့ ပုံမှန် reply၊ 404 ဒါမှမဟုတ် 503 လို failure status၊ ပုံစံမှားတဲ့ body ပါ။ Adapter က ပထမအခြေအနေမှာ စာသားကို ပြန်ပေးပြီး ကျန်နှစ်ခုမှာ ရှင်းလင်းတဲ့ failure ပြန်ရပါမယ်။ ရုပ်သိမ်းပြီးသား host ရဲ့ အပြုအမူကို မသိနိုင်တာမို့ သူ့ဆီက status တစ်ခုတည်းကို မျှော်တဲ့ test ကို ဘယ်တော့မှ မရေးပါနဲ့။

ကျန်ခဲ့တာတွေကို ရှင်းလင်းပါ

ရုပ်သိမ်းပြီးသား service အတွက်ပဲ ဖန်တီးခဲ့တဲ့ token တွေကို revoke လုပ်ပါ၊ သူ့ကို ပြောတဲ့ environment variable နဲ့ documentation တွေကို ဖျက်ပါ၊ သေနေတဲ့ code path ကို comment ပိတ်မထားဘဲ ဖယ်ရှားပါ။ ကျန်ခဲ့တဲ့ credential က အကျိုးမရှိဘဲ အန္တရာယ်ရှိပြီး ကျန်ခဲ့တဲ့ URL က နောက်အဖွဲ့သားအတွက် ထောင်ချောက်ပါ။

လက်တွေ့ project တွေမှာ

လက်တွေ့ project မှာ ဘယ်လိုသုံးမလဲ

Prototype မှာ GitHub Models ကို သုံးခဲ့တဲ့ service သေးသေးသုံးခုပါတဲ့ team တစ်ခုကို မြင်ကြည့်ပါ။ ပထမအပတ်မှာ inventory လုပ်ပါတယ်။ Repository တိုင်းမှာ ရုပ်သိမ်းပြီးသား hostname တွေကို ရှာ၊ သူတို့ကို ပြောတဲ့ environment variable နဲ့ CI secret တွေကို စာရင်းလုပ်၊ အသုံးတစ်ခုချင်းစီကို ပိုင်ဆိုင်သူ မှတ်ပါတယ်။

ပြီးတော့ တွေ့ရှိချက်တွေကို ခွဲပါတယ်။ Back end ထဲက inference ကို adapter နောက်က model provider ဆီ ရွှေ့ပါတယ်။ Developer-productivity အသုံးကို လူတွေ editor မှာသုံးတဲ့ Copilot feature ဆီ ရွှေ့ပါတယ်။ သေနေတဲ့ prototype ကို ဖျက်ပါတယ်။ ဒုတိယအပတ်မှာ adapter နဲ့ သူ့ contract test တွေရေး၊ token အဟောင်းတွေ revoke လုပ်ပြီး setup guide ကို update လုပ်လို့ နောက်ရုပ်သိမ်းကြောင်း အသိပေးချက်ဆိုရင် နေ့တစ်ဝက်အလုပ် ဖြစ်သွားပါတယ်။

အမှားများ

မကြာခဏ လုပ်မိတတ်တဲ့ အမှားတွေ

ရုပ်သိမ်းပြီးသား ဒါမှမဟုတ် ဆင်တူတဲ့ service တွေအနားမှာ ဒီအမှားလေးခု ထပ်ခါထပ်ခါ ပေါ်ပါတယ်။

Copilot subscription ကို chat API key လို အလုပ်လုပ်မယ်လို့ မျှော်ခြင်း

Subscription က Copilot feature တွေသုံးခွင့် licence ဖြစ်ပြီး ယေဘုယျ inference endpoint အတွက် credential မဟုတ်ပါဘူး။ Completion အစစ်အတွက် model provider ရဲ့ API ကို၊ Copilot-specific feature တွေအတွက် SDK ဒါမှမဟုတ် agent API ကို သုံးပါ။

Tutorial ရဲ့ ရက်စွဲကို မစစ်ဘဲ copy ကူးခြင်း

Tutorial တစ်ခုက ရေးတဲ့နေ့မှာ မှန်ပြီး တစ်နှစ်ကြာရင် မှားနိုင်ပါတယ်။ နမူနာတစ်ခုပေါ် မတည်ဆောက်ခင် ထုတ်ဝေတဲ့ရက်နဲ့ provider ရဲ့ လက်ရှိ documentation ကို စစ်ပါ။

Provider တစ်ခုရဲ့ response path ကို app တစ်ခုလုံး ပြန့်စေခြင်း

File နှစ်ဆယ်က choices[0].message.content ကို ဖတ်နေရင် provider ပြောင်းတာက file နှစ်ဆယ်ကို ထိပါတယ်။ Path ကို adapter function တစ်ခုထဲမှာ ထားပါ။

Token နဲ့ hostname အဟောင်းတွေကို ချန်ထားခဲ့ခြင်း

မသုံးတော့တဲ့ credential နဲ့ URL တွေက repository ထဲမှာ နှစ်များစွာ ကျန်နေတတ်ပါတယ်။ Token တွေ revoke လုပ်၊ variable တွေ ဖျက်ပြီး CI မှာ audit ကို run ပါ၊ ဒါမှ host အဟောင်း မသိလိုက်ဘဲ ပြန်ပေါ်မလာမှာပါ။

Best Practices

ထိန်းသိမ်းသင့်တဲ့ အလေ့အကျင့်တွေ

  • ကိုယ်မှီခိုတဲ့ provider တိုင်းရဲ့ changelog ဒါမှမဟုတ် status feed ကို subscribe လုပ်ပြီး ရုပ်သိမ်းမယ့်ရက်တွေကို team calendar ထဲ ထည့်ပါ။
  • Provider တစ်ခုစီရဲ့ data policy၊ ကုန်ကျစရိတ်ပိုင်ရှင်နဲ့ fallback ကို README မှာ နာမည်တပ်ထားပါ၊ ဒါမှ ကူးပြောင်းရေးအစီအစဉ် ရှိပြီးသား ဖြစ်မှာပါ။
  • Endpoint audit ကို CI မှာ run ပြီး ရုပ်သိမ်းပြီးသား hostname ပေါ်လာရင် build ကို fail လုပ်ပါ။

Mini challenge

ပိုတင်းကျပ်တဲ့ endpoint audit တည်ဆောက်ပါ

{ path: text } object တစ်ခုအတွက် audit(files) ကိုရေးပါ။ ရုပ်သိမ်းပြီးသား hostname ပါတဲ့ စာကြောင်းတိုင်းကို 1 ကစတဲ့ line number နဲ့ ပြောပြရမယ်၊ ဒါပေမယ့် // ဒါမှမဟုတ် # နဲ့ စတဲ့ comment စာကြောင်းတွေကို ကျော်ပါ။ တွေ့ရှိချက်တစ်ခုစီကို စာကြောင်းတစ်ကြောင်း print လုပ်ပြီး တွေ့ရှိချက် ဘယ်နှစ်ခု၊ file ဘယ်နှစ်ခုမှာလဲ ပြောတဲ့ အကျဉ်းချုပ်ကို print လုပ်ပါ။

  • models.inference.ai.azure.com နဲ့ models.github.ai နှစ်ခုလုံးကို စစ်ပါ
  • ပထမ space မဟုတ်တဲ့ စာလုံးတွေက // ဒါမှမဟုတ် # ဖြစ်တဲ့ စာကြောင်းတွေကို ကျော်ပါ
  • File၊ 1 ကစတဲ့ line number နဲ့ ကိုက်ညီတဲ့ host ကို ပြောပါ
  • တွေ့ရှိချက်နဲ့ ထိခိုက်တဲ့ file အရေအတွက်ကို file အားလုံးထဲက အကျဉ်းချုပ်နဲ့ ပိတ်ပါ
audit.mjs
// Hostnames of the retired service, as seen in tutorials written before the retirement.
const RETIRED = ["models.inference.ai.azure.com", "models.github.ai"];

function audit(files) {
  // files is an object of { "path": "file text" }
  // TODO 1: look at every line of every file, with 1-based line numbers
  // TODO 2: skip lines whose first non-space characters are // or # (comments)
  // TODO 3: when a line contains a retired host, record { file, number, host }
  return [];
}

// TODO 4: build four sample files in an object: one TypeScript file with one live
//   and one commented-out use, one .env with a retired host, one clean .env and
//   one README that only mentions a host inside a # line

// TODO 5: print one line per finding, for example   config/dev.env:1 models.github.ai
//   then a summary line such as   2 findings in 2 of 4 files

ရလဒ်: တွေ့ရှိချက်စာကြောင်းနှစ်ကြောင်း src/client.ts:3 models.github.ai နဲ့ config/dev.env:1 models.inference.ai.azure.com ပြီးရင် "2 findings in 2 of 4 files" ထွက်ပါမယ်။ Comment ပိတ်ထားတဲ့ URL နဲ့ README ထဲက ဖော်ပြချက်ကို ကျော်ပါတယ်။

အရိပ်အမြွက် ကြည့်ရန်

/^\s*(\/\/|#)/ လို regular expression က comment စာကြောင်းတွေကို သိပါတယ်။ File နာမည်တွေရဲ့ Set တစ်ခုက ထိခိုက်တဲ့ file အရေအတွက်ကို ပေးပါတယ်။

အဖြေ ကြည့်ရန်
audit.mjs
// Hostnames of the retired service, as seen in tutorials written before the retirement.
const RETIRED = ["models.inference.ai.azure.com", "models.github.ai"];

function audit(files) {
  const findings = [];
  for (const [file, text] of Object.entries(files)) {
    const lines = text.split("\n");
    for (let number = 1; number <= lines.length; number++) {
      const line = lines[number - 1];
      if (/^\s*(\/\/|#)/.test(line)) continue; // a commented-out URL is not a live call
      const host = RETIRED.find((name) => line.includes(name));
      if (host) findings.push({ file, number, host });
    }
  }
  return findings;
}

const files = {
  "src/client.ts": [
    "import OpenAI from 'openai';",
    "// old: https://models.github.ai/inference",
    "const baseURL = 'https://models.github.ai/inference';",
  ].join("\n"),
  "config/dev.env": "AI_BASE=https://models.inference.ai.azure.com\nREGION=eu",
  "config/prod.env": "AI_BASE=https://api.example.com/v1",
  "README.md": "# Setup\n# do not use models.github.ai any more",
};

const findings = audit(files);
for (const { file, number, host } of findings) console.log(file + ":" + number, host);
const dirty = new Set(findings.map((f) => f.file)).size;
const total = Object.keys(files).length;
console.log(findings.length + " findings in " + dirty + " of " + total + " files");

Quick Quiz 1 / 3

GitHub Models ဘာဖြစ်သွားတယ်လို့ GitHub documentation က ပြောသလဲ။

Quick Quiz 2 / 3

CI job တစ်ခုက GitHub App installation token နဲ့ REST API ကနေ Copilot cloud agent task တစ်ခု စတင်ပါတယ်။ ဘာဖြစ်မယ်လို့ မျှော်ရမလဲ။

Quick Quiz 3 / 3

Adapter က ရုပ်သိမ်းပြီးသား provider ဆီက 2xx မဟုတ်တဲ့ reply အားလုံးကို ဘာကြောင့် တူညီစွာ ကိုင်တာလဲ။

မှတ်ထားရမယ့် အချက်များ

  • GitHub Models ကို 2026 ဇူလိုင် 30 မှာ လုံးဝရုပ်သိမ်းခဲ့ပြီး Copilot က chat-completions အစားထိုး မဟုတ်ဘဲ သီးခြား product ပါ။
  • Programmable Copilot surface တွေမှာ Copilot SDK နဲ့ public preview ဖြစ်ပြီး user-to-server token ကိုပဲ လက်ခံတဲ့ cloud agent REST API တို့ ပါပါတယ်။
  • အစီအစဉ်တကျ ကူးပြောင်းပါ။ hostname အဟောင်းတွေကို inventory လုပ်၊ contract သတ်မှတ်၊ provider တစ်ခုစီအတွက် adapter တစ်ခုရေးပြီး mock server နဲ့ စမ်းပါ။
  • ရုပ်သိမ်းပြီးသား service ကိုပဲ ဝန်ဆောင်ခဲ့တဲ့ token တွေ revoke လုပ်ပြီး variable တွေ ဖျက်ပါ။

GitHub Models — Retirement Notice — GitHub

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

Copilot / GitHub Models Note | Thuta Learning