Files
yawan f7fc992f57
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
2026-09-22 16:19:06 +08:00

67 lines
2.0 KiB
Go

package web_search
import (
"fmt"
"strings"
"github.com/Tencent/WeKnora/internal/types"
)
// emptyResultDiagnostics is implemented by providers that can explain an empty
// search result set (used by the settings "test connection" flow).
type emptyResultDiagnostics interface {
EmptyResultDiagnostics() string
}
// EmptyTestResultsError builds a provider-specific message when a connectivity
// test search succeeds but returns no usable results.
func EmptyTestResultsError(providerType string, provider any) error {
detail := ""
if dr, ok := provider.(emptyResultDiagnostics); ok {
detail = dr.EmptyResultDiagnostics()
}
switch types.WebSearchProviderType(providerType) {
case types.WebSearchProviderTypeSearxng:
if detail != "" {
return fmt.Errorf("searxng returned 0 results: %s", detail)
}
return fmt.Errorf(
"searxng returned 0 results; verify the instance URL, JSON format in settings.yml, and upstream search engine connectivity",
)
case types.WebSearchProviderTypeDuckDuckGo:
return fmt.Errorf("duckduckgo returned 0 results; verify network connectivity and proxy settings")
case types.WebSearchProviderTypeKeenable:
return fmt.Errorf(
"keenable returned 0 results; keyless requests are rate-limited, so verify network connectivity or set an API key to lift the cap",
)
case types.WebSearchProviderTypeExa:
return fmt.Errorf(
"exa returned 0 results; verify the API key, account quota, network connectivity, and proxy settings",
)
default:
return fmt.Errorf("search returned 0 results, please verify your API key and configuration")
}
}
func formatUnresponsiveEngines(engines [][]string) string {
if len(engines) == 0 {
return ""
}
parts := make([]string, 0, len(engines))
for _, e := range engines {
if len(e) == 0 {
continue
}
if len(e) == 1 {
parts = append(parts, e[0])
continue
}
parts = append(parts, e[0]+" ("+e[1]+")")
}
if len(parts) == 0 {
return ""
}
return "unresponsive engines: " + strings.Join(parts, ", ")
}