File size: 1,902 Bytes
68f7925
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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();
  },
};