export type GetApiApiFurusatoSemanticSearchArgs = {q: string, prefecture?: string | undefined, category?: string | undefined, muni_code?: string | undefined, limit?: number | undefined}; export type GetApiApiFurusatoSemanticSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Semantic search (Workers AI bge-m3 → Vectorize)。 binding 未活性化時は FTS5 fallback * * GET /api/furusato/semantic_search */ export const getApiApiFurusatoSemanticSearch = async (args: GetApiApiFurusatoSemanticSearchArgs, options?: GetApiApiFurusatoSemanticSearchOptions) => { const {baseUrl = "https://localgov.jp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.q != null) query.append("q", String(args.q)) if (args.prefecture != null) query.append("prefecture", String(args.prefecture)) if (args.category != null) query.append("category", String(args.category)) if (args.muni_code != null) query.append("muni_code", String(args.muni_code)) if (args.limit != null) query.append("limit", String(args.limit)) const url = `${baseUrl.replace(/\/+$/, '')}/api/furusato/semantic_search${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };