Skip to content

Commit fa34960

Browse files
committed
feat: add example code
1 parent b12ba01 commit fa34960

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

sample/Cnblogs.DashScope.Sample/Program.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using Microsoft.Extensions.AI;
1010
using ChatMessage = Cnblogs.DashScope.Core.ChatMessage;
1111

12-
const string apiKey = "sk-**";
12+
const string apiKey = "sk-***";
1313
var dashScopeClient = new DashScopeClient(apiKey);
1414

1515
Console.WriteLine("Choose the sample you want to run:");
@@ -195,7 +195,9 @@ string GetWeather(WeatherReportParameters parameters)
195195

196196
async Task ChatWithMicrosoftExtensions()
197197
{
198+
Console.WriteLine("Requesting model...");
198199
var chatClient = dashScopeClient.AsChatClient("qwen-max");
199200
var response = await chatClient.CompleteAsync("你好,很高兴认识你");
200-
Console.WriteLine(JsonSerializer.Serialize(response));
201+
var serializerOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web) { WriteIndented = true };
202+
Console.WriteLine(JsonSerializer.Serialize(response, serializerOptions));
201203
}

sample/Cnblogs.DashScope.Sample/SampleTypeDescriptor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public static string GetDescription(this SampleType sampleType)
1111
SampleType.ChatCompletion => "Conversation between user and assistant",
1212
SampleType.ChatCompletionWithTool => "Function call sample",
1313
SampleType.ChatCompletionWithFiles => "File upload sample using qwen-long",
14+
SampleType.MicrosoftExtensionsAi => "Use with Microsoft.Extensions.AI",
1415
_ => throw new ArgumentOutOfRangeException(nameof(sampleType), sampleType, "Unsupported sample option")
1516
};
1617
}

0 commit comments

Comments
 (0)