Jiri Semantic Kernel na Shannon
Nye OpenAIChatCompletion nke Semantic Kernel AsyncOpenAI client e duziri gaa Shannon; plugins na automatic function calling ga-agba na models Shannon.
- Anwalere ya 7 Nov 2026
- OpenAI Chat Completions
- Ihe dị ka nkeji 3
Banyere Semantic Kernel
Semantic Kernel bụ SDK open-source nke Microsoft maka itinye AI n'apps na Python, C# na Java, nwere plugins, function calling na agents. Connector OpenAI ya na-anabata client OpenAI nke gị, ya mere client e duziri gaa Shannon na-eme ka kernel function ọ bụla gbaa na models Shannon.
Ihe ị chọrọ
- Shannon API key
- Keys na ojiji
- Base URL
-
https://api.shannon-ai.com/v1Endpoint:/v1/chat/completions - Snippet ọ bụla dị n'okpuru na-agbaso nhọrọ gị.
Tọọ ya
-
Wụnye Semantic Kernel
Shellpip install semantic-kernel -
Tinye Shannon dị ka chat service
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) -
Tinye plugin wee hapụ model ka ọ kpọọ ya
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())
Lelee na ọ na-arụ ọrụ
Zipu: Gbaa sample plugin ahụ.
Ihe ị ga-ahụ: Azịza e wuru site na nsonaazụ plugin: anwụ na-acha, 18 C na Oslo.
Models dabara Semantic Kernel
Id ọ bụla dị n'okpuru na-emeju ihe Semantic Kernel chọrọ. Nke mbụ bụ default na snippets.
| Model id | Context window | Mmepụta kachasị | Ntinye onyonyo |
|---|---|---|---|
Kimi-K3-uncensored-NVFP4 | 1,022,976 | 262,144 | Ee |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | Ee |
shannon-3 | 196,608 | 65,536 | Ee |
shannon-coder-1 | 131,072 | 65,536 | Mba |
Ihe ọ dị mma ịma
- Gafee
AsyncOpenAIclient nke gị: ọ bụ ụzọ e si atọ base URL na Python connector. - Na
FunctionChoiceBehavior.Auto(), kernel na-agba function ahụ wee jụọ model ọzọ, ya mere otu ajụjụ na-ewe requests abụọ.
Ndụmọdụ
chat.get_streaming_chat_message_contents(history, settings)na-eme stream azịza ahụ.- Na C#, connector OpenAI na-anakwa endpoint:
AddOpenAIChatCompletion(modelId: "<id>", endpoint: new Uri("https://api.shannon-ai.com/v1"), apiKey: key). Anyị nwara SDK Python. - Debanye ọtụtụ services nwere
service_iddị iche ka ị gwakọta models Shannon n'otu kernel.
Idozi nsogbu
| Mgbaàmà | Ihe kpatara ya | Idozi |
|---|---|---|
404 Not Found | base_url enweghị /v1. | Jiri https://api.shannon-ai.com/v1. |
| A naghị akpọ plugin ahụ ma ọlị | Enweghị function_choice_behavior na ntọala. | Jiri FunctionChoiceBehavior.Auto() wee gafee kernel=. |
401 Unauthorized | Key ahụ adịghị, e dehiere ya, ma ọ bụ a gbanwere ya. | Kọpịa key ahụ ọzọ site na Keys & usage; ọ na-amalite na sk-. |
context_length_exceeded ma ọ bụ "prompt is too long" | Mkparịta ụka ahụ dị ogologo karịa context window nke model ahụ. | Malite chat ọhụrụ, hapụ tool ahụ ka o mee ya ka ọ dị mkpụmkpụ, ma ọ bụ họrọ model nwere window buru ibu. |
insufficient_quota | Balance gị enweghị ike ịkwụ ụgwọ request ahụ. | Top up ma ọ bụ gbanwee plan; a naghị anwaghachi request ahụ n'onwe ya. |
Ajụjụ
Semantic Kernel ọ na-arụ ọrụ na Shannon?
Ee, site na OpenAIChatCompletion nwere AsyncOpenAI client nke base_url ya bụ https://api.shannon-ai.com/v1.
Automatic function calling ọ na-arụ ọrụ?
Ee; anyị gbara plugin call nwere FunctionChoiceBehavior.Auto().