Sebelisa Haystack le Shannon
Sebelisa OpenAIChatGenerator ea Haystack e nang le api_base_url e setiloeng ho Shannon; li-pipeline, streaming le li-tool li sebetsa ka eona.
- E lekiloe 2026 Pun 7
- OpenAI Chat Completions
- Metsotso e ka bang 2
Mabapi le Haystack
Haystack ke moralo o bulehileng oa mohloli oa Python oa deepset oa search, retrieval-augmented generation le li-agent, o hahiloeng ka likarolo tse hokelitsoeng ka li-pipeline. Chat generator ea eona ea OpenAI e amohela base URL, kahoo li-pipeline le li-agent li ka hlahisa ka li-model tsa Shannon.
Seo u se hlokang
- Senotlolo sa API sa Shannon
- Linotlolo le tšebeliso
- Base URL
-
https://api.shannon-ai.com/v1Endpoint:/v1/chat/completions - Snippet e 'ngoe le e 'ngoe e ka tlase e latela khetho ea hau.
E hlophise
-
Kenya Haystack
Shellpip install haystack-ai -
Theha generator 'me u etse streaming
Haystack e nka lisenotlolo e le lintho tsa
Secret;Secret.from_env_vare bala senotlolo ha karolo e sebetsa.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.")]) -
Bitsa li-tool
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)
Hlahloba hore e a sebetsa
Romela: Tsamaisa sampole ea streaming ha SHANNON_API_KEY e setiloe.
U lokela ho bona: Mebala e hatisoa ha e ntse e fihla.
Li-model tse loketseng Haystack
Id e 'ngoe le e 'ngoe e ka tlase e khotsofatsa seo Haystack e se hlokang. Ea pele ke default ho li-snippet.
| Id ea model | Fensetere ea context | Tsoa e kholo ka ho fetisisa | Kenyo ea setšoantšo |
|---|---|---|---|
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 | Che |
Ho molemo ho tseba
- Li-embedder le li-document store tsa Haystack li hloka model ea embedding; Shannon ha e sebeletse
/v1/embeddings, kahoo sebelisa embedder e 'ngoe bakeng sa retrieval. Secret.from_token("...")e sebetsa bakeng sa liteko tse potlakileng empa e ke ke ea fetoloa ho serialise le pipeline.
Malebela
- Karolo ea
Agentea Haystack e amohela generator ena e lechat_generator'me e tsamaisa tool loop bakeng sa hau. generation_kwargs={"max_completion_tokens": ...}e thibela bolelele ba karabo.- Sebelisa generator e ts'oanang ho pipeline ea RAG ka mor'a retriever le
ChatPromptBuilder.
Ho rarolla mathata
| Matšoao | Lebaka | Tokiso |
|---|---|---|
None of the following authentication environment variables are set | SHANNON_API_KEY ha e setiloe. | E romele ka export pele u tsamaisa pipeline. |
404 Not Found | api_base_url ha e na /v1. | Sebelisa https://api.shannon-ai.com/v1. |
401 Unauthorized | Senotlolo ha se eo, se ngotsoe hampe kapa se fetotsoe. | Kopitsa senotlolo hape ho tsoa ho Keys & usage; se qala ka sk-. |
context_length_exceeded / “prompt is too long” | Puisano e telele ho feta window ea model. | Qala chat e ncha, tlohela tool e e compact, kapa khetha model e nang le window e kholoanyane. |
insufficient_quota | Balance ea hau e ke ke ea lefella kopo. | Eketsa credit kapa fetola plan; kopo ha e lekoe hape ka boeona. |
Lipotso
Na Haystack e sebetsa le Shannon?
E, ka OpenAIChatGenerator(api_base_url="https://api.shannon-ai.com/v1").
Na li-tool lia sebetsa?
E; karabo e tlisa tool_calls, tseo re li lekileng.