Whakamahia a Semantic Kernel me Shannon
Hoatu ki te OpenAIChatCompletion a Semantic Kernel tētahi kiritaki AsyncOpenAI kua tohua ki a Shannon; ka rere ngā mono me te karanga function aunoa i runga i ngā model Shannon.
- I whakamātauria 7 Noe 2026
- OpenAI Chat Completions
- Tata ki te 3 meneti
Mō Semantic Kernel
Ko Semantic Kernel te SDK pūtake-tuwhera a Microsoft mō te tāpiri AI ki ngā taupānga i Python, C# me Java, me ngā mono, te karanga function me ngā kaiwhakaahei. Ka whakaae tana tūhono OpenAI ki tō ake kiritaki OpenAI, no reira ma tētahi kiritaki kua tohua ki a Shannon ka rere ia function kernel i runga i ngā model Shannon.
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 a Semantic Kernel
Shellpip install semantic-kernel -
Tāpirihia a Shannon hei ratonga chat
Pythonfrom openai import AsyncOpenAI from semantic_kernel import Kernel from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion client = AsyncOpenAI(base_url="https://api.shannon-ai.com/v1", api_key="YOUR_API_KEY") chat = OpenAIChatCompletion(ai_model_id="Kimi-K3-uncensored-NVFP4", async_client=client) kernel = Kernel() kernel.add_service(chat) -
Tāpirihia tētahi mono ka tukuna te model ki te karanga
Pythonimport asyncio from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior from semantic_kernel.connectors.ai.open_ai import OpenAIChatPromptExecutionSettings from semantic_kernel.contents import ChatHistory from semantic_kernel.functions import kernel_function class Weather: @kernel_function(description="Weather for a city") def get_weather(self, city: str) -> str: return f"Sunny, 18 C in {city}" kernel.add_plugin(Weather(), plugin_name="weather") settings = OpenAIChatPromptExecutionSettings(function_choice_behavior=FunctionChoiceBehavior.Auto()) async def main(): history = ChatHistory() history.add_user_message("What is the weather in Oslo?") print(await chat.get_chat_message_content(history, settings, kernel=kernel)) asyncio.run(main())
Tirohia kei te mahi
Tukuna: Whakahaerehia te tauira mono.
Me kite koe i: He whakautu i hangaia mai i te hua a te mono: ra, 18 C i Oslo.
Ngā model e hāngai ana ki Semantic Kernel
Ka tutuki i ia id i raro iho ngā hiahia o Semantic Kernel. 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 |
He pai kia mōhio
- Tukuna tō ake kiritaki
AsyncOpenAI: koinei te huarahi hei tautuhi i tētahi base URL i te tūhono Python. - Me te
FunctionChoiceBehavior.Auto(), ka whakahaere te kernel i te function ka pātai anō ki te model, no reira e rua ngā tono mō tētahi pātai kotahi.
Ngā tohutohu
- Ka rere te
chat.get_streaming_chat_message_contents(history, settings)i te whakautu. - I C#, ka whakaae hoki te tūhono OpenAI ki tētahi endpoint:
AddOpenAIChatCompletion(modelId: "<id>", endpoint: new Uri("https://api.shannon-ai.com/v1"), apiKey: key). I whakamātauria e mātou te SDK Python. - Rēhitatia ngā ratonga maha me ngā
service_idrerekē hei whakaranu i ngā model Shannon i tētahi kernel kotahi.
Te whakatika raruraru
| Tohu | Take | Whakatika |
|---|---|---|
404 Not Found | Kāore i te whai te base_url i te /v1. | Whakamahia https://api.shannon-ai.com/v1. |
| Kāore te mono e karangahia | Kāore he function_choice_behavior i ngā tautuhinga. | Whakamahia te FunctionChoiceBehavior.Auto() ka tukuna te kernel=. |
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 Semantic Kernel me Shannon?
Āe, mā te OpenAIChatCompletion me tētahi kiritaki AsyncOpenAI e https://api.shannon-ai.com/v1 tōna base_url.
Ka mahi te karanga function aunoa?
Āe; i whakahaere mātou i tētahi karanga mono me te FunctionChoiceBehavior.Auto().