Sebenzisa i-Haystack ne-Shannon
Sebenzisa i-OpenAIChatGenerator ye-Haystack ene-api_base_url isethelwe ku-Shannon; amapayipi, ukusakaza namathuluzi kusebenza ngayo.
- Kuhlolwe ngo-Nov 7, 2026
- OpenAI Chat Completions
- Cishe imizuzu engu-2
Mayelana ne-Haystack
I-Haystack uhlaka lwe-open-source lwe-deepset lwe-Python lokusesha, ukukhiqiza okuthuthukiswe ngokutholwa kolwazi nama-ejenti, olwakhiwe ngezingxenye ezihlanganiswe emapayipini. Isakhi sayo sengxoxo se-OpenAI samukela i-base URL, ngakho amapayipi nama-ejenti angakhiqiza ngama-model e-Shannon.
Okudingayo
- I-API key ye-Shannon
- Ama-key nokusetshenziswa
- I-base URL
-
https://api.shannon-ai.com/v1I-endpoint:/v1/chat/completions - Wonke amasampula ekhodi angezansi alandela ukukhetha kwakho.
Kusethe
-
Faka i-Haystack
Shellpip install haystack-ai -
Dala isakhi bese usakaza
I-Haystack yamukela ama-key njengezinto ze-
Secret; i-Secret.from_env_variyifunda lapho isakhi sisebenza.Pythonfrom haystack.components.generators.chat import OpenAIChatGenerator from haystack.components.generators.utils import print_streaming_chunk from haystack.dataclasses import ChatMessage from haystack.utils import Secret llm = OpenAIChatGenerator( api_key=Secret.from_env_var("SHANNON_API_KEY"), model="Kimi-K3-uncensored-NVFP4", api_base_url="https://api.shannon-ai.com/v1", streaming_callback=print_streaming_chunk, ) llm.run([ChatMessage.from_user("Name three colours a cat can be.")]) -
Biza amathuluzi
Pythonfrom haystack.tools import Tool weather = Tool( name="get_weather", description="Weather for a city", parameters={"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}, function=lambda city: f"Sunny in {city}", ) gen = OpenAIChatGenerator(api_key=Secret.from_env_var("SHANNON_API_KEY"), model="Kimi-K3-uncensored-NVFP4", api_base_url="https://api.shannon-ai.com/v1", tools=[weather]) print(gen.run([ChatMessage.from_user("What is the weather in Oslo?")])["replies"][0].tool_calls)
Hlola ukuthi liyasebenza
Thumela: Sebenzisa isampula yokusakaza ne-SHANNON_API_KEY isethiwe.
Kufanele ubone: Imibala yaphrintwa njengoba isakazwa.
Ama-model afanele i-Haystack
Yonke i-id engezansi ihlangabezana nalokho i-Haystack ekudingayo. Eyokuqala iyi-default kumasampula ekhodi.
| I-id ye-model | Iwindi lomongo | Okuphumayo okuphezulu | Okufakwayo kwesithombe |
|---|---|---|---|
Kimi-K3-uncensored-NVFP4 | 1,022,976 | 262,144 | Yebo |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | Yebo |
shannon-3 | 196,608 | 65,536 | Yebo |
shannon-coder-1 | 131,072 | 65,536 | Cha |
Kuhle ukwazi
- Ama-embedder nezitolo zamadokhumenti ze-Haystack zidinga i-model ye-embedding; i-Shannon ayihlinzeki nge-
/v1/embeddings, ngakho sebenzisa i-embedder enye ekutholeni ulwazi. - I-
Secret.from_token("...")isebenza ekuhloleni okusheshayo kodwa ayikwazi ukuhlelwa ngapayipi.
Amathiphu
- Isakhi se-
Agentse-Haystack sithatha lesi sakhi njenge-chat_generatorfuthi sikusebenzela isiyingi sethuluzi. - I-
generation_kwargs={"max_completion_tokens": ...}ibeka umkhawulo ekuhlangeni kwempendulo. - Sebenzisa isakhi esifanayo epayipini le-RAG ngemva kwe-retriever ne-
ChatPromptBuilder.
Ukuxazulula izinkinga
| Uphawu | Imbangela | Isixazululo |
|---|---|---|
None of the following authentication environment variables are set | I-SHANNON_API_KEY ayisethiwe. | Yithekelise ngaphambi kokusebenzisa ipayipi. |
404 Not Found | I-api_base_url ayinayo i-/v1. | Sebenzisa https://api.shannon-ai.com/v1. |
401 Unauthorized | I-key ayikho, ibhalwe ngephutha noma ishintshiwe. | Kopisha i-key futhi ku-Ama-key nokusetshenziswa; iqala nge-sk-. |
context_length_exceeded / “i-prompt inde kakhulu” | Ingxoxo inde kunewindi lomongo le-model. | Qala ingxoxo entsha, vumela ithuluzi liyifinyeze, noma ukhethe i-model enewindi lomongo elikhulu. |
insufficient_quota | I-balance yakho ayikwazi ukukhokhela isicelo. | Yengeza i-credit noma ushintshe ipulani; isicelo asizanywa futhi ngokwaso. |
Imibuzo
Ingabe i-Haystack isebenza ne-Shannon?
Yebo, nge-OpenAIChatGenerator(api_base_url="https://api.shannon-ai.com/v1").
Ingabe amathuluzi ayasebenza?
Yebo; impendulo ithwala i-tool_calls, esikuhlolile.