mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
Add configurable Sogou-backed web search
This commit is contained in:
@@ -17,6 +17,31 @@ interface ToolActionResponse {
|
||||
status: string
|
||||
}
|
||||
|
||||
export interface WebSearchProviderOption {
|
||||
id: string
|
||||
label: string
|
||||
configured: boolean
|
||||
current: boolean
|
||||
requires_auth: boolean
|
||||
}
|
||||
|
||||
export interface WebSearchProviderConfig {
|
||||
enabled: boolean
|
||||
max_results: number
|
||||
base_url?: string
|
||||
api_key?: string
|
||||
api_key_set?: boolean
|
||||
}
|
||||
|
||||
export interface WebSearchConfigResponse {
|
||||
provider: string
|
||||
current_service: string
|
||||
prefer_native: boolean
|
||||
proxy?: string
|
||||
providers: WebSearchProviderOption[]
|
||||
settings: Record<string, WebSearchProviderConfig>
|
||||
}
|
||||
|
||||
async function request<T>(path: string, options?: RequestInit): Promise<T> {
|
||||
const res = await launcherFetch(path, options)
|
||||
if (!res.ok) {
|
||||
@@ -56,3 +81,17 @@ export async function setToolEnabled(
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
export async function getWebSearchConfig(): Promise<WebSearchConfigResponse> {
|
||||
return request<WebSearchConfigResponse>("/api/tools/web-search-config")
|
||||
}
|
||||
|
||||
export async function updateWebSearchConfig(
|
||||
payload: WebSearchConfigResponse,
|
||||
): Promise<WebSearchConfigResponse> {
|
||||
return request<WebSearchConfigResponse>("/api/tools/web-search-config", {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user