Whakamahia a LlamaIndex me Shannon
Whakamahia te karaehe OpenAILike a LlamaIndex me te base URL a Shannon; ka mahi te chat, te rere me te karanga function mā roto.
- I whakamātauria 7 Noe 2026
- OpenAI Chat Completions
- Tata ki te 2 meneti
Mō LlamaIndex
He anga Python me TypeScript a LlamaIndex mō ngā taupānga e pānui ana i ō tuhinga: te whakarārangi, te rapu, ngā kaiwhakaahei me ngā rerekētanga mahi. Ka kōrero tana karaehe OpenAILike ki tētahi tūmau hototahi ki OpenAI, no reira ka taea e ngā model Shannon te whakautu pātai, te karanga tool me te kawe i ngā kaiwhakaahei LlamaIndex.
Ngā mea e hiahiatia ana
- He API key Shannon
- Ngā kī me te whakamahinga
- URL pūtake
-
https://api.shannon-ai.com/v1Pito mutunga:/v1/chat/completions - Ka whai ia wāhanga waehere i raro iho i tō kōwhiringa.
Whakaritea
-
Whakaurua te whakaurunga āhua-OpenAI
Shellpip install llama-index-core llama-index-llms-openai-like -
Hangaia te model ka rere
Ka whakamahi te
is_chat_model=Truei te endpoint chat; ka tuku teis_function_calling_model=Truei ngā kaiwhakaahei ki te karanga tool; ka kī tecontext_windowki a LlamaIndex te nui o te kuputuhi ka uru.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) -
Karanga i ngā tool
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'})]
Tirohia kei te mahi
Tukuna: Whakahaerehia te tauira rere.
Me kite koe i: Ka taia ngā tae i a rātou e rere mai ana.
Ngā model e hāngai ana ki LlamaIndex
Ka tutuki i ia id i raro iho ngā hiahia o LlamaIndex. Ko te tuatahi te taunoa i ngā wāhanga waehere.
| Id tauira | Matapihi horopaki | Output nui rawa | Input whakaahua |
|---|---|---|---|
Kimi-K3-uncensored-NVFP4 | 1,022,976 | 262,144 | Āe |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | Āe |
shannon-3 | 196,608 | 65,536 | Āe |
shannon-coder-1 | 131,072 | 65,536 | Kāo |
Ngā tautuhinga model
Ka tono a LlamaIndex i ēnei uara. Ka whai rātou i te model i kōwhiria e koe.
| Tautuhinga | Uara | He aha ai |
|---|---|---|
context_window | 1022976 | Ka whakauru a LlamaIndex i te kuputuhi kua rapua ki roto i te maha nei o ngā token. |
He pai kia mōhio
- Ki te kore te
is_chat_model=True, ka karanga teOpenAILikei te endpoint tawhito/v1/completions, ka hoki mai te404i runga i a Shannon. - Ki te kore te
is_function_calling_model=True, ka hoki ngā kaiwhakaahei ki te whakamahi tool i runga i te kuputuhi. - Ka hiahia te rapu ki tētahi model embedding; kāore a Shannon e whakahaere i te
/v1/embeddings, no reira tautuhia teembed_modela LlamaIndex ki tētahi atu kaiwhakarato, model rohe rānei.
Ngā tohutohu
- Tautuhia te
Settings.llm = llmkotahi anake kia whakamahia a Shannon e ia taurangi, muna rapu me kaiwhakaahei. - Ka tango te
FunctionAgentme teReActAgenti tēneillm. - Mō ngā tuhinga roa, kōwhiria tētahi model whai matapihi nui ka whakanuia te
context_windowkia ōrite.
Te whakatika raruraru
| Tohu | Take | Whakatika |
|---|---|---|
He 404 i runga i te /v1/completions | Kāore i tautuhia te is_chat_model. | Tukuna te is_chat_model=True. |
| Ka tonoa e te whakarārangi tētahi key OpenAI | Ko te model embedding taunoa a LlamaIndex nō OpenAI. | Tautuhia te Settings.embed_model ki tētahi model embedding kei a koe. |
401 Unauthorized | Kei te ngaro te key, kua hē te pato, kua hurihia rānei. | Tāruatia anō te key mai i Keys & usage; ka tīmata ki te sk-. |
context_length_exceeded, te karere "prompt is too long" rānei | He roa ake te kōrero i te matapihi horopaki o te model. | Tīmatahia he kōrerorero hou, tukuna te taputapu kia whakamāmā, kōwhiria rānei he model he nui ake te matapihi. |
insufficient_quota | Kāore e rawaka tō toenga hei utu i te tono. | Tāpiri nama, huri mahere rānei; kāore te tono e ngana anō ko ia anake. |
Ngā pātai
Ka mahi a LlamaIndex me Shannon?
Āe, mā te OpenAILike me te api_base="https://api.shannon-ai.com/v1".
Ka taea e ngā kaiwhakaahei LlamaIndex te karanga tool i runga i a Shannon?
Āe; me te is_function_calling_model=True ka whakahoki te model i ngā karanga tool taketake, i whakamātauria e mātou.