update database file, add tika host config

This commit is contained in:
RockYang
2024-07-12 18:10:32 +08:00
parent eecce10018
commit 46141f87b8
19 changed files with 1087 additions and 89 deletions

View File

@@ -317,13 +317,18 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session *types.ChatSessio
// extract files in prompt
files := utils.ExtractFileURLs(prompt)
logger.Debugf("detected FILES: %+v", files)
if len(files) > 0 {
// 如果不是逆向模型,则提取文件内容
if len(files) > 0 && !(session.Model.Value == "gpt-4-all" ||
strings.HasPrefix(session.Model.Value, "gpt-4-gizmo") ||
strings.HasSuffix(session.Model.Value, "claude-3")) {
contents := make([]string, 0)
var file model.File
for _, v := range files {
h.DB.Where("url = ?", v).First(&file)
content, err := utils.ReadFileContent(v)
if err == nil {
content, err := utils.ReadFileContent(v, h.App.Config.TikaHost)
if err != nil {
logger.Error("error with read file: ", err)
} else {
contents = append(contents, fmt.Sprintf("%s 文件内容:%s", file.Name, content))
}
text = strings.Replace(text, v, "", 1)

View File

@@ -36,7 +36,7 @@ func (h *UploadHandler) Upload(c *gin.Context) {
return
}
logger.Info("upload file: %s", file.Name)
logger.Info("upload file: ", file.Name)
// cut the file name if it's too long
if len(file.Name) > 100 {
file.Name = file.Name[:90] + file.Ext

View File

@@ -256,8 +256,8 @@ func (h *UserHandler) Logout(c *gin.Context) {
resp.SUCCESS(c)
}
// Clogin 第三方登录请求二维码
func (h *UserHandler) Clogin(c *gin.Context) {
// CLogin 第三方登录请求二维码
func (h *UserHandler) CLogin(c *gin.Context) {
returnURL := h.GetTrim(c, "return_url")
var res types.BizVo
apiURL := fmt.Sprintf("%s/api/clogin/request", h.App.Config.ApiConfig.ApiURL)