Shannon සමඟ LlamaIndex භාවිත කරන්න
Shannon හි base URL සමග LlamaIndex හි OpenAILike class එක භාවිතා කරන්න; chat, streaming සහ function calling එය හරහා ක්රියා කරයි.
- පරීක්ෂා කළේ 2026 ඉල් 7
- OpenAI Chat Completions
- මිනිත්තු 2 ක් පමණ
LlamaIndex ගැන
LlamaIndex යනු ඔබේ ලේඛන කියවන apps සඳහා Python සහ TypeScript framework එකකි: indexing, retrieval, agents සහ workflows. එහි OpenAILike class එක ඕනෑම OpenAI-අනුකූල server එකක් සමග කතා කරන බැවින්, Shannon models වලට ප්රශ්නවලට පිළිතුරු දීමට, tools call කිරීමට සහ LlamaIndex agents මෙහෙයවීමට හැක.
ඔබට අවශ්ය දේ
- Shannon API key එකක්
- යතුරු සහ භාවිතය
- Base URL
-
https://api.shannon-ai.com/v1Endpoint:/v1/chat/completions - පහත සියලු code උදාහරණ ඔබේ තේරීම අනුගමනය කරයි.
සකසන්න
-
OpenAI-like integration එක ස්ථාපනය කරන්න
Shellpip install llama-index-core llama-index-llms-openai-like -
Model එක සාදා stream කරන්න
is_chat_model=Truechat endpoint එක භාවිතා කරයි;is_function_calling_model=Trueagents වලට tools call කිරීමට ඉඩ දෙයි;context_windowමගින් LlamaIndex ට කොපමණ text ප්රමාණයක් ගැලපෙන්නේදැයි කියයි.Pythonfrom llama_index.llms.openai_like import OpenAILike llm = OpenAILike( model="Kimi-K3-uncensored-NVFP4", api_base="https://api.shannon-ai.com/v1", api_key="YOUR_API_KEY", context_window=1022976, is_chat_model=True, is_function_calling_model=True, ) for r in llm.stream_complete("Name three colours a cat can be."): print(r.delta, end="", flush=True) -
Tools call කරන්න
Pythonfrom llama_index.core.tools import FunctionTool def get_weather(city: str) -> str: """Weather for a city.""" return f"Sunny in {city}" tool = FunctionTool.from_defaults(fn=get_weather) resp = llm.chat_with_tools([tool], user_msg="What is the weather in Oslo?") print(llm.get_tool_calls_from_response(resp)) # [ToolSelection(tool_name='get_weather', tool_kwargs={'city': 'Oslo'})]
එය ක්රියා කරන බව පරීක්ෂා කරන්න
යවන්න: Streaming නියැදිය ධාවනය කරන්න.
ඔබට පෙනිය යුත්තේ: වර්ණ stream වන විටම මුද්රණය වේ.
LlamaIndex සඳහා ගැළපෙන model
පහත සෑම id එකක්ම LlamaIndex ට අවශ්ය දේ සපුරයි. පළමු එක 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 | නැත |
Model සැකසුම්
LlamaIndex මෙම අගයන් ඉල්ලයි. ඒවා ඔබ තෝරාගත් model එක අනුව වෙනස් වේ.
| සැකසුම | අගය | ඇයි |
|---|---|---|
context_window | 1022976 | LlamaIndex සොයාගත් text මෙම tokens ගණනට ගැළපෙන සේ සකසයි. |
දැනගත යුතු දේ
is_chat_model=TrueනොමැතිවOpenAILikeපැරණි/v1/completionsendpoint එක call කරයි, එය Shannon හි404ලබා දෙයි.is_function_calling_model=Trueනොමැතිව agents text-පාදක tool භාවිතයට ආපසු හැරේ.- Retrieval සඳහා embedding model එකක් අවශ්යයි; Shannon
/v1/embeddingsසපයන්නේ නැත, එබැවින් LlamaIndex හිembed_modelවෙනත් provider කෙනෙකුට හෝ local model එකකට සකසන්න.
ඉඟි
- සෑම index, query engine සහ agent එකක්ම Shannon භාවිතා කිරීමට
Settings.llm = llmඑක් වරක් සකසන්න. FunctionAgentසහReActAgentදෙකම මෙමllmගනී.- දිගු ලේඛන සඳහා විශාල window එකක් සහිත model එකක් තෝරා, ඊට ගැළපෙන සේ
context_windowඉහළ දමන්න.
ගැටලු නිරාකරණය
| රෝග ලක්ෂණය | හේතුව | විසඳුම |
|---|---|---|
/v1/completions හි 404 | is_chat_model සකසා නැත. | is_chat_model=True යවන්න. |
| Indexing OpenAI key එකක් ඉල්ලයි | LlamaIndex හි පෙරනිමි embedding model එක OpenAI හි එකයි. | Settings.embed_model ඔබ සතු embedding model එකකට සකසන්න. |
401 Unauthorized | Key එක නැත, වැරදියට ටයිප් කර ඇත, නැතහොත් මාරු කර ඇත. | යතුරු සහ භාවිතය වෙතින් key එක නැවත පිටපත් කරන්න; එය sk- වලින් ආරම්භ වේ. |
context_length_exceeded / “prompt එක දිග වැඩියි” | සංවාදය model එකේ context window එකට වඩා දිගය. | නව chat එකක් අරඹන්න, මෙවලමට එය සම්පීඩනය කිරීමට ඉඩ දෙන්න, නැතහොත් විශාල context window එකක් ඇති model එකක් තෝරන්න. |
insufficient_quota | ඔබේ ශේෂය ඉල්ලීමේ ගාස්තුවට ප්රමාණවත් නොවේ. | Credit එකතු කරන්න හෝ සැලසුම වෙනස් කරන්න; ඉල්ලීම ඉබේම නැවත උත්සාහ නොකෙරේ. |
ප්රශ්න
LlamaIndex Shannon සමග ක්රියා කරයිද?
ඔව්, api_base="https://api.shannon-ai.com/v1" සහිත OpenAILike හරහා.
LlamaIndex agents ට Shannon මත tools call කළ හැකිද?
ඔව්; is_function_calling_model=True සමග model එක native tool calls ආපසු දෙයි, අපි එය පරීක්ෂා කළෙමු.