Mastra ကို Shannon ဖြင့် အသုံးပြုခြင်း
Mastra agent အား Shannon ၏ URL၊ key နှင့် id ပါသော model object တစ်ခု ပေးပါ၊ ထို့နောက် streaming နှင့် tool များသည် Shannon model များပေါ်တွင် run သည်။
- 2026 နို 7 တွင် စမ်းသပ်ထားသည်
- OpenAI Chat Completions
- ခန့်မှန်း 3 မိနစ်
Mastra အကြောင်း
Mastra သည် agent၊ workflow၊ memory နှင့် retrieval များအတွက် local dev studio ပါသော TypeScript framework ဖြစ်သည်။ Agent များသည် ၎င်း၏ model router မှတစ်ဆင့် model တစ်ခုကို လက်ခံပြီး URL နှင့် key ပေးထားသော OpenAI-compatible endpoint မည်သည့်အရာကိုမဆို လက်ခံသည်။ ထို့ကြောင့် Mastra agent နှင့် workflow များသည် Shannon model များပေါ်တွင် run နိုင်သည်။
လိုအပ်သည်များ
- Shannon API key တစ်ခု
- Keys & usage စာမျက်နှာ
- အခြေ URL
-
https://api.shannon-ai.com/v1အဆုံးမှတ်:/v1/chat/completions - အောက်ပါ နမူနာအားလုံးသည် သင့်ရွေးချယ်မှုအတိုင်း ပြောင်းလဲသည်။
သတ်မှတ်ပုံ
-
Mastra ကို install လုပ်ပါ
Shellnpm install @mastra/core zod -
Shannon ပေါ်တွင် agent တစ်ခု ဖန်တီးပါ
idသည်<any prefix>/<Shannon id>ဖြစ်သည်။urlသည် chat endpoint မဟုတ်ဘဲ base URL ဖြစ်သည်။TypeScriptimport { Agent } from "@mastra/core/agent"; import { createTool } from "@mastra/core/tools"; import { z } from "zod"; const getWeather = createTool({ id: "get-weather", description: "Weather for a city", inputSchema: z.object({ city: z.string() }), execute: async ({ city }) => ({ weather: `Sunny, 18 C in ${city}` }), }); export const agent = new Agent({ id: "assistant", name: "assistant", instructions: "Answer briefly. Use tools for weather.", model: { id: "shannon/Kimi-K3-uncensored-NVFP4", url: "https://api.shannon-ai.com/v1", apiKey: process.env.SHANNON_API_KEY }, tools: { getWeather }, }); -
Stream လုပ်ပြီး generate လုပ်ပါ
TypeScriptconst stream = await agent.stream("Name three colours a cat can be."); for await (const text of stream.textStream) process.stdout.write(text); const r = await agent.generate("What is the weather in Oslo?"); console.log(r.text);
အလုပ်လုပ်ကြောင်း စစ်ဆေးပါ
ပို့ရန်: SHANNON_API_KEY သတ်မှတ်ပြီး နမူနာကို run ပါ။
မြင်ရမည့်အရာ: အရောင်များ stream ဝင်လာပြီး tool ၏ ရာသီဥတုကို သုံးထားသော အဖြေတစ်ခု ထွက်လာသည်။
Mastra နှင့် ကိုက်ညီသော model များ
အောက်ပါ id တိုင်းသည် Mastra ၏ လိုအပ်ချက်နှင့် ကိုက်ညီသည်။ ပထမ id သည် code နမူနာများတွင် default ဖြစ်သည်။
| မော်ဒယ် ID | Context အရွယ် | အများဆုံး output | ပုံ ထည့်သွင်းမှု |
|---|---|---|---|
Kimi-K3-uncensored-NVFP4 | 1,022,976 | 262,144 | ဟုတ် |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | ဟုတ် |
shannon-3 | 196,608 | 65,536 | ဟုတ် |
shannon-coder-1 | 131,072 | 65,536 | မဟုတ် |
သိထားသင့်သည်များ
urlသည်/v1ဖြင့်ဆုံးသော base URL ဖြစ်ရမည်၊ Mastra က/chat/completionsကို ထည့်ပေးသည်။- Shannon ၏
/v1/responsesကို အစားထိုးသုံးရန် model object တွင်api: "responses"ကို ထည့်ပါ။
အကြံပြုချက်များ
- local studio (
mastra dev) တွင် agent များကို မြင်ရန်Mastrainstance တွင် agent များကို မှတ်ပုံတင်ပါ။ - တူညီသော model object သည် model လက်ခံသော workflow နှင့် memory processor များတွင်လည်း အလုပ်လုပ်သည်။
- key ကို
apiKeyတွင် ပေးပါ၊ ဥပမာSHANNON_API_KEYမှ။ Mastra ၏ docs တွင် custom endpoint အတွက် ကိုယ်တိုင်ဖတ်သော variable အမည် မဖော်ပြထားပါ။
ပြဿနာဖြေရှင်းခြင်း
| လက္ခဏာ | အကြောင်းရင်း | ဖြေရှင်းနည်း |
|---|---|---|
404 Not Found | url တွင် /v1 မပါပါ သို့မဟုတ် /chat/completions ဖြင့် ဆုံးနေသည်။ | https://api.shannon-ai.com/v1 ကို သုံးပါ။ |
401 | apiKey ဗလာဖြစ်နေသည်။ | key ကို apiKey တွင် ပေးပါ။ |
401 Unauthorized | Key မရှိခြင်း၊ စာလုံးပေါင်းမှားခြင်း သို့မဟုတ် လဲလှယ်ပြီးသွားခြင်း ဖြစ်သည်။ | Keys & usage မှ key ကို ထပ်မံကူးယူပါ။ ၎င်းသည် sk- ဖြင့် စတင်သည်။ |
context_length_exceeded သို့မဟုတ် "prompt is too long" စာတို | စကားပြောဆိုမှုသည် model ၏ context window ထက် ပိုရှည်နေသည်။ | chat အသစ် စတင်ပါ၊ tool ကို ချုံ့ခွင့်ပေးပါ သို့မဟုတ် window ပိုကြီးသော model ကို ရွေးပါ။ |
insufficient_quota | သင့် လက်ကျန်ငွေသည် request အတွက် ပေးချေရန် မလုံလောက်ပါ။ | Top up ပြုလုပ်ပါ သို့မဟုတ် plan ပြောင်းပါ။ request ကို အလိုအလျောက် ပြန်မပို့ပါ။ |
မေးခွန်းများ
Mastra သည် Shannon နှင့် အလုပ်လုပ်ပါသလား။
လုပ်ပါသည်- url: "https://api.shannon-ai.com/v1" ပါသော agent model { id, url, apiKey } သည် Shannon သို့ ရောက်သည်။
Mastra tool များ အလုပ်လုပ်ပါသလား။
လုပ်ပါသည်၊ createTool tool များကို native tool call အဖြစ် ပို့သည်။