feat(web-search): refactor web search provider

- Updated relevant files to include provider registration, implementation, and metadata.
- Enhanced frontend components to support provider management and configuration.
- Added localization for new provider settings and messages.
- Implemented backend repository methods for CRUD operations on web search providers.
This commit is contained in:
wizardchen
2026-03-31 20:14:26 +08:00
committed by lyingbug
parent c59ae84157
commit a5ca9a2784
46 changed files with 2311 additions and 1499 deletions
+7 -27
View File
@@ -3,42 +3,22 @@ package handler
import (
"net/http"
"github.com/Tencent/WeKnora/internal/application/service/web_search"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/gin-gonic/gin"
)
// WebSearchHandler handles web search related requests
type WebSearchHandler struct {
registry *web_search.Registry
}
// WebSearchHandler handles legacy web search related requests
type WebSearchHandler struct{}
// NewWebSearchHandler creates a new web search handler
func NewWebSearchHandler(registry *web_search.Registry) *WebSearchHandler {
return &WebSearchHandler{
registry: registry,
}
func NewWebSearchHandler() *WebSearchHandler {
return &WebSearchHandler{}
}
// GetProviders returns the list of available web search providers
// @Summary Get available web search providers
// @Description Returns the list of available web search providers from configuration
// @Tags web-search
// @Accept json
// @Produce json
// @Success 200 {object} map[string]interface{} "List of providers"
// @Security Bearer
// @Security ApiKeyAuth
// @Router /web-search/providers [get]
// GetProviders returns the list of available web search provider types
func (h *WebSearchHandler) GetProviders(c *gin.Context) {
ctx := c.Request.Context()
logger.Info(ctx, "Getting web search providers")
providers := h.registry.GetAllProviderInfos()
logger.Infof(ctx, "Returning %d web search providers", len(providers))
c.JSON(http.StatusOK, gin.H{
"success": true,
"data": providers,
"data": types.GetWebSearchProviderTypes(),
})
}