@@ -47,7 +47,7 @@ builder.AddDashScopeClient(builder.Configuration);
47
47
``` json
48
48
{
49
49
"DashScope" : {
50
- "ApiKey" : " your-api-key"
50
+ "ApiKey" : " your-api-key" ,
51
51
}
52
52
}
53
53
```
@@ -66,21 +66,54 @@ public class YourService(IDashScopeClient client)
66
66
67
67
# Supported APIs
68
68
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() `
74
75
- Wanx Models(Image generation, background generation, etc)
75
76
- Image Synthesis - ` CreateWanxImageSynthesisTaskAsync() ` and ` GetWanxImageSynthesisTaskAsync() `
76
77
- Image Generation - ` CreateWanxImageGenerationTaskAsync() ` and ` GetWanxImageGenerationTaskAsync() `
77
78
- 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 `
79
80
- Application call - ` GetApplicationResponseAsync() ` and ` GetApplicationResponseStreamAsync() `
80
81
81
82
# Examples
82
83
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
+ ```
84
117
85
118
## Single Text Completion
86
119
@@ -90,6 +123,19 @@ var completion = await client.GetQWenCompletionAsync(QWenLlm.QWenMax, prompt);
90
123
Console .WriteLine (completion .Output .Text );
91
124
```
92
125
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
+
93
139
## Multi-round chat
94
140
95
141
``` csharp
0 commit comments