- Updated .env.example to include new configuration options for the UltiAI branding and API endpoints. - Enhanced Nginx configuration to support new API routes for the MCP and WebSocket connections. - Introduced sub-filters for branding adjustments in Nginx responses. - Added new JavaScript patch for API endpoint adjustments. - Implemented tests for new API functionalities and improved error handling in the AI gateway.
35 lines
862 B
Go
35 lines
862 B
Go
package discovery
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/ultisuite/ulti-backend/internal/websearch"
|
|
)
|
|
|
|
var ErrWebSearchNotConfigured = errors.New("web search not configured")
|
|
|
|
func (s *Service) SearchWeb(ctx context.Context, externalUserID, query string, count int) ([]websearch.Result, error) {
|
|
if s.websearch == nil {
|
|
return nil, fmt.Errorf("web search unavailable")
|
|
}
|
|
query = strings.TrimSpace(query)
|
|
if query == "" {
|
|
return nil, fmt.Errorf("search query is required")
|
|
}
|
|
settings, err := s.loadSearchSettings(ctx, externalUserID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if !searchSettingsConfigured(settings) {
|
|
return nil, ErrWebSearchNotConfigured
|
|
}
|
|
provider, err := websearch.ResolveProvider(settings)
|
|
if err != nil {
|
|
return nil, ErrWebSearchNotConfigured
|
|
}
|
|
return s.websearch.Search(ctx, provider, query, count)
|
|
}
|