Skip to content

Commit 711e23c

Browse files
authored
feat: support ppt skill for qwen-doc-turbo (#193)
1 parent 498b931 commit 711e23c

13 files changed

Lines changed: 1495 additions & 5 deletions

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ Console.WriteLine($"Image token usage: {raw?.Usage?.ImageTokens}");
193193
- [Prefix Completion](#prefix-completion)
194194
- [Long Context (Qwen-Long)](#long-context-qwen-long)
195195
- [Code Interpreter](#code-interpreter)
196+
- [PPT Generation (Qwen-doc-turbo)](#ppt-generation-qwen-doc-turbo)
196197
- [Multimodal](#multimodal) - QWen-VL, QVQ, etc. Supports reasoning/visual understanding/OCR/audio understanding
197198
- [Upload file for multimodal usage](#upload-file-for-multimodal-usage)
198199
- [Image Recognition/Thinking](#image-recognition/thinking)
@@ -724,6 +725,72 @@ Usage: in(704)/out(234)/reasoning(142)/plugins(1)/total(938)
724725

725726

726727

728+
### PPT Generation (Qwen-doc-turbo)
729+
730+
Use `qwen-doc-turbo` with the PPT skill to generate a presentation from a document URL or prompt. Pass the document link via `TextChatMessage.DocUrl` and enable the PPT skill through `Parameters.Skill`.
731+
732+
- `DashScopeModelSkill.PptCreative` — generate a presentation in creative mode (no template required).
733+
- `DashScopeModelSkill.PptGeneral(templateId)` — generate in general mode using the given template.
734+
735+
The model emits the slide storyboard in `ReasoningContent`, and the final reply `Content` contains a download URL for the generated `.pptx` file.
736+
737+
```csharp
738+
var messages = new List<TextChatMessage>
739+
{
740+
TextChatMessage.System("You are a helpful assistant"),
741+
TextChatMessage.DocUrl("生成一个ppt", ["https://example.com/product-manual.docx"]),
742+
};
743+
var completion = client.GetTextCompletionStreamAsync(
744+
new ModelRequest<TextGenerationInput, ITextGenerationParameters>()
745+
{
746+
Model = "qwen-doc-turbo",
747+
Input = new TextGenerationInput() { Messages = messages },
748+
Parameters = new TextGenerationParameters()
749+
{
750+
ResultFormat = "message",
751+
IncrementalOutput = true,
752+
Skill = [DashScopeModelSkill.PptCreative]
753+
}
754+
});
755+
var reply = new StringBuilder();
756+
var reasoning = false;
757+
TextGenerationTokenUsage? usage = null;
758+
await foreach (var chunk in completion)
759+
{
760+
var choice = chunk.Output.Choices![0];
761+
if (string.IsNullOrEmpty(choice.Message.ReasoningContent) == false)
762+
{
763+
if (reasoning == false)
764+
{
765+
reasoning = true;
766+
Console.Write("Reasoning > ");
767+
}
768+
769+
Console.Write(choice.Message.ReasoningContent);
770+
continue;
771+
}
772+
773+
if (reasoning && string.IsNullOrEmpty(choice.Message.Content.Text) == false)
774+
{
775+
reasoning = false;
776+
Console.WriteLine();
777+
Console.Write("Assistant > ");
778+
}
779+
780+
Console.Write(choice.Message.Content);
781+
reply.Append(choice.Message.Content);
782+
usage = chunk.Usage;
783+
}
784+
785+
Console.WriteLine();
786+
if (usage != null)
787+
{
788+
Console.WriteLine($"Usage: in({usage.InputTokens})/out({usage.OutputTokens})/total({usage.TotalTokens})");
789+
}
790+
791+
// reply.ToString() contains the .pptx download URL
792+
```
793+
727794
## Multimodal
728795

729796
Use `GetMultimodalGenerationAsync`/`GetMultimodalGenerationStreamAsync`

README.zh-Hans.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ Console.WriteLine($"Image token usage: {raw?.Usage?.ImageTokens}");
200200
- [翻译能力(Qwen-MT)](#翻译能力(Qwen-MT))
201201
- [角色扮演(Qwen-Character)](#角色扮演(Qwen-Character))
202202
- [数据挖掘(Qwen-doc-turbo)](#数据挖掘(Qwen-doc-turbo))
203+
- [PPT 生成(Qwen-doc-turbo)](#ppt-生成(qwen-doc-turbo))
203204
- [深入研究(Qwen-Deep-Research)](#深入研究(Qwen-Deep-Research))
204205
- [多模态](#多模态) - QWen-VL,QVQ 等,支持推理/视觉理解/OCR/音频理解等场景
205206
- [视觉理解/推理](#视觉理解/推理) - 图像/视频输入与理解,支持推理模式
@@ -1824,6 +1825,72 @@ Deleting file1...Success
18241825
*/
18251826
````
18261827

1828+
### PPT 生成(Qwen-doc-turbo)
1829+
1830+
使用 `qwen-doc-turbo` 配合 PPT 技能,可以根据文档链接或提示词生成 PPT。通过 `TextChatMessage.DocUrl` 传入文档链接,并通过 `Parameters.Skill` 启用 PPT 技能。
1831+
1832+
- `DashScopeModelSkill.PptCreative` —— 创意模式生成 PPT(无需模板)。
1833+
- `DashScopeModelSkill.PptGeneral(templateId)` —— 通用模式,使用指定模板生成。
1834+
1835+
模型会将幻灯片脚本输出到 `ReasoningContent`,最终回复的 `Content` 中包含生成好的 `.pptx` 文件下载链接。
1836+
1837+
```csharp
1838+
var messages = new List<TextChatMessage>
1839+
{
1840+
TextChatMessage.System("You are a helpful assistant"),
1841+
TextChatMessage.DocUrl("生成一个ppt", ["https://example.com/product-manual.docx"]),
1842+
};
1843+
var completion = client.GetTextCompletionStreamAsync(
1844+
new ModelRequest<TextGenerationInput, ITextGenerationParameters>()
1845+
{
1846+
Model = "qwen-doc-turbo",
1847+
Input = new TextGenerationInput() { Messages = messages },
1848+
Parameters = new TextGenerationParameters()
1849+
{
1850+
ResultFormat = "message",
1851+
IncrementalOutput = true,
1852+
Skill = [DashScopeModelSkill.PptCreative]
1853+
}
1854+
});
1855+
var reply = new StringBuilder();
1856+
var reasoning = false;
1857+
TextGenerationTokenUsage? usage = null;
1858+
await foreach (var chunk in completion)
1859+
{
1860+
var choice = chunk.Output.Choices![0];
1861+
if (string.IsNullOrEmpty(choice.Message.ReasoningContent) == false)
1862+
{
1863+
if (reasoning == false)
1864+
{
1865+
reasoning = true;
1866+
Console.Write("Reasoning > ");
1867+
}
1868+
1869+
Console.Write(choice.Message.ReasoningContent);
1870+
continue;
1871+
}
1872+
1873+
if (reasoning && string.IsNullOrEmpty(choice.Message.Content.Text) == false)
1874+
{
1875+
reasoning = false;
1876+
Console.WriteLine();
1877+
Console.Write("Assistant > ");
1878+
}
1879+
1880+
Console.Write(choice.Message.Content);
1881+
reply.Append(choice.Message.Content);
1882+
usage = chunk.Usage;
1883+
}
1884+
1885+
Console.WriteLine();
1886+
if (usage != null)
1887+
{
1888+
Console.WriteLine($"Usage: in({usage.InputTokens})/out({usage.OutputTokens})/total({usage.TotalTokens})");
1889+
}
1890+
1891+
// reply.ToString() 包含 .pptx 文件的下载链接
1892+
```
1893+
18271894
### 深入研究(Qwen-Deep-Research)
18281895

18291896
深入研究大致可以分为如下步骤:

0 commit comments

Comments
 (0)