Skip to content

Commit c6e2aef

Browse files
committed
doc: update README with application call example
1 parent 72fd4a6 commit c6e2aef

File tree

2 files changed

+138
-0
lines changed

2 files changed

+138
-0
lines changed

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public class YourService(IDashScopeClient client)
7676
- Image Generation - `CreateWanxImageGenerationTaskAsync()` and `GetWanxImageGenerationTaskAsync()`
7777
- Background Image Generation - `CreateWanxBackgroundGenerationTaskAsync()` and `GetWanxBackgroundGenerationTaskAsync()`
7878
- File API that used by Qwen-Long - `dashScopeClient.UploadFileAsync()` and `dashScopeClient.DeleteFileAsync`
79+
- Application call - `GetApplicationResponseAsync()` and `GetApplicationResponseStreamAsync()`
7980

8081
# Examples
8182

@@ -208,3 +209,71 @@ Delete file if needed
208209
```csharp
209210
var deletionResult = await dashScopeClient.DeleteFileAsync(uploadedFile.Id);
210211
```
212+
213+
## Application call
214+
215+
Use `GetApplicationResponseAsync` to call an application.
216+
217+
Use `GetApplicationResponseStreamAsync` for streaming output.
218+
219+
```csharp
220+
var request =
221+
new ApplicationRequest()
222+
{
223+
Input = new ApplicationInput() { Prompt = "Summarize this file." },
224+
Parameters = new ApplicationParameters()
225+
{
226+
TopK = 100,
227+
TopP = 0.8f,
228+
Seed = 1234,
229+
Temperature = 0.85f,
230+
RagOptions = new ApplicationRagOptions()
231+
{
232+
PipelineIds = ["thie5bysoj"],
233+
FileIds = ["file_d129d632800c45aa9e7421b30561f447_10207234"]
234+
}
235+
}
236+
};
237+
var response = await client.GetApplicationResponseAsync("your-application-id", request);
238+
Console.WriteLine(response.Output.Text);
239+
```
240+
241+
`ApplicationRequest` use an `Dictionary<string, object?>` as `BizParams` by default.
242+
243+
```csharp
244+
var request =
245+
new ApplicationRequest()
246+
{
247+
Input = new ApplicationInput()
248+
{
249+
Prompt = "Summarize this file.",
250+
BizParams = new Dictionary<string, object?>()
251+
{
252+
{ "customKey1", "custom-value" }
253+
}
254+
}
255+
};
256+
var response = await client.GetApplicationResponseAsync("your-application-id", request);
257+
Console.WriteLine(response.Output.Text);
258+
```
259+
260+
You can use the generic version `ApplicationRequest<TBizParams>` for strong-typed `BizParams`. But keep in mind that client use `snake_case` by default when doing json serialization, you may need to use `[JsonPropertyName("camelCase")]` for other type of naming policy.
261+
262+
```csharp
263+
public record TestApplicationBizParam(
264+
[property: JsonPropertyName("sourceCode")]
265+
string SourceCode);
266+
267+
var request =
268+
new ApplicationRequest<TestApplicationBizParam>()
269+
{
270+
Input = new ApplicationInput<TestApplicationBizParam>()
271+
{
272+
Prompt = "Summarize this file.",
273+
BizParams = new TestApplicationBizParam("test")
274+
}
275+
};
276+
var response = await client.GetApplicationResponseAsync("your-application-id", request);
277+
Console.WriteLine(response.Output.Text);
278+
```
279+

README.zh-Hans.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public class YourService(IDashScopeClient client)
7676
- 人像风格重绘 - `CreateWanxImageGenerationTaskAsync()` and `GetWanxImageGenerationTaskAsync()`
7777
- 图像背景生成 - `CreateWanxBackgroundGenerationTaskAsync()` and `GetWanxBackgroundGenerationTaskAsync()`
7878
- 适用于 QWen-Long 的文件 API `dashScopeClient.UploadFileAsync()` and `dashScopeClient.DeleteFileAsync`
79+
- 应用调用 `dashScopeClient.GetApplicationResponseAsync``dashScopeClient.GetApplicationResponseStreamAsync()`
7980
- 其他使用相同 Endpoint 的模型
8081

8182
# 示例
@@ -204,3 +205,71 @@ Console.WriteLine(completion.Output.Choices[0].Message.Content);
204205
```csharp
205206
var deletionResult = await dashScopeClient.DeleteFileAsync(uploadedFile.Id);
206207
```
208+
209+
## 应用调用
210+
211+
`GetApplicationResponseAsync` 用于进行应用调用。
212+
213+
`GetApplicationResponseStreamAsync` 用于流式调用。
214+
215+
```csharp
216+
var request =
217+
new ApplicationRequest()
218+
{
219+
Input = new ApplicationInput() { Prompt = "Summarize this file." },
220+
Parameters = new ApplicationParameters()
221+
{
222+
TopK = 100,
223+
TopP = 0.8f,
224+
Seed = 1234,
225+
Temperature = 0.85f,
226+
RagOptions = new ApplicationRagOptions()
227+
{
228+
PipelineIds = ["thie5bysoj"],
229+
FileIds = ["file_d129d632800c45aa9e7421b30561f447_10207234"]
230+
}
231+
}
232+
};
233+
var response = await client.GetApplicationResponseAsync("your-application-id", request);
234+
Console.WriteLine(response.Output.Text);
235+
```
236+
237+
`ApplicationRequest` 默认使用 `Dictionary<string, object?>` 作为 `BizParams` 的类型。
238+
239+
```csharp
240+
var request =
241+
new ApplicationRequest()
242+
{
243+
Input = new ApplicationInput()
244+
{
245+
Prompt = "Summarize this file.",
246+
BizParams = new Dictionary<string, object?>()
247+
{
248+
{ "customKey1", "custom-value" }
249+
}
250+
}
251+
};
252+
var response = await client.GetApplicationResponseAsync("your-application-id", request);
253+
Console.WriteLine(response.Output.Text);
254+
```
255+
256+
如需强类型支持,可以使用泛型类 `ApplicationRequest<TBizParams>`
257+
注意 SDK 在 JSON 序列化时使用 `snake_case`。如果你的应用采用其他的命名规则,请使用 `[JsonPropertyName("camelCase")]` 来手动指定序列化时的属性名称。
258+
259+
```csharp
260+
public record TestApplicationBizParam(
261+
[property: JsonPropertyName("sourceCode")]
262+
string SourceCode);
263+
264+
var request =
265+
new ApplicationRequest<TestApplicationBizParam>()
266+
{
267+
Input = new ApplicationInput<TestApplicationBizParam>()
268+
{
269+
Prompt = "Summarize this file.",
270+
BizParams = new TestApplicationBizParam("test")
271+
}
272+
};
273+
var response = await client.GetApplicationResponseAsync("your-application-id", request);
274+
Console.WriteLine(response.Output.Text);
275+
```

0 commit comments

Comments
 (0)