Skip to content

Commit f24eb48

Browse files
authored
chore: update README.md (#2)
1 parent d90113f commit f24eb48

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

README.md

+50-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,51 @@
1-
# SemanticKernel.DashScope
1+
# Cnblogs.SemanticKernel.Connectors.DashScope
22
Semantic Kernel Connector to DashScope
3+
4+
## Get started
5+
Add the NuGet package to your project.
6+
```shell
7+
dotnet add package Cnblogs.SemanticKernel.Connectors.DashScope
8+
```
9+
10+
Add the `dashscope` section to the appsettings.json file.
11+
```json
12+
{
13+
"dashscope": {
14+
"modelId": "qwen-max"
15+
}
16+
}
17+
```
18+
Add the api key to the user-secrets.
19+
```shell
20+
dotnet user-secrets init
21+
dotnet user-secrets set "dashscope:apiKey" "sk-xxx"
22+
```
23+
## Usage
24+
Program.cs
25+
```cs
26+
using Microsoft.Extensions.Configuration;
27+
using Microsoft.Extensions.DependencyInjection;
28+
using Microsoft.SemanticKernel;
29+
30+
var builder = Kernel.CreateBuilder();
31+
builder.Services.AddSingleton(GetConfiguration());
32+
builder.AddDashScopeChatCompletion();
33+
var kernel = builder.Build();
34+
35+
var prompt = @"<message role=""user"">Tell me about the Cnblogs</message>";
36+
var result = await kernel.InvokePromptAsync(prompt);
37+
Console.WriteLine(result);
38+
39+
static IConfiguration GetConfiguration()
40+
{
41+
return new ConfigurationBuilder()
42+
.SetBasePath(Directory.GetCurrentDirectory())
43+
.AddJsonFile("appsettings.json")
44+
.AddUserSecrets<Program>()
45+
.Build();
46+
}
47+
48+
public partial class Program
49+
{ }
50+
```
51+

0 commit comments

Comments
 (0)