Shannon සමඟ Mastra භාවිත කරන්න
Mastra agent එකකට Shannon හි URL, key සහ id සහිත model object එකක් දෙන්න; streaming සහ tools ඉන්පසු Shannon models මත ධාවනය වේ.
- පරීක්ෂා කළේ 2026 ඉල් 7
- OpenAI Chat Completions
- මිනිත්තු 3 ක් පමණ
Mastra ගැන
Mastra යනු agents, workflows, memory සහ retrieval සඳහා, local dev studio එකක් සහිත TypeScript framework එකකි. Agents model එකක් ගන්නේ එහි model router එක හරහාය, එය URL එකක් සහ key එකක් දුන් ඕනෑම OpenAI-අනුකූල endpoint එකක් පිළිගනී. එමගින් Mastra agents සහ workflows Shannon models මත ධාවනය කළ හැක.
ඔබට අවශ්ය දේ
- Shannon API key එකක්
- යතුරු සහ භාවිතය
- Base URL
-
https://api.shannon-ai.com/v1Endpoint:/v1/chat/completions - පහත සියලු code උදාහරණ ඔබේ තේරීම අනුගමනය කරයි.
සකසන්න
-
Mastra ස්ථාපනය කරන්න
Shellnpm install @mastra/core zod -
Shannon මත agent එකක් සාදන්න
idයනු<any prefix>/<Shannon id>ය;urlයනු base URL එකයි, chat endpoint එක නොවේ.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 සකසා නියැදිය ධාවනය කරන්න.
ඔබට පෙනිය යුත්තේ: වර්ණ stream වේ, ඉන්පසු tool එකේ කාලගුණය භාවිතා කරන පිළිතුරක්.
Mastra සඳහා ගැළපෙන model
පහත සෑම id එකක්ම Mastra ට අවශ්ය දේ සපුරයි. පළමු එක code උදාහරණවල පෙරනිමියයි.
| Model ID | සන්දර්භ කවුළුව | උපරිම 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) බැලීමට agentsMastrainstance එකක ලියාපදිංචි කරන්න. - Model එකක් ගන්නා workflows සහ memory processors වලද එම model object එකම ක්රියා කරයි.
- Key එක
apiKeyහි යවන්න, උදා.SHANNON_API_KEYවෙතින්; Mastra හි ලේඛන custom endpoint එකක් සඳහා එය තනිවම කියවන variable එකක් නම් නොකරයි.
ගැටලු නිරාකරණය
| රෝග ලක්ෂණය | හේතුව | විසඳුම |
|---|---|---|
404 Not Found | url හි /v1 නැත, නැතහොත් එය /chat/completions වලින් අවසන් වේ. | https://api.shannon-ai.com/v1 භාවිතා කරන්න. |
401 | apiKey හිස්ය. | Key එක apiKey හි යවන්න. |
401 Unauthorized | Key එක නැත, වැරදියට ටයිප් කර ඇත, නැතහොත් මාරු කර ඇත. | යතුරු සහ භාවිතය වෙතින් key එක නැවත පිටපත් කරන්න; එය sk- වලින් ආරම්භ වේ. |
context_length_exceeded / “prompt එක දිග වැඩියි” | සංවාදය model එකේ context window එකට වඩා දිගය. | නව chat එකක් අරඹන්න, මෙවලමට එය සම්පීඩනය කිරීමට ඉඩ දෙන්න, නැතහොත් විශාල context window එකක් ඇති model එකක් තෝරන්න. |
insufficient_quota | ඔබේ ශේෂය ඉල්ලීමේ ගාස්තුවට ප්රමාණවත් නොවේ. | Credit එකතු කරන්න හෝ සැලසුම වෙනස් කරන්න; ඉල්ලීම ඉබේම නැවත උත්සාහ නොකෙරේ. |
ප්රශ්න
Mastra Shannon සමග ක්රියා කරයිද?
ඔව්: url: "https://api.shannon-ai.com/v1" සහිත agent model { id, url, apiKey } Shannon වෙත ළඟා වේ.
Mastra tools ක්රියා කරයිද?
ඔව්; createTool tools native tool calls ලෙස යැවේ.