File tree Expand file tree Collapse file tree 1 file changed +50
-1
lines changed
Expand file tree Collapse file tree 1 file changed +50
-1
lines changed Original file line number Diff line number Diff line change 1- # SemanticKernel.DashScope
1+ # Cnblogs. SemanticKernel.Connectors .DashScope
22Semantic 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+
You can’t perform that action at this time.
0 commit comments