Peke ki ngā ihirangi
Semantic Kernel

Ngā framework me ngā SDK

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/v1 Pito mutunga: /v1/chat/completions
Ka whai ia wāhanga waehere i raro iho i tō kōwhiringa.

Whakaritea

  1. Whakaurua a Semantic Kernel

    Shell
    pip install semantic-kernel
  2. Tāpirihia a Shannon hei ratonga chat

    Python
    from 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)
  3. Tāpirihia tētahi mono ka tukuna te model ki te karanga

    Python
    import 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 tauiraMatapihi horopakiOutput nui rawaInput 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

  1. Ka rere te chat.get_streaming_chat_message_contents(history, settings) i te whakautu.
  2. 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.
  3. Rēhitatia ngā ratonga maha me ngā service_id rerekē hei whakaranu i ngā model Shannon i tētahi kernel kotahi.

Te whakatika raruraru

TohuTakeWhakatika
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().

Kōwhiria tō reo

He ōrite ngā reo katoa. Kōwhiria te reo e hiahia ana koe ki te whakamahi.

Ūropi

Te Rāwhiti Waenga me Āwherika ki te Raki

Āhia ki te Tonga

Āhia ki te Tonga-ma-Rāwhiti

Āhia ki te Rāwhiti

Āhia Waenga me Kōkahu

Āwherika

Te Moana-nui-a-Kiwa

Reo Hanga me te Reo Tawhito