@@ -47,7 +47,7 @@ builder.AddDashScopeClient(builder.Configuration);
4747``` json
4848{
4949 "DashScope" : {
50- "ApiKey" : " your-api-key"
50+ "ApiKey" : " your-api-key" ,
5151 }
5252}
5353```
@@ -66,21 +66,54 @@ public class YourService(IDashScopeClient client)
6666
6767# Supported APIs
6868
69- - Text Embedding API - ` dashScopeClient.GetTextEmbeddingsAsync() `
70- - Text Generation API(qwen-turbo, qwen-max, etc.) - ` dashScopeClient.GetQwenCompletionAsync() ` and ` dashScopeClient.GetQWenCompletionStreamAsync() `
71- - BaiChuan Models - Use ` dashScopeClient.GetBaiChuanTextCompletionAsync() `
72- - LLaMa2 Models - ` dashScopeClient.GetLlama2TextCompletionAsync() `
73- - Multimodal Generation API(qwen-vl-max, etc.) - ` dashScopeClient.GetQWenMultimodalCompletionAsync() ` and ` dashScopeClient.GetQWenMultimodalCompletionStreamAsync() `
69+ - Text Embedding API - ` GetTextEmbeddingsAsync() `
70+ - Text Generation API(qwen-turbo, qwen-max, etc.) - ` GetQWenCompletionAsync() ` and ` GetQWenCompletionStreamAsync() `
71+ - DeepSeek Models - ` GetDeepSeekCompletionAsync() ` and ` GetDeepSeekCompletionStreamAsync() `
72+ - BaiChuan Models - Use ` GetBaiChuanTextCompletionAsync() `
73+ - LLaMa2 Models - ` GetLlama2TextCompletionAsync() `
74+ - Multimodal Generation API(qwen-vl-max, etc.) - ` GetQWenMultimodalCompletionAsync() ` and ` GetQWenMultimodalCompletionStreamAsync() `
7475- Wanx Models(Image generation, background generation, etc)
7576 - Image Synthesis - ` CreateWanxImageSynthesisTaskAsync() ` and ` GetWanxImageSynthesisTaskAsync() `
7677 - Image Generation - ` CreateWanxImageGenerationTaskAsync() ` and ` GetWanxImageGenerationTaskAsync() `
7778 - Background Image Generation - ` CreateWanxBackgroundGenerationTaskAsync() ` and ` GetWanxBackgroundGenerationTaskAsync() `
78- - File API that used by Qwen-Long - ` dashScopeClient. UploadFileAsync()` and ` dashScopeClient. DeleteFileAsync`
79+ - File API that used by Qwen-Long - ` UploadFileAsync() ` and ` DeleteFileAsync `
7980- Application call - ` GetApplicationResponseAsync() ` and ` GetApplicationResponseStreamAsync() `
8081
8182# Examples
8283
83- Visit [ tests] ( ./test ) for more usage of each api.
84+ Visit [ snapshots] ( ./test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.cs ) for calling samples.
85+
86+ Visit [ tests] ( ./test/Cnblogs.DashScope.Sdk.UnitTests ) for more usage of each api.
87+
88+ ## General Text Completion API
89+
90+ Use ` client.GetTextCompletionAsync ` and ` client.GetTextCompletionStreamAsync ` to access text generation api directly.
91+
92+ ``` csharp
93+ var completion = await dashScopeClient .GetTextCompletionAsync (
94+ new ModelRequest <TextGenerationInput , ITextGenerationParameters >
95+ {
96+ Model = " your-model-name" ,
97+ Input = new TextGenerationInput { Prompt = prompt },
98+ Parameters = new TextGenerationParameters ()
99+ {
100+ // control parameters as you wish.
101+ EnableSearch = true
102+ }
103+ });
104+ var completions = dashScopeClient .GetTextCompletionStreamAsync (
105+ new ModelRequest <TextGenerationInput , ITextGenerationParameters >
106+ {
107+ Model = " your-model-name" ,
108+ Input = new TextGenerationInput { Messages = [TextChatMessage .System (" you are a helpful assistant" ), TextChatMessage .User (" How are you?" )] },
109+ Parameters = new TextGenerationParameters ()
110+ {
111+ // control parameters as you wish.
112+ EnableSearch = true ,
113+ IncreamentalOutput = true
114+ }
115+ });
116+ ```
84117
85118## Single Text Completion
86119
@@ -90,6 +123,19 @@ var completion = await client.GetQWenCompletionAsync(QWenLlm.QWenMax, prompt);
90123Console .WriteLine (completion .Output .Text );
91124```
92125
126+ ## Reasoning
127+
128+ Use ` completion.Output.Choices![0].Message.ReasoningContent ` to access the reasoning content from model.
129+
130+ ``` csharp
131+ var history = new List <ChatMessage >
132+ {
133+ ChatMessage .User (" Calculate 1+1" )
134+ };
135+ var completion = await client .GetDeepSeekChatCompletionAsync (DeepSeekLlm .DeepSeekR1 , history );
136+ Console .WriteLine (completion .Output .Choices [0 ]! .Message .ReasoningContent );
137+ ```
138+
93139## Multi-round chat
94140
95141``` csharp
0 commit comments