Senparc.AI is the AI extension package for the Senparc ecosystem. It currently focuses on LLM interaction and provides shared .NET abstractions for chat, text completion, embeddings, speech, image generation, Semantic Kernel integration, Microsoft Agent Framework integration, and agent workflows.
| Package | Description | NuGet |
|---|---|---|
Senparc.AI |
Base module for all standard interfaces and shared capabilities. | |
Senparc.AI.AgentKernel |
Agent-oriented kernel built on the Senparc.AI standard. It wraps Microsoft Agent Framework and supports Chat, Embedding, TTS, STT, Image, vector storage, plugins, multiple model backends, and rapid agent application development. | |
Senparc.AI.Kernel |
Semantic Kernel implementation of the Senparc.AI API surface. It is designed for plug-and-play integration. | |
Senparc.AI.PromptRange (standalone project) |
Base library that supports the PromptRange ecosystem through the Senparc.AI standard. It is implemented in Senparc.Xncf.PromptRange, can be used to build PromptRange-based extension applications, and supports Web, desktop, and mobile systems on .NET 6.0 or later. NeuCharFramework (NCF) integrates Senparc.Xncf.PromptRange by default, so it can be used directly without code changes. See What is PromptRange?. | |
Senparc.AI.Agents |
Agent integration extension module implemented with AutoGen. |
Configure OpenAI, Azure OpenAI, NeuCharAI, HuggingFace, FastAPI, or another supported AI platform in appsettings.json.
The configuration above works as follows:
AiPlatformselects the active platform. Supported values include:OpenAI: the official openai.com API.NeuCharAI: the Senparc relay API at https://www.neuchar.com.AzureOpenAI: Microsoft Azure OpenAI Service.HuggingFace: HuggingFace API.FastAPI: FastAPI endpoint.
- The system switches the platform automatically based on
AiPlatform; application logic does not need provider-specific branching. - Configure
OpenAIKeysonly whenAiPlatformisOpenAI. - Configure
NeuCharAIKeysonly whenAiPlatformisNeuCharAI. - Configure
AzureOpenAIKeysonly whenAiPlatformisAzureOpenAI. - Other platform types follow the same pattern.
- Each platform configuration includes a
ModelNamenode. Use it to specify the model for each capability. For example, set"Chat": "gpt-4"to use GPT-4 for chat.
Rate-limit references:
- Azure OpenAI quotas and limits: https://learn.microsoft.com/en-us/azure/cognitive-services/openai/quotas-limits
- OpenAI rate limits: https://platform.openai.com/docs/guides/rate-limits
Use separate platform key blocks and ModelName values when one application needs different providers or different models for Chat, Embedding, TextCompletion, SpeechToText, TextToSpeech, or image generation.
Model parameters can be supplied at runtime through the request and handler configuration APIs, allowing different users, conversations, or workloads to use different model settings without changing the static appsettings.json file.
Senparc.AI uses a conversational programming style. You do not need to learn every platform SDK in detail. Define what you want to do, configure the model, build the kernel, then run the request. The following chat example shows the basic flow:
// Read the AI model configuration automatically from appsettings.json.
var aiSetting = Senparc.AI.Config.SenparcAiSetting;
// Create the AI handler. This can also be supplied by dependency injection.
var handler = new SemanticAiHandler(aiSetting);
// Define AI call parameters and token limits.
var promptParameter = new PromptConfigParameter
{
MaxTokens = 2000,
Temperature = 0.7,
TopP = 0.5,
};
// Prepare the runtime.
var userId = "JeffreySu"; // Used to distinguish users.
var iWantToRun =
handler.IWantTo()
.ConfigModel(ConfigModel.Chat, userId)
.BuildKernel()
.RegisterSemanticFunction("ChatBot", "Chat", promptParameter)
.iWantToRun;
// Ask a question and get the result.
var prompt = "What is the population of China?";
var aiRequest = iWantToRun.CreateRequest(prompt, true, true);
var aiResult = await iWantToRun.RunAsync(aiRequest);
// aiResult.Result example: China has a population of about 1.4 billion.All quick-reference samples are located in the /Samples/ folder.
| Folder | Description |
|---|---|
Samples/Senparc.AI.Samples.AgentKernelConsoles |
AgentKernel command-line sample, including MAF Harness Agent. |
Samples/Senparc.AI.Samples.Consoles |
Command-line sample. |
Samples/Senparc.AI.Samples.Agents |
Agent sample with AutoGen integration. |
Open Senparc.AI.sln, set the API key and platform parameters in appsettings.json, then start the Senparc.AI.Samples.Consoles project.
Enter 1 to start the chat workflow.
Enter 2 on the main screen to start the TextCompletion workflow.
Enter 3 on the main screen to start the Embedding workflow. Embedding supports two categories: standard information and reference information. Select one in the next step.
Select 1 to enter the standard Embedding test. Input information is separated by three English colons. After entering the information, enter n to start the chat test.
Select 2 to enter the reference Embedding test. Input information is separated by three English colons. After entering the information, enter n to start the chat test.
Enter 4 on the main screen to start the DALL-E image generation workflow.
The result is returned as a URL. Enter s to save the generated image locally.
Note: the URL returned by the API is temporary and should not be used as a persistent display URL. Save the image promptly if you need to keep it.
- Implement more model and mode matching scenarios.
- Implement fully automatic factory module configuration.
- Integrate with Senparc.Weixin SDK so AI capabilities can be added with no logic-code changes, mainly for chat scenarios.
- Integrate with NeuCharFramework so AI capabilities can be added with no logic-code changes, mainly for development and cloud operation scenarios.
- Complete more default model adapters. Custom extension capability is already available.
- Improve standalone documentation.








