![]() |
VOOZH | about |
dotnet add package Cnblogs.KernelMemory.AI.DashScope --version 0.5.2
NuGet\Install-Package Cnblogs.KernelMemory.AI.DashScope -Version 0.5.2
<PackageReference Include="Cnblogs.KernelMemory.AI.DashScope" Version="0.5.2" />
<PackageVersion Include="Cnblogs.KernelMemory.AI.DashScope" Version="0.5.2" />Directory.Packages.props
<PackageReference Include="Cnblogs.KernelMemory.AI.DashScope" />Project file
paket add Cnblogs.KernelMemory.AI.DashScope --version 0.5.2
#r "nuget: Cnblogs.KernelMemory.AI.DashScope, 0.5.2"
#:package Cnblogs.KernelMemory.AI.DashScope@0.5.2
#addin nuget:?package=Cnblogs.KernelMemory.AI.DashScope&version=0.5.2Install as a Cake Addin
#tool nuget:?package=Cnblogs.KernelMemory.AI.DashScope&version=0.5.2Install as a Cake Tool
Make DashScope work with Semantic Kernel and Kernel Memory.
Add the NuGet package to your project.
dotnet add package Cnblogs.SemanticKernel.Connectors.DashScope
using Microsoft.SemanticKernel;
var builder = Kernel.CreateBuilder();
builder.Services.AddDashScopeChatCompletion("your-api-key", "qwen-max");
var kernel = builder.Build();
var prompt = "<message role=\"user\">Tell me about the Cnblogs</message>";
var response = await kernel.InvokePromptAsync(prompt);
Console.WriteLine(response);
Install Nuget package Cnblogs.KernelMemory.AI.DashScope
Install Nuget package Microsoft.KernelMemory.Core
Install Nuget package Microsoft.KernelMemory.SemanticKernelPlugin
appsettings.json
{
"dashScope": {
"apiKey": "your-key",
"chatCompletionModelId": "qwen-max",
"textEmbeddingModelId": "text-embedding-v3"
}
}
Program.cs
// Kernel Memory stuff
var memory = new KernelMemoryBuilder(builder.Services).WithDashScope(builder.Configuration).Build();
builder.Services.AddSingleton(memory);
// SK stuff
builder.Services.AddDashScopeChatCompletion(builder.Configuration);
builder.Services.AddSingleton(
sp =>
{
var plugins = new KernelPluginCollection();
plugins.AddFromObject(
new MemoryPlugin(sp.GetRequiredService<IKernelMemory>(), waitForIngestionToComplete: true),
"memory");
return new Kernel(sp, plugins);
});
Services
public class YourService(Kernel kernel, IKernelMemory memory)
{
public async Task<string> GetCompletionAsync(string prompt)
{
var chatResult = await kernel.InvokePromptAsync(prompt);
return chatResult.ToString();
}
public async Task ImportDocumentAsync(string filePath, string documentId)
{
await memory.ImportDocumentAsync(filePath, documentId);
}
public async Task<string> AskMemoryAsync(string question)
{
// use memory.ask to query kernel memory
var skPrompt = """
Question to Kernel Memory: {{$input}}
Kernel Memory Answer: {{memory.ask $input}}
If the answer is empty say 'I don't know' otherwise reply with a preview of the answer, truncated to 15 words.
""";
// you can bundle created functions into a singleton service to reuse them
var myFunction = kernel.CreateFunctionFromPrompt(skPrompt);
var result = await myFunction.InvokeAsync(question);
return result.ToString();
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.