upgrade to v4.0.4

This commit is contained in:
RockYang
2024-05-07 16:32:05 +08:00
parent 2f0215ac87
commit 5c4899df6e
96 changed files with 3315 additions and 625 deletions

View File

@@ -83,4 +83,4 @@ func OpenAIRequest(db *gorm.DB, prompt string) (string, error) {
db.Model(&apiKey).UpdateColumn("last_used_at", time.Now().Unix())
return response.Choices[0].Message.Content, nil
}
}

View File

@@ -7,6 +7,7 @@ import (
"net/url"
"os"
"path/filepath"
"regexp"
"strings"
"time"
)
@@ -79,3 +80,15 @@ func GetImgExt(filename string) string {
}
return ext
}
func ExtractImgURL(text string) []string {
re := regexp.MustCompile(`(http[s]?:\/\/.*?\.(?:png|jpg|jpeg|gif))`)
matches := re.FindAllStringSubmatch(text, 10)
urls := make([]string, 0)
if len(matches) > 0 {
for _, m := range matches {
urls = append(urls, m[1])
}
}
return urls
}