dashscope-sdk icon indicating copy to clipboard operation
dashscope-sdk copied to clipboard

[BUG]

Open choby opened this issue 2 weeks ago • 2 comments

环境信息 安装的包及版本Cnblogs.DashScope.Sdk v0.9.0 .NET 10 使用的模型名称 qwen-doc-turbo、qwen-long

文件上传成功后,传入文件 id 到大模型,大模型提示 File:{fileid} parsing error,但是偶尔会成功,没找到规律

choby avatar Nov 29 '25 10:11 choby

你好,麻烦提供一下调用代码,我们这边测试一下。

示例代码(注意 qwen-long 需要使用 UploadFileAsync 而不是 UploadTemporaryFileAsync):

var file1 = await client.UploadFileAsync(File.OpenRead("1024-1.txt"), "file1.txt");
var file2 = await client.UploadFileAsync(File.OpenRead("1024-2.txt"), "file2.txt");

var messages = new List<TextChatMessage>();
messages.Add(TextChatMessage.System("You are a helpful assistant"));
messages.Add(TextChatMessage.File(file1.Id));
messages.Add(TextChatMessage.File(file2.Id));
messages.Add(TextChatMessage.User("这两篇文章分别讲了什么?"));

ikesnowy avatar Nov 29 '25 11:11 ikesnowy

阿里云似乎会对上传的文件有一个解析的操作,可以确认一下是不是和文件内容相关:

https://help.aliyun.com/zh/model-studio/error-code

Image

ikesnowy avatar Nov 29 '25 11:11 ikesnowy

复现地址: https://github.com/choby/CnblogsDashScope

choby avatar Nov 30 '25 01:11 choby

复现地址: https://github.com/choby/CnblogsDashScope

测试了一下是没问题的:

Image

测试用数据:

code.md

可以确认下文件格式是否支持,或者是否超出了限制

Image

ikesnowy avatar Nov 30 '25 05:11 ikesnowy

我们测试过 word ,pdf,图片,都存在问题

choby avatar Nov 30 '25 05:11 choby

我们测试过 word ,pdf,图片,都存在问题

目前我们这边复现不出来,有可能提供一个存在问题的文件吗?

或者尝试一下这个文件:code.md 看是否会出现相同的问题。

ikesnowy avatar Nov 30 '25 05:11 ikesnowy

可能是阿里的问题, 我在百炼大模型网页端直接使用也有同样问题:

Image

choby avatar Nov 30 '25 05:11 choby

另外能否增加doc_url 的文件支持:https://bailian.console.aliyun.com/?spm=5176.29619931.J_SEsSjsNv72yRuRFS2VknO.2.74cd10d7LKNHGa&tab=doc#/doc/?type=model&url=2948885

choby avatar Nov 30 '25 06:11 choby

另外能否增加doc_url 的文件支持:https://bailian.console.aliyun.com/?spm=5176.29619931.J_SEsSjsNv72yRuRFS2VknO.2.74cd10d7LKNHGa&tab=doc#/doc/?type=model&url=2948885

这个另外提 Issue 跟踪吧,实现起来比较困难。

通常这个 API 的 content 字段类型是 string,但这里变成了一个类,对于强类型语言很不友好。你可以看到官方的 Java SDK 也是不支持这个用法的。

在 #138 跟踪

ikesnowy avatar Nov 30 '25 06:11 ikesnowy

另外能否增加doc_url 的文件支持:https://bailian.console.aliyun.com/?spm=5176.29619931.J_SEsSjsNv72yRuRFS2VknO.2.74cd10d7LKNHGa&tab=doc#/doc/?type=model&url=2948885

刚发布了 v1.0.0-pre1 的包(需要在 nuget 管理器中允许安装 prerelease 的包),对 doc_url 提供了支持,用法:

var messages = new List<TextChatMessage>
    {
        TextChatMessage.System("You are a helpful assistant"),
        TextChatMessage.DocUrl(
            "从这两份产品手册中,提取所有产品信息,并整理成一个标准的JSON数组。每个对象需要包含:model(产品的型号)、name(产品的名称)、price(价格(去除货币符号和逗号))",
            [
                "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251107/jockge/%E7%A4%BA%E4%BE%8B%E4%BA%A7%E5%93%81%E6%89%8B%E5%86%8CA.docx",
                "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251107/ztwxzr/%E7%A4%BA%E4%BE%8B%E4%BA%A7%E5%93%81%E6%89%8B%E5%86%8CB.docx"
            ]),
    };

之前 qwen-long 的上传文件 API 更改了名称,现在是 OpenAiCompatibleUploadFileAsync,和 DashScope 自身提供的文件 API 做区分。

var file1 = await client.OpenAiCompatibleUploadFileAsync(File.OpenRead("1024-1.txt"), "file1.txt");
var messages = new List<TextChatMessage>();
messages.Add(TextChatMessage.System("You are a helpful assistant"));
messages.Add(TextChatMessage.File(file1.Id));
messages.Add(TextChatMessage.User("这篇文章讲了什么,整理成一个 JSON,需要包含标题(title)和摘要(description)"));

ikesnowy avatar Dec 01 '25 04:12 ikesnowy

其实可以跟阿里云发工单问一下的,具体出现错误的原因。

https://smartservice.console.aliyun.com/service/list?entrance=100&product=account

ikesnowy avatar Dec 01 '25 04:12 ikesnowy

该问题阿里云已修复.

choby avatar Dec 01 '25 09:12 choby