Lo LlamaIndex pẹ̀lú Shannon
Lo kíláàsì OpenAILike ti LlamaIndex pẹ̀lú base URL Shannon; chat, streaming àti function calling ń ṣiṣẹ́ nípasẹ̀ rẹ̀.
- A dán an wò 7 Oṣù Bélú 2026
- OpenAI Chat Completions
- Nǹkan bí ìṣẹ́jú 2
Nípa LlamaIndex
LlamaIndex jẹ́ framework Python àti TypeScript fún àwọn app tó ń ka àwọn document rẹ: indexing, retrieval, àwọn agent àti workflow. Kíláàsì OpenAILike rẹ̀ ń bá olùpèsè-ìsìn èyíkéyìí tó bá OpenAI mu sọ̀rọ̀, nítorí náà àwọn model Shannon lè dáhùn àwọn ìbéèrè, pe àwọn tool kí wọ́n sì darí àwọn agent LlamaIndex.
Ohun tí o nílò
- API key Shannon kan
- Àwọn key àti ìlò
- Base URL
-
https://api.shannon-ai.com/v1Endpoint:/v1/chat/completions - Gbogbo àpẹẹrẹ code nísàlẹ̀ ń tẹ̀lé àṣàyàn rẹ.
Ṣètò rẹ̀
-
Fi ìṣọ̀kan tó jọ OpenAI sílẹ̀
Shellpip install llama-index-core llama-index-llms-openai-like -
Ṣẹ̀dá model náà kí o sì ṣe streaming
is_chat_model=Trueń lo chat endpoint;is_function_calling_model=Truejẹ́ kí àwọn agent pe àwọn tool;context_windowń sọ fún LlamaIndex iye ọ̀rọ̀ tó wọlé.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) -
Pe àwọn 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'})]
Ṣàyẹ̀wò pé ó ń ṣiṣẹ́
Fi ránṣẹ́: Ṣiṣẹ́ àpẹẹrẹ streaming náà.
Ó yẹ kí o rí: Àwọn àwọ̀ tí a tẹ̀ jáde bí wọ́n ṣe ń wọlé.
Àwọn model tó bá LlamaIndex mu
Id kọ̀ọ̀kan nísàlẹ̀ bá ohun tí LlamaIndex nílò mu. Èyí àkọ́kọ́ ni a ń lò ní ìbẹ̀rẹ̀ nínú àwọn àpẹẹrẹ code.
| Id model | Context window | Output tó pọ̀ jù | Input àwòrán |
|---|---|---|---|
Kimi-K3-uncensored-NVFP4 | 1,022,976 | 262,144 | Bẹ́ẹ̀ni |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | Bẹ́ẹ̀ni |
shannon-3 | 196,608 | 65,536 | Bẹ́ẹ̀ni |
shannon-coder-1 | 131,072 | 65,536 | Rárá |
Ètò model
LlamaIndex béèrè àwọn iye wọ̀nyí. Wọ́n tẹ̀lé model tí o yàn.
| Ètò | Iye | Ìdí |
|---|---|---|
context_window | 1022976 | LlamaIndex ń fi ọ̀rọ̀ tí a gbà sínú iye token yìí. |
Ó dára láti mọ̀
- Láìsí
is_chat_model=True,OpenAILikeń pe endpoint/v1/completionsàtijọ́, èyí tó ń dá404padà lórí Shannon. - Láìsí
is_function_calling_model=True, àwọn agent ń padà sí lílo tool tó dá lórí ọ̀rọ̀. - Retrieval nílò model embedding; Shannon kì í sìn
/v1/embeddings, nítorí náà ṣètòembed_modelti LlamaIndex sí olùpèsè mìíràn tàbí model àdúgbò.
Àwọn ìmọ̀ràn
- Ṣètò
Settings.llm = llmlẹ́ẹ̀kan kí gbogbo index, query engine àti agent lè lo Shannon. FunctionAgentàtiReActAgentméjèèjì ń gballmyìí.- Fún àwọn document gígùn, yan model tó ní window ńlá kí o sì gbé
context_windowsókè láti bá a mu.
Ìyanjú ìṣòro
| Àmì àìsàn | Ohun tó fà á | Ojútùú |
|---|---|---|
404 lórí /v1/completions | A kò ṣètò is_chat_model. | Fi is_chat_model=True ránṣẹ́. |
| Indexing ń béèrè fún key OpenAI | Model embedding àkọ́kọ́ ti LlamaIndex jẹ́ ti OpenAI. | Ṣètò Settings.embed_model sí model embedding tí o ní. |
401 Unauthorized | Key náà kò sí, a tẹ̀ ẹ́ ní àṣìṣe, tàbí a ti pààrọ̀ rẹ̀. | Daakọ key náà padà láti Àwọn key àti ìlò; ó bẹ̀rẹ̀ pẹ̀lú sk-. |
context_length_exceeded tàbí ìfiránṣẹ́ "prompt is too long" | Ìjíròrò náà gùn ju context window ti model lọ. | Bẹ̀rẹ̀ chat tuntun, jẹ́ kí tool náà kó o pọ̀, tàbí yan model tí window rẹ̀ tóbi jù. |
insufficient_quota | Balance rẹ kò tó láti sanwó fún ìbéèrè náà. | Fi credit kún un tàbí yí plan padà; ìbéèrè náà kò ní tún ara rẹ̀ gbìyànjú fúnra rẹ̀. |
Àwọn ìbéèrè
Ṣé LlamaIndex ń ṣiṣẹ́ pẹ̀lú Shannon?
Bẹ́ẹ̀ ni, nípasẹ̀ OpenAILike pẹ̀lú api_base="https://api.shannon-ai.com/v1".
Ṣé àwọn agent LlamaIndex lè pe àwọn tool lórí Shannon?
Bẹ́ẹ̀ ni; pẹ̀lú is_function_calling_model=True model náà ń dá àwọn tool call abínibí padà, èyí tí a dánwò.