mirror of
https://github.com/langgenius/dify-docs-archived.git
synced 2026-07-21 09:55:25 -04:00
dify 网站嵌入 如何传入非 inputs的 数据,不希望能在前端展示。希望能赋值给环境变量或者会话变量。 #67
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dalaosheng on GitHub (Feb 20, 2025).
@dosubot[bot] commented on GitHub (Feb 20, 2025):
@dalaosheng 你好!我是一个可以帮助您解决错误、回答问题并成为贡献者的机器人。在等待人类维护者时,我可以为您提供帮助。
在 Dify 中,可以通过环境变量和会话变量来传递不希望在前端展示的数据。
环境变量:这些变量用于保护敏感信息,如 API 密钥和数据库密码。它们存储在工作流中,而不是代码中,可以在大多数节点中全局引用。环境变量通常是只读的,不能在前端直接访问。
会话变量:在 Chatflow 应用中使用会话变量,可以在同一会话中临时存储特定信息。这些变量支持多种数据类型,如字符串、数字、对象和数组,并且可以在会话中读写。
通过这些机制,您可以确保敏感数据在前端不被暴露 [1][2][3].
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
@dalaosheng commented on GitHub (Feb 20, 2025):
我是希望通过网站嵌入的方式。
window.difyChatbotConfig={
inputs:{
}
}
该办法只能改变输入的参数,我希望改变的是环境变量或者会话变量的参数。
@dosubot[bot] commented on GitHub (Feb 20, 2025):
在 Dify 的网站嵌入中,
window.difyChatbotConfig的inputs参数用于传递输入数据,但如果你希望修改环境变量或会话变量,直接通过前端配置可能不够。对于会话变量,Dify 提供了
chat-messagesAPI 端点,可以在会话中动态管理变量。你可以通过 API 调用来设置或修改会话变量,而不是通过前端的window.difyChatbotConfig。这需要在后端进行 API 调用,以确保安全性,避免在前端暴露敏感信息 [1]。环境变量通常用于存储敏感信息,如 API 密钥,通常在后端配置,不能通过前端直接修改。确保这些变量的安全性和隐私性是关键。
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
@dalaosheng commented on GitHub (Feb 20, 2025):
如何通过 API 调用来修改 chatflow 或者 workflow 的环境变量
@Kingyumu commented on GitHub (Mar 3, 2025):
你解决了吗,我也遇到了和你一样的问题
@gdamao commented on GitHub (Mar 6, 2025):
网站嵌入时,我们希望跟网站的数据有一些交互,自动设置会话变量,不需要让用户输入input,该怎么处理? https://github.com/langgenius/dify/issues/14899 使用隐藏的input变量