Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
480 changes: 406 additions & 74 deletions README.md

Large diffs are not rendered by default.

2,290 changes: 2,191 additions & 99 deletions README.zh-Hans.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions sample/Cnblogs.DashScope.Sample/1024-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
中国程序员节,10月24日,你同意吗?
大家好!

国庆长假之后,我们来确定一下中国程序员节的日子吧。

9月份的时候,我们针对中国程序员节进行了讨论与投票。

起因是一条新闻“今天是程序员节”,俄罗斯把每年的第256(0x100th)天作为程序员节,通常是9月12日,也有可能是9月13日。

园友贤达在评论中说:

想想这么多年中国程序员这么辛苦,怎么就没有个法定的程序员节日呢?
可执行文件的代码只有0和1,希望有一个10.10为中国程序员节。
于是,很多朋友支持把10月10日作为中国程序员节。

但10月10日紧接着中秋节与国庆节之后,大家正在恢复调整进入工作状态之中。

所以我们觉得10月24日可能更合适(今年的10月24日是星期天),1024是很有意义的一个数字,1K=1024,1024=2的10次方,二进制10000000000,八进制2000,十六进制0x400。

所以在这里征询一下大家意见,如果你同意10月24日作为中国程序员节,请点击随笔下面的推荐按钮,如果不同意,请点击反对按钮。

如果确定了中国程序员节,我们会在那天组织网上的庆贺活动。如果大家对活动形式有好的建议,也欢迎在这里提出。
4 changes: 4 additions & 0 deletions sample/Cnblogs.DashScope.Sample/1024-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
程序员节,10月24日!
根据大家在“中国程序员节,10月24日,你同意吗”中的反馈,现在确定中国程序员节放在每年的10月24日。博客园将在10月24日那天组织网上庆祝活动。

希望通过程序员节,代表着我们的一种努力,努力将程序员们凝聚在一起,为社会创造更多价值,得到更多的认可。我们是程序员,不是代码工人,不是IT民工,是一群用代码改变世界的人。我们的代码可以给社会带来进步,也可能给社会带来灾难,我们的责任重于泰山;我们生活于现实世界,却在创造虚拟世界,我们的创造力无限...如果阿基米德是程序员,他会说“给我一台电脑,我就能改变世界”。
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
<None Update="Lenna.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="1024-1.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="1024-2.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions sample/Cnblogs.DashScope.Sample/ISample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Cnblogs.DashScope.Core;

namespace Cnblogs.DashScope.Sample;

public interface ISample
{
string Description { get; }
Task RunAsync(IDashScopeClient client);
}
79 changes: 79 additions & 0 deletions sample/Cnblogs.DashScope.Sample/Multimodal/ImageInputSample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System.Text;
using Cnblogs.DashScope.Core;

namespace Cnblogs.DashScope.Sample.Multimodal;

public class ImageInputSample : ISample
{
/// <inheritdoc />
public string Description => "Chat with image input";

/// <inheritdoc />
public async Task RunAsync(IDashScopeClient client)
{
var messages = new List<MultimodalMessage>();
messages.Add(
MultimodalMessage.User(
[
MultimodalMessageContent.ImageContent(
"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"),
MultimodalMessageContent.ImageContent("https://dashscope.oss-cn-beijing.aliyuncs.com/images/tiger.png"),
MultimodalMessageContent.TextContent("这些图展现了什么内容?")
]));
var completion = client.GetMultimodalGenerationStreamAsync(
new ModelRequest<MultimodalInput, IMultimodalParameters>()
{
Model = "qwen3-vl-plus",
Input = new MultimodalInput() { Messages = messages },
Parameters = new MultimodalParameters()
{
IncrementalOutput = true,
EnableThinking = true,
VlHighResolutionImages = true
}
});
var reply = new StringBuilder();
var reasoning = false;
MultimodalTokenUsage? usage = null;
await foreach (var chunk in completion)
{
var choice = chunk.Output.Choices[0];
if (string.IsNullOrEmpty(choice.Message.ReasoningContent) == false)
{
// reasoning
if (reasoning == false)
{
Console.Write("Reasoning > ");
reasoning = true;
}

Console.Write(choice.Message.ReasoningContent);
continue;
}

if (reasoning)
{
reasoning = false;
Console.WriteLine();
Console.Write("Assistant > ");
}

if (choice.Message.Content.Count == 0)
{
continue;
}

Console.Write(choice.Message.Content[0].Text);
reply.Append(choice.Message.Content[0].Text);
usage = chunk.Usage;
}

Console.WriteLine();
messages.Add(MultimodalMessage.Assistant([MultimodalMessageContent.TextContent(reply.ToString())]));
if (usage != null)
{
Console.WriteLine(
$"Usage: in({usage.InputTokens})/out({usage.OutputTokens})/image({usage.ImageTokens})/reasoning({usage.OutputTokensDetails?.ReasoningTokens})/total({usage.TotalTokens})");
}
}
}
Loading