1110615300
支持对接自建/公共 SearXNG 实例作为网络搜索引擎,缓解免费搜索引擎在国内 网络环境下访问受限的问题。 - types: 新增 WebSearchProviderTypeSearxng 与 BaseURL 参数字段; 类型元数据新增 RequiresBaseURL,前端可动态渲染 Instance URL 表单。 - infrastructure/web_search/searxng.go: 调用 /search?format=json,强制 utils.ValidateURLForSSRF 校验 base_url,可选 api_key 透传给反代鉴权。 - service: isValidProviderType 与参数校验接入 searxng。 - container: 注册 NewSearxngProvider 工厂。 - frontend: WebSearchSettings 表单根据 requires_base_url 渲染 Instance URL 输入框;编辑回填、free 判定同步更新。 - docker: 新增可选 searxng 服务(profile=searxng/full),附带最小化 settings.yml(启用 JSON 格式、关闭 limiter、关闭遥测), docker-compose 默认 SSRF_WHITELIST 包含 searxng 容器名。 - .env.example: 补充 SEARXNG_PORT / SEARXNG_SECRET 说明。 Closes #1166
78 lines
2.3 KiB
TypeScript
78 lines
2.3 KiB
TypeScript
import { get, post, put, del } from '@/utils/request'
|
|
|
|
// WebSearchProviderEntity represents a configured web search provider instance
|
|
export interface WebSearchProviderEntity {
|
|
id?: string
|
|
tenant_id?: number
|
|
name: string
|
|
provider: 'bing' | 'google' | 'duckduckgo' | 'tavily' | 'ollama' | 'baidu' | 'searxng'
|
|
description?: string
|
|
parameters: {
|
|
api_key?: string
|
|
engine_id?: string
|
|
base_url?: string
|
|
proxy_url?: string
|
|
extra_config?: Record<string, string>
|
|
}
|
|
is_default?: boolean
|
|
created_at?: string
|
|
updated_at?: string
|
|
}
|
|
|
|
// WebSearchProviderTypeInfo describes metadata for a provider type
|
|
export interface WebSearchProviderTypeInfo {
|
|
id: string
|
|
name: string
|
|
requires_api_key: boolean
|
|
requires_engine_id?: boolean
|
|
requires_base_url?: boolean
|
|
supports_proxy?: boolean
|
|
description?: string
|
|
docs_url?: string
|
|
}
|
|
|
|
// Create a new web search provider
|
|
export function createWebSearchProvider(data: Partial<WebSearchProviderEntity>) {
|
|
return post('/api/v1/web-search-providers', data)
|
|
}
|
|
|
|
// List all web search providers for the current tenant
|
|
export function listWebSearchProviders() {
|
|
return get('/api/v1/web-search-providers')
|
|
}
|
|
|
|
// Get a single web search provider by ID
|
|
export function getWebSearchProvider(id: string) {
|
|
return get(`/api/v1/web-search-providers/${id}`)
|
|
}
|
|
|
|
// Update an existing web search provider
|
|
export function updateWebSearchProvider(id: string, data: Partial<WebSearchProviderEntity>) {
|
|
return put(`/api/v1/web-search-providers/${id}`, data)
|
|
}
|
|
|
|
// Delete a web search provider
|
|
export function deleteWebSearchProvider(id: string) {
|
|
return del(`/api/v1/web-search-providers/${id}`)
|
|
}
|
|
|
|
// Get available provider types (for dynamic form rendering)
|
|
export function listWebSearchProviderTypes(): Promise<WebSearchProviderTypeInfo[]> {
|
|
return get('/api/v1/web-search-providers/types').then((res: any) => {
|
|
if (res.success && res.data) {
|
|
return res.data
|
|
}
|
|
return []
|
|
})
|
|
}
|
|
|
|
// Test a web search provider connection.
|
|
// If id is provided, tests the existing saved provider.
|
|
// If data is provided, tests with raw credentials (no persistence).
|
|
export function testWebSearchProvider(id?: string, data?: { provider: string; parameters: any }): Promise<any> {
|
|
if (id) {
|
|
return post(`/api/v1/web-search-providers/${id}/test`, {})
|
|
}
|
|
return post('/api/v1/web-search-providers/test', data || {})
|
|
}
|