File size: 775 Bytes
11ab88a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
export async function requestJson(path, options = {}) {
  const response = await fetch(path, options);
  const contentType = response.headers.get("content-type") || "";
  const data = contentType.includes("application/json") ? await response.json() : null;

  if (!response.ok) {
    const message = data?.detail?.message || data?.detail || "์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.";
    throw new Error(message);
  }

  return data;
}

export function getConfidenceState(confidence) {
  if (confidence >= 0.9) {
    return { label: "์•ˆ์ •", className: "confidence-stable" };
  }
  if (confidence >= 0.7) {
    return { label: "ํ™•์ธ ํ•„์š”", className: "confidence-review" };
  }
  return { label: "๋‹ค์‹œ ๋ณด๊ธฐ", className: "confidence-retry" };
}