mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-17 16:06:38 +08:00
feat: add env DIFY_DEBUG
This commit is contained in:
parent
4246c4cdc1
commit
20d71711d3
@ -72,6 +72,7 @@
|
|||||||
|
|
||||||
## 比原版One API多出的配置
|
## 比原版One API多出的配置
|
||||||
- `STREAMING_TIMEOUT`:设置流式一次回复的超时时间,默认为 30 秒
|
- `STREAMING_TIMEOUT`:设置流式一次回复的超时时间,默认为 30 秒
|
||||||
|
- `DIFY_DEBUG`:设置 Dify 渠道是否输出工作流和节点信息到客户端,默认为 `true`, 可选值为 `true` 和 `false`
|
||||||
|
|
||||||
## 部署
|
## 部署
|
||||||
### 部署要求
|
### 部署要求
|
||||||
|
@ -24,3 +24,15 @@ func GetEnvOrDefaultString(env string, defaultValue string) string {
|
|||||||
}
|
}
|
||||||
return os.Getenv(env)
|
return os.Getenv(env)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetEnvOrDefaultBool(env string, defaultValue bool) bool {
|
||||||
|
if env == "" || os.Getenv(env) == "" {
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
b, err := strconv.ParseBool(os.Getenv(env))
|
||||||
|
if err != nil {
|
||||||
|
SysError(fmt.Sprintf("failed to parse %s: %s, using default value: %t", env, err.Error(), defaultValue))
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
@ -5,3 +5,4 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var StreamingTimeout = common.GetEnvOrDefault("STREAMING_TIMEOUT", 30)
|
var StreamingTimeout = common.GetEnvOrDefault("STREAMING_TIMEOUT", 30)
|
||||||
|
var DifyDebug = common.GetEnvOrDefaultBool("DIFY_DEBUG", true)
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"one-api/common"
|
"one-api/common"
|
||||||
|
"one-api/constant"
|
||||||
"one-api/dto"
|
"one-api/dto"
|
||||||
relaycommon "one-api/relay/common"
|
relaycommon "one-api/relay/common"
|
||||||
"one-api/service"
|
"one-api/service"
|
||||||
@ -48,9 +49,9 @@ func streamResponseDify2OpenAI(difyResponse DifyChunkChatCompletionResponse) *dt
|
|||||||
Model: "dify",
|
Model: "dify",
|
||||||
}
|
}
|
||||||
var choice dto.ChatCompletionsStreamResponseChoice
|
var choice dto.ChatCompletionsStreamResponseChoice
|
||||||
if difyResponse.Event == "workflow_started" {
|
if constant.DifyDebug && difyResponse.Event == "workflow_started" {
|
||||||
choice.Delta.SetContentString("Workflow: " + difyResponse.Data.WorkflowId + "\n")
|
choice.Delta.SetContentString("Workflow: " + difyResponse.Data.WorkflowId + "\n")
|
||||||
} else if difyResponse.Event == "node_started" {
|
} else if constant.DifyDebug && difyResponse.Event == "node_started" {
|
||||||
choice.Delta.SetContentString("Node: " + difyResponse.Data.NodeId + "\n")
|
choice.Delta.SetContentString("Node: " + difyResponse.Data.NodeId + "\n")
|
||||||
} else if difyResponse.Event == "message" {
|
} else if difyResponse.Event == "message" {
|
||||||
choice.Delta.SetContentString(difyResponse.Answer)
|
choice.Delta.SetContentString(difyResponse.Answer)
|
||||||
|
Loading…
Reference in New Issue
Block a user