feat: publish sanitized custom.97 source
This commit is contained in:
1022 files changed
+69903
-19207
No files matched your search
@@ -38,14 +38,14 @@ func uploadDifyFile(c *gin.Context, info *relaycommon.RelayInfo, user string, me
|
||||
// Decode base64 string
|
||||
decodedData, err := base64.StdEncoding.DecodeString(base64Data)
|
||||
if err != nil {
|
||||
common.SysLog("failed to decode base64: " + err.Error())
|
||||
common.SysLog(common.LogText("failed to decode base64: %s", err.Error()))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Create temporary file
|
||||
tempFile, err := os.CreateTemp("", "dify-upload-*")
|
||||
if err != nil {
|
||||
common.SysLog("failed to create temp file: " + err.Error())
|
||||
common.SysLog(common.LogText("failed to create temp file: %s", err.Error()))
|
||||
return nil
|
||||
}
|
||||
defer tempFile.Close()
|
||||
@@ -53,7 +53,7 @@ func uploadDifyFile(c *gin.Context, info *relaycommon.RelayInfo, user string, me
|
||||
|
||||
// Write decoded data to temp file
|
||||
if _, err := tempFile.Write(decodedData); err != nil {
|
||||
common.SysLog("failed to write to temp file: " + err.Error())
|
||||
common.SysLog(common.LogText("failed to write to temp file: %s", err.Error()))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func uploadDifyFile(c *gin.Context, info *relaycommon.RelayInfo, user string, me
|
||||
|
||||
// Add user field
|
||||
if err := writer.WriteField("user", user); err != nil {
|
||||
common.SysLog("failed to add user field: " + err.Error())
|
||||
common.SysLog(common.LogText("failed to add user field: %s", err.Error()))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -76,13 +76,13 @@ func uploadDifyFile(c *gin.Context, info *relaycommon.RelayInfo, user string, me
|
||||
// Create form file
|
||||
part, err := writer.CreateFormFile("file", fmt.Sprintf("image.%s", strings.TrimPrefix(mimeType, "image/")))
|
||||
if err != nil {
|
||||
common.SysLog("failed to create form file: " + err.Error())
|
||||
common.SysLog(common.LogText("failed to create form file: %s", err.Error()))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Copy file content to form
|
||||
if _, err = io.Copy(part, bytes.NewReader(decodedData)); err != nil {
|
||||
common.SysLog("failed to copy file content: " + err.Error())
|
||||
common.SysLog(common.LogText("failed to copy file content: %s", err.Error()))
|
||||
return nil
|
||||
}
|
||||
writer.Close()
|
||||
@@ -90,7 +90,7 @@ func uploadDifyFile(c *gin.Context, info *relaycommon.RelayInfo, user string, me
|
||||
// Create HTTP request
|
||||
req, err := http.NewRequest("POST", uploadUrl, body)
|
||||
if err != nil {
|
||||
common.SysLog("failed to create request: " + err.Error())
|
||||
common.SysLog(common.LogText("failed to create request: %s", err.Error()))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func uploadDifyFile(c *gin.Context, info *relaycommon.RelayInfo, user string, me
|
||||
client := service.GetHttpClient()
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
common.SysLog("failed to send request: " + err.Error())
|
||||
common.SysLog(common.LogText("failed to send request: %s", err.Error()))
|
||||
return nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
@@ -111,7 +111,7 @@ func uploadDifyFile(c *gin.Context, info *relaycommon.RelayInfo, user string, me
|
||||
Id string `json:"id"`
|
||||
}
|
||||
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
|
||||
common.SysLog("failed to decode response: " + err.Error())
|
||||
common.SysLog(common.LogText("failed to decode response: %s", err.Error()))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ func requestOpenAI2Dify(c *gin.Context, info *relaycommon.RelayInfo, request dto
|
||||
var stringUser string
|
||||
err := json.Unmarshal(user, &stringUser)
|
||||
if err != nil {
|
||||
common.SysLog("failed to unmarshal user: " + err.Error())
|
||||
common.SysLog(common.LogText("failed to unmarshal user: %s", err.Error()))
|
||||
stringUser = helper.GetResponseID(c)
|
||||
}
|
||||
difyReq.User = stringUser
|
||||
@@ -231,7 +231,7 @@ func difyStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.R
|
||||
helper.StreamScannerHandler(c, resp, info, func(data string, sr *helper.StreamResult) {
|
||||
var difyResponse DifyChunkChatCompletionResponse
|
||||
if err := json.Unmarshal([]byte(data), &difyResponse); err != nil {
|
||||
common.SysLog("error unmarshalling stream response: " + err.Error())
|
||||
common.SysLog(common.LogText("error unmarshalling stream response: %s", err.Error()))
|
||||
sr.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user