mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-10 19:23:42 +08:00
feat: chat with file function is ready
This commit is contained in:
@@ -88,7 +88,7 @@ func GetImgExt(filename string) string {
|
||||
return ext
|
||||
}
|
||||
|
||||
func ExtractImgURL(text string) []string {
|
||||
func ExtractImgURLs(text string) []string {
|
||||
re := regexp.MustCompile(`(http[s]?:\/\/.*?\.(?:png|jpg|jpeg|gif))`)
|
||||
matches := re.FindAllStringSubmatch(text, 10)
|
||||
urls := make([]string, 0)
|
||||
@@ -99,3 +99,15 @@ func ExtractImgURL(text string) []string {
|
||||
}
|
||||
return urls
|
||||
}
|
||||
|
||||
func ExtractFileURLs(text string) []string {
|
||||
re := regexp.MustCompile(`(http[s]?:\/\/.*?\.(?:docx?|pdf|pptx?|xlsx?|txt))`)
|
||||
matches := re.FindAllStringSubmatch(text, 10)
|
||||
urls := make([]string, 0)
|
||||
if len(matches) > 0 {
|
||||
for _, m := range matches {
|
||||
urls = append(urls, m[1])
|
||||
}
|
||||
}
|
||||
return urls
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user