mirror of
https://github.com/HugeFrog24/go-telegram-bot.git
synced 2026-08-28 22:11:38 +00:00
README
This commit is contained in:
+29
-2
@@ -177,9 +177,13 @@ func webSearchTools(cfg *WebSearchConfig) []anthropic.BetaToolUnionParam {
|
||||
tools := []anthropic.BetaToolUnionParam{{OfWebSearchTool20250305: search}}
|
||||
|
||||
if cfg.Fetch {
|
||||
fetchAllowed := cfg.FetchAllowedDomains
|
||||
if len(fetchAllowed) == 0 {
|
||||
fetchAllowed = cfg.AllowedDomains
|
||||
}
|
||||
fetch := &anthropic.BetaWebFetchTool20250910Param{
|
||||
AllowedDomains: cfg.AllowedDomains,
|
||||
BlockedDomains: cfg.BlockedDomains,
|
||||
AllowedDomains: fetchHosts(fetchAllowed),
|
||||
BlockedDomains: fetchHosts(cfg.BlockedDomains),
|
||||
Citations: anthropic.BetaCitationsConfigParam{Enabled: param.NewOpt(true)},
|
||||
}
|
||||
if cfg.MaxUses > 0 {
|
||||
@@ -193,6 +197,29 @@ func webSearchTools(cfg *WebSearchConfig) []anthropic.BetaToolUnionParam {
|
||||
return tools
|
||||
}
|
||||
|
||||
// fetchHosts strips any path from each domain entry. web_fetch matches on host
|
||||
// only, so a path-scoped entry (valid for web_search) would otherwise never match
|
||||
// any fetch URL. Search keeps the path-scoped entries; fetch gets host-only.
|
||||
func fetchHosts(entries []string) []string {
|
||||
if len(entries) == 0 {
|
||||
return nil
|
||||
}
|
||||
seen := make(map[string]bool, len(entries))
|
||||
hosts := make([]string, 0, len(entries))
|
||||
for _, e := range entries {
|
||||
host := e
|
||||
if i := strings.IndexByte(host, '/'); i >= 0 {
|
||||
host = host[:i]
|
||||
}
|
||||
if host == "" || seen[host] {
|
||||
continue
|
||||
}
|
||||
seen[host] = true
|
||||
hosts = append(hosts, host)
|
||||
}
|
||||
return hosts
|
||||
}
|
||||
|
||||
func buildUserContext(username, firstName, lastName string, isPremium bool, languageCode string, messageTime int) string {
|
||||
name := strings.TrimSpace(firstName + " " + lastName)
|
||||
if name == "" {
|
||||
|
||||
Reference in New Issue
Block a user