Skip to content

cnblogs/semantic-kernel-dashscope

 
 

Repository files navigation

Cnblogs.SemanticKernel.Connectors.DashScope

Semantic Kernel Connector to DashScope

Get started

Add the NuGet package to your project.

dotnet add package Cnblogs.SemanticKernel.Connectors.DashScope

Add the dashscope section to the appsettings.json file.

{
  "dashscope": {
    "modelId": "qwen-max"
  }
}

Add the api key to the user-secrets.

dotnet user-secrets init
dotnet user-secrets set "dashscope:apiKey" "sk-xxx"

Usage

Program.cs

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;

var builder = Kernel.CreateBuilder();
builder.Services.AddSingleton(GetConfiguration());
builder.AddDashScopeChatCompletion();
var kernel = builder.Build();

var prompt = @"<message role=""user"">Tell me about the Cnblogs</message>";
var result = await kernel.InvokePromptAsync(prompt);
Console.WriteLine(result);

static IConfiguration GetConfiguration()
{
    return new ConfigurationBuilder()
        .SetBasePath(Directory.GetCurrentDirectory())
        .AddJsonFile("appsettings.json")
        .AddUserSecrets<Program>()
        .Build();
}

public partial class Program
{ }

About

Semantic Kernel Connector to DashScope

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •