feat: support gpt-4-turbo-2014-04-09 vision function

This commit is contained in:
RockYang
2024-04-10 11:47:10 +08:00
parent 6efd92806f
commit abab76ccc6
14 changed files with 48 additions and 86 deletions

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
}