Skip to content

dify 的格式问题 #895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 tasks done
brilliantrough opened this issue May 5, 2025 · 3 comments
Open
4 tasks done

dify 的格式问题 #895

brilliantrough opened this issue May 5, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@brilliantrough
Copy link

在提问之前...

  • 我已经搜索了现有的 issues
  • 我在提问题之前至少花费了 5 分钟来思考和准备
  • 我已经认真且完整的阅读了 wiki
  • 我已经认真检查了问题和网络环境无关(包括但不限于Google不可用,模型下载失败)

使用的环境

OS: Ubuntu 24.04
Python: 3.10
pdf2zh: 1.9.6

请选择安装方式

源码

描述你的问题

目前 dify 最新版本 1.3.1,其返回格式应为 {"data": {"outputs": {"answer": "翻译后文本"}}
这个在 820 更改过,可能需要再更改回来。

另外可以考虑在 文档表格 中的 Dify 的 Notes 一栏中添加一个 输出设置 answer 参数 的提示。(阅读源码后才发现这个 hard code 的注意事项)

以下是 Dify 的响应格式
Image

如何复现

下载源码运行

预期行为

将 820 中的更改撤除掉,在文档表格中添加 answer 输出参数的提示

相关 Logs


原始PDF文件

No response

还有别的吗?

No response

@brilliantrough brilliantrough added the bug Something isn't working label May 5, 2025
@hellofinch
Copy link
Contributor

hellofinch commented May 6, 2025

好的,谢谢反馈。
: )

可以把dify相关的文档链接发一下吗?我仔细瞅瞅,我没找到对应的页面。 : (

@brilliantrough
Copy link
Author

brilliantrough commented May 6, 2025

更新一下上面的说法

查阅了一下,发现 dify 有工作流,Agent,Chatflow 的三种形式的应用。其中工作流是我上面所说的 {"data": {"outputs": {"answer": "翻译后文本"}},而 Agent 和 Chatflow 是用的 answer,所以 820 的改动应该没有问题

回复 可以把dify相关的文档链接发一下吗?我仔细瞅瞅,我没找到对应的页面。 : (

这个我是自己部署了 dify,自己构建了应用,然后在访问 API 界面可以查看到。相信可以直接在 dify 官网注册账号,并部署一个应用,然后去到访问 API 界面可以看见。

另外

DIFY_API_URL 的环境变量提示希望可以说明清楚是用的包含最终路径的链接,而不是 dify 的访问 API 界面提供的 BASE URL。比如 dify 提供的 BASE URL 为 https://dify.example.com/v1,但是在程序中有效的链接应为

  • 工作流: https://dify.example.com/v1/workflows/run
  • Chatflow: https://dify.example.com/v1/chat-messages
  • Agent: https://dify.example.com/v1/chat-messages

同时在表格中提醒用户在工作流应用中输出变量节点使用 answer 字段(也可以是其他的比如 text,统一规范即可)

希望改进

因为 dify 包含上述三种应用,其中返回格式有两套,推荐在最后的字典查询中,判断是否有 answer 字段或者 data 字段,以方便的兼容两种格式。

@hellofinch
Copy link
Contributor

OK 我仔细研究一下,看看dify的translator应该怎么说。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants