Spaces:
Sleeping
Sleeping
| import type { ThemeExtractionRequest, ThemeExtractionResponse } from '@/schema/theme-extraction'; | |
| /** | |
| * テーマ抽出API | |
| */ | |
| export const themeExtractionApi = { | |
| /** | |
| * テーマを抽出 | |
| */ | |
| async extractTheme(request: ThemeExtractionRequest): Promise<ThemeExtractionResponse> { | |
| const response = await fetch('/api/rpc/theme-extraction', { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| body: JSON.stringify(request), | |
| }); | |
| if (!response.ok) { | |
| const errorData = await response.json().catch(() => ({ error: 'Unknown error' })); | |
| throw new Error(errorData.error || `HTTP error! status: ${response.status}`); | |
| } | |
| const data = await response.json(); | |
| return data; | |
| }, | |
| /** | |
| * 利用可能なプロバイダーを取得 | |
| */ | |
| async getProviders(): Promise<{ success: boolean; data?: { providers: string[]; default: string }; error?: string }> { | |
| const response = await fetch('/api/rpc/theme-extraction/providers', { | |
| method: 'GET', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| }); | |
| if (!response.ok) { | |
| const errorData = await response.json().catch(() => ({ error: 'Unknown error' })); | |
| throw new Error(errorData.error || `HTTP error! status: ${response.status}`); | |
| } | |
| return response.json(); | |
| }, | |
| /** | |
| * ヘルスチェック | |
| */ | |
| async healthCheck(): Promise<{ success: boolean; status: string; data?: any; error?: string }> { | |
| const response = await fetch('/api/rpc/theme-extraction/health', { | |
| method: 'GET', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| }); | |
| if (!response.ok) { | |
| const errorData = await response.json().catch(() => ({ error: 'Unknown error' })); | |
| throw new Error(errorData.error || `HTTP error! status: ${response.status}`); | |
| } | |
| return response.json(); | |
| }, | |
| }; | |