|
|
<!DOCTYPE html> |
|
|
<html lang="ko"> |
|
|
<head> |
|
|
<script type="text/javascript"> |
|
|
(function(c,l,a,r,i,t,y){ |
|
|
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; |
|
|
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; |
|
|
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); |
|
|
})(window, document, "clarity", "script", "ujskfvh0bu"); |
|
|
</script> |
|
|
<meta charset="UTF-8"> |
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
|
<title>AI ์ค์ ๊ด๋ฆฌ - SOY NV AI</title> |
|
|
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin> |
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet"> |
|
|
<style> |
|
|
* { |
|
|
margin: 0; |
|
|
padding: 0; |
|
|
box-sizing: border-box; |
|
|
} |
|
|
|
|
|
body { |
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; |
|
|
background: #f8f9fa; |
|
|
color: #202124; |
|
|
} |
|
|
|
|
|
.header { |
|
|
background: white; |
|
|
border-bottom: 1px solid #dadce0; |
|
|
padding: 16px 24px; |
|
|
display: flex; |
|
|
align-items: center; |
|
|
justify-content: space-between; |
|
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); |
|
|
} |
|
|
|
|
|
.header-title { |
|
|
font-size: 20px; |
|
|
font-weight: 500; |
|
|
display: flex; |
|
|
align-items: center; |
|
|
gap: 12px; |
|
|
} |
|
|
|
|
|
.header-actions { |
|
|
display: flex; |
|
|
gap: 8px; |
|
|
align-items: center; |
|
|
flex-wrap: wrap; |
|
|
} |
|
|
|
|
|
|
|
|
.dropdown { |
|
|
position: relative; |
|
|
display: inline-block; |
|
|
} |
|
|
|
|
|
|
|
|
.dropdown::after { |
|
|
content: ''; |
|
|
position: absolute; |
|
|
left: 0; |
|
|
right: 0; |
|
|
top: 100%; |
|
|
height: 8px; |
|
|
} |
|
|
|
|
|
.dropdown-toggle { |
|
|
padding: 8px 16px; |
|
|
background: #f1f3f4; |
|
|
color: #202124; |
|
|
border: none; |
|
|
border-radius: 6px; |
|
|
font-size: 14px; |
|
|
font-weight: 500; |
|
|
cursor: pointer; |
|
|
transition: all 0.2s; |
|
|
display: flex; |
|
|
align-items: center; |
|
|
gap: 6px; |
|
|
} |
|
|
|
|
|
.dropdown-toggle:hover { |
|
|
background: #e8eaed; |
|
|
} |
|
|
|
|
|
.dropdown-toggle::after { |
|
|
content: 'โผ'; |
|
|
font-size: 10px; |
|
|
transition: transform 0.2s; |
|
|
} |
|
|
|
|
|
.dropdown:hover .dropdown-toggle::after { |
|
|
transform: rotate(180deg); |
|
|
} |
|
|
|
|
|
.dropdown-menu { |
|
|
position: absolute; |
|
|
top: calc(100% + 4px); |
|
|
left: 0; |
|
|
margin-top: 0; |
|
|
background: white; |
|
|
border: 1px solid #dadce0; |
|
|
border-radius: 6px; |
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); |
|
|
min-width: 200px; |
|
|
opacity: 0; |
|
|
visibility: hidden; |
|
|
transform: translateY(-8px); |
|
|
transition: all 0.2s ease; |
|
|
z-index: 10000; |
|
|
padding: 4px 0; |
|
|
pointer-events: none; |
|
|
} |
|
|
|
|
|
.dropdown:hover .dropdown-menu { |
|
|
opacity: 1; |
|
|
visibility: visible; |
|
|
transform: translateY(0); |
|
|
pointer-events: auto; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.dropdown-item { |
|
|
display: block; |
|
|
padding: 10px 16px; |
|
|
color: #202124; |
|
|
text-decoration: none; |
|
|
font-size: 14px; |
|
|
transition: background 0.2s; |
|
|
} |
|
|
|
|
|
.dropdown-item:hover { |
|
|
background: #f8f9fa; |
|
|
} |
|
|
|
|
|
.dropdown-item:first-child { |
|
|
border-top-left-radius: 6px; |
|
|
border-top-right-radius: 6px; |
|
|
} |
|
|
|
|
|
.dropdown-item:last-child { |
|
|
border-bottom-left-radius: 6px; |
|
|
border-bottom-right-radius: 6px; |
|
|
} |
|
|
|
|
|
.menu-toggle { |
|
|
display: none; |
|
|
background: none; |
|
|
border: none; |
|
|
font-size: 24px; |
|
|
cursor: pointer; |
|
|
padding: 8px; |
|
|
color: #202124; |
|
|
} |
|
|
|
|
|
.mobile-menu { |
|
|
display: none; |
|
|
position: fixed; |
|
|
top: 0; |
|
|
left: 0; |
|
|
right: 0; |
|
|
bottom: 0; |
|
|
background: rgba(0, 0, 0, 0.5); |
|
|
z-index: 1000; |
|
|
} |
|
|
|
|
|
.mobile-menu.active { |
|
|
display: block; |
|
|
} |
|
|
|
|
|
.mobile-menu-content { |
|
|
position: fixed; |
|
|
top: 0; |
|
|
right: -100%; |
|
|
width: 280px; |
|
|
max-width: 80%; |
|
|
height: 100%; |
|
|
background: white; |
|
|
box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1); |
|
|
transition: right 0.3s ease; |
|
|
overflow-y: auto; |
|
|
z-index: 1001; |
|
|
} |
|
|
|
|
|
.mobile-menu.active .mobile-menu-content { |
|
|
right: 0; |
|
|
} |
|
|
|
|
|
.mobile-menu-header { |
|
|
padding: 16px 20px; |
|
|
border-bottom: 1px solid #dadce0; |
|
|
display: flex; |
|
|
justify-content: space-between; |
|
|
align-items: center; |
|
|
background: white; |
|
|
position: sticky; |
|
|
top: 0; |
|
|
z-index: 10; |
|
|
} |
|
|
|
|
|
.mobile-menu-title { |
|
|
font-size: 18px; |
|
|
font-weight: 500; |
|
|
} |
|
|
|
|
|
.mobile-menu-close { |
|
|
background: none; |
|
|
border: none; |
|
|
font-size: 24px; |
|
|
cursor: pointer; |
|
|
color: #202124; |
|
|
padding: 0; |
|
|
width: 32px; |
|
|
height: 32px; |
|
|
display: flex; |
|
|
align-items: center; |
|
|
justify-content: center; |
|
|
} |
|
|
|
|
|
.mobile-menu-items { |
|
|
padding: 8px 0; |
|
|
} |
|
|
|
|
|
.mobile-menu-item { |
|
|
display: block; |
|
|
padding: 12px 20px; |
|
|
color: #202124; |
|
|
text-decoration: none; |
|
|
border-bottom: 1px solid #f1f3f4; |
|
|
transition: background 0.2s; |
|
|
} |
|
|
|
|
|
.mobile-menu-item:hover { |
|
|
background: #f8f9fa; |
|
|
} |
|
|
|
|
|
.mobile-menu-user { |
|
|
padding: 16px 20px; |
|
|
border-bottom: 1px solid #dadce0; |
|
|
color: #5f6368; |
|
|
font-size: 14px; |
|
|
} |
|
|
|
|
|
@media (max-width: 768px) { |
|
|
.header { |
|
|
padding: 12px 16px; |
|
|
} |
|
|
|
|
|
.header-title { |
|
|
font-size: 18px; |
|
|
} |
|
|
|
|
|
.header-title span:first-child { |
|
|
display: none; |
|
|
} |
|
|
|
|
|
.menu-toggle { |
|
|
display: block; |
|
|
} |
|
|
|
|
|
.header-actions { |
|
|
display: none; |
|
|
} |
|
|
} |
|
|
|
|
|
.btn { |
|
|
padding: 8px 16px; |
|
|
border: none; |
|
|
border-radius: 6px; |
|
|
font-size: 14px; |
|
|
font-weight: 500; |
|
|
cursor: pointer; |
|
|
transition: all 0.2s; |
|
|
text-decoration: none; |
|
|
display: inline-block; |
|
|
} |
|
|
|
|
|
.btn-primary { |
|
|
background: #1a73e8; |
|
|
color: white; |
|
|
} |
|
|
|
|
|
.btn-primary:hover { |
|
|
background: #1557b0; |
|
|
} |
|
|
|
|
|
.btn-secondary { |
|
|
background: #f1f3f4; |
|
|
color: #202124; |
|
|
} |
|
|
|
|
|
.btn-secondary:hover { |
|
|
background: #e8eaed; |
|
|
} |
|
|
|
|
|
.container { |
|
|
max-width: 1200px; |
|
|
margin: 0 auto; |
|
|
padding: 24px; |
|
|
} |
|
|
|
|
|
.page-header { |
|
|
margin-bottom: 24px; |
|
|
} |
|
|
|
|
|
.page-header h1 { |
|
|
font-size: 28px; |
|
|
font-weight: 600; |
|
|
margin-bottom: 8px; |
|
|
} |
|
|
|
|
|
.page-header p { |
|
|
color: #5f6368; |
|
|
} |
|
|
|
|
|
.card { |
|
|
background: white; |
|
|
border-radius: 8px; |
|
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); |
|
|
padding: 24px; |
|
|
margin-bottom: 24px; |
|
|
} |
|
|
|
|
|
.card-header { |
|
|
display: flex; |
|
|
justify-content: space-between; |
|
|
align-items: center; |
|
|
margin-bottom: 20px; |
|
|
} |
|
|
|
|
|
.card-title { |
|
|
font-size: 18px; |
|
|
font-weight: 500; |
|
|
} |
|
|
|
|
|
.form-group { |
|
|
margin-bottom: 16px; |
|
|
} |
|
|
|
|
|
.form-group label { |
|
|
display: block; |
|
|
font-size: 14px; |
|
|
font-weight: 500; |
|
|
margin-bottom: 8px; |
|
|
} |
|
|
|
|
|
.form-group input { |
|
|
width: 100%; |
|
|
padding: 10px 12px; |
|
|
border: 1px solid #dadce0; |
|
|
border-radius: 6px; |
|
|
font-size: 14px; |
|
|
font-family: inherit; |
|
|
} |
|
|
|
|
|
.form-group input:focus { |
|
|
outline: none; |
|
|
border-color: #1a73e8; |
|
|
box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1); |
|
|
} |
|
|
|
|
|
.alert { |
|
|
padding: 12px 16px; |
|
|
border-radius: 6px; |
|
|
margin-bottom: 16px; |
|
|
font-size: 14px; |
|
|
} |
|
|
|
|
|
.alert.error { |
|
|
background: #fce8e6; |
|
|
color: #c5221f; |
|
|
} |
|
|
|
|
|
.alert.success { |
|
|
background: #e8f5e9; |
|
|
color: #137333; |
|
|
} |
|
|
</style> |
|
|
</head> |
|
|
<body> |
|
|
<div class="header"> |
|
|
<div class="header-title"> |
|
|
<span>โ๏ธ</span> |
|
|
<span>AI ์ค์ ๊ด๋ฆฌ</span> |
|
|
</div> |
|
|
<button class="menu-toggle" onclick="toggleMobileMenu()" aria-label="๋ฉ๋ด ์ด๊ธฐ">โฐ</button> |
|
|
<div class="header-actions"> |
|
|
<span style="margin-right: 12px; color: #5f6368;">{{ current_user.nickname or current_user.username }}</span> |
|
|
|
|
|
{# ์ฌ์ดํธ ๊ด๋ฆฌ #} |
|
|
<div class="dropdown"> |
|
|
<button type="button" class="dropdown-toggle">์ฌ์ดํธ ๊ด๋ฆฌ</button> |
|
|
<div class="dropdown-menu"> |
|
|
<a href="{{ url_for('main.admin') }}" class="dropdown-item">์ฌ์ฉ์ ๊ด๋ฆฌ</a> |
|
|
<a href="{{ url_for('main.admin_tokens') }}" class="dropdown-item">ํ ํฐ ํต๊ณ</a> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
{# ์น์์ค ๊ด๋ฆฌ #} |
|
|
<div class="dropdown"> |
|
|
<button type="button" class="dropdown-toggle">์น์์ค ๊ด๋ฆฌ</button> |
|
|
<div class="dropdown-menu"> |
|
|
<a href="{{ url_for('main.admin_webnovels') }}" class="dropdown-item">์น์์ค ์
๋ก๋ ๋ฐ ๊ด๋ฆฌ</a> |
|
|
<a href="{{ url_for('main.admin_messages') }}" class="dropdown-item">๋ฉ์์ง ํ์ธ</a> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
{# AI ์ค์ #} |
|
|
<div class="dropdown"> |
|
|
<button type="button" class="dropdown-toggle">AI ์ค์ </button> |
|
|
<div class="dropdown-menu"> |
|
|
<a href="{{ url_for('main.admin_settings') }}" class="dropdown-item">AI ์ค์ </a> |
|
|
<a href="{{ url_for('main.admin_prompts') }}" class="dropdown-item">ํ๋กฌํํธ ๊ด๋ฆฌ</a> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
{# ์ฑ๋ด #} |
|
|
<div class="dropdown"> |
|
|
<button type="button" class="dropdown-toggle">์ฑ๋ด</button> |
|
|
<div class="dropdown-menu"> |
|
|
<a href="{{ url_for('main.admin_tags') }}" class="dropdown-item">ํ๊ทธ/ํ๋กฌํํธ</a> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
{# ํธ์๊ธฐ๋ฅ #} |
|
|
<div class="dropdown"> |
|
|
<button type="button" class="dropdown-toggle">ํธ์๊ธฐ๋ฅ</button> |
|
|
<div class="dropdown-menu"> |
|
|
<a href="{{ url_for('main.admin_utils') }}" class="dropdown-item">์ ํธ</a> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
{# ๋ฉ์ธ์ผ๋ก #} |
|
|
<a href="{{ url_for('main.index') }}" class="btn btn-secondary" style="padding: 8px 16px; font-size: 14px; margin-right: 4px;">๋ฉ์ธ์ผ๋ก</a> |
|
|
<a href="{{ url_for('main.logout') }}" class="btn btn-secondary" style="padding: 8px 16px; font-size: 14px;">๋ก๊ทธ์์</a> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="mobile-menu" id="mobileMenu" onclick="closeMobileMenuOnBackdrop(event)"> |
|
|
<div class="mobile-menu-content" onclick="event.stopPropagation()"> |
|
|
<div class="mobile-menu-header"> |
|
|
<div class="mobile-menu-title">๋ฉ๋ด</div> |
|
|
<button class="mobile-menu-close" onclick="toggleMobileMenu()" aria-label="๋ฉ๋ด ๋ซ๊ธฐ">×</button> |
|
|
</div> |
|
|
<div class="mobile-menu-user">{{ current_user.nickname or current_user.username }}</div> |
|
|
<div class="mobile-menu-items"> |
|
|
<div style="padding: 8px 20px; font-size: 11px; font-weight: 600; color: #5f6368; text-transform: uppercase; border-bottom: 1px solid #f1f3f4;">์ฌ์ดํธ ๊ด๋ฆฌ</div> |
|
|
<a href="{{ url_for('main.admin') }}" class="mobile-menu-item" onclick="closeMobileMenu()">์ฌ์ฉ์ ๊ด๋ฆฌ</a> |
|
|
<a href="{{ url_for('main.admin_tokens') }}" class="mobile-menu-item" onclick="closeMobileMenu()">ํ ํฐ ํต๊ณ</a> |
|
|
|
|
|
<div style="padding: 8px 20px; font-size: 11px; font-weight: 600; color: #5f6368; text-transform: uppercase; border-bottom: 1px solid #f1f3f4; margin-top: 8px;">์น์์ค ๊ด๋ฆฌ</div> |
|
|
<a href="{{ url_for('main.admin_webnovels') }}" class="mobile-menu-item" onclick="closeMobileMenu()">์น์์ค ์
๋ก๋ ๋ฐ ๊ด๋ฆฌ</a> |
|
|
<a href="{{ url_for('main.admin_messages') }}" class="mobile-menu-item" onclick="closeMobileMenu()">๋ฉ์์ง ํ์ธ</a> |
|
|
|
|
|
<div style="padding: 8px 20px; font-size: 11px; font-weight: 600; color: #5f6368; text-transform: uppercase; border-bottom: 1px solid #f1f3f4; margin-top: 8px;">AI ์ค์ </div> |
|
|
<a href="{{ url_for('main.admin_settings') }}" class="mobile-menu-item" onclick="closeMobileMenu()">AI ์ค์ </a> |
|
|
<a href="{{ url_for('main.admin_prompts') }}" class="mobile-menu-item" onclick="closeMobileMenu()">ํ๋กฌํํธ ๊ด๋ฆฌ</a> |
|
|
|
|
|
<div style="padding: 8px 20px; font-size: 11px; font-weight: 600; color: #5f6368; text-transform: uppercase; border-bottom: 1px solid #f1f3f4; margin-top: 8px;">์ฑ๋ด</div> |
|
|
<a href="{{ url_for('main.admin_tags') }}" class="mobile-menu-item" onclick="closeMobileMenu()">ํ๊ทธ/ํ๋กฌํํธ</a> |
|
|
|
|
|
<div style="padding: 8px 20px; font-size: 11px; font-weight: 600; color: #5f6368; text-transform: uppercase; border-bottom: 1px solid #f1f3f4; margin-top: 8px;">ํธ์๊ธฐ๋ฅ</div> |
|
|
<a href="{{ url_for('main.admin_utils') }}" class="mobile-menu-item" onclick="closeMobileMenu()">์ ํธ</a> |
|
|
|
|
|
<div style="padding: 8px 20px; font-size: 11px; font-weight: 600; color: #5f6368; text-transform: uppercase; border-bottom: 1px solid #f1f3f4; margin-top: 8px;">๊ธฐํ</div> |
|
|
<a href="{{ url_for('main.index') }}" class="mobile-menu-item" onclick="closeMobileMenu()">๋ฉ์ธ์ผ๋ก</a> |
|
|
<a href="{{ url_for('main.logout') }}" class="mobile-menu-item" onclick="closeMobileMenu()">๋ก๊ทธ์์</a> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div class="container"> |
|
|
<div class="page-header"> |
|
|
<h1>AI ์ค์ ๊ด๋ฆฌ</h1> |
|
|
<p>Gemini API ํค์ AI ๋ชจ๋ธ๋ณ ํ ํฐ ์๋ฅผ ๊ด๋ฆฌํ ์ ์์ต๋๋ค.</p> |
|
|
</div> |
|
|
|
|
|
<div id="alertContainer"></div> |
|
|
|
|
|
|
|
|
<div class="card"> |
|
|
<div class="card-header"> |
|
|
<div class="card-title">Gemini API ํค ์ค์ </div> |
|
|
</div> |
|
|
<div style="padding: 16px 0;"> |
|
|
<div class="form-group"> |
|
|
<label for="geminiApiKey">Gemini API ํค</label> |
|
|
<div style="display: flex; gap: 8px;"> |
|
|
<input type="password" id="geminiApiKey" placeholder="Gemini API ํค๋ฅผ ์
๋ ฅํ์ธ์" style="flex: 1; padding: 8px 12px; border: 1px solid #dadce0; border-radius: 4px; font-size: 14px;"> |
|
|
<button class="btn btn-primary" onclick="saveGeminiApiKey()">์ ์ฅ</button> |
|
|
<button class="btn btn-secondary" onclick="loadGeminiApiKey()">ํ์ฌ ์ํ ํ์ธ</button> |
|
|
</div> |
|
|
<small style="color: #5f6368; font-size: 12px; display: block; margin-top: 4px;"> |
|
|
Google AI Studio(<a href="https://aistudio.google.com/app/apikey" target="_blank">https://aistudio.google.com/app/apikey</a>)์์ API ํค๋ฅผ ๋ฐ๊ธ๋ฐ์ ์ ์์ต๋๋ค. |
|
|
</small> |
|
|
<div id="geminiApiKeyStatus" style="margin-top: 8px; font-size: 13px;"></div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="card"> |
|
|
<div class="card-header"> |
|
|
<div class="card-title">Hugging Face ํ ํฐ ์ค์ </div> |
|
|
</div> |
|
|
<div style="padding: 16px 0;"> |
|
|
<div class="form-group"> |
|
|
<label for="huggingfaceToken">Hugging Face ํ ํฐ</label> |
|
|
<div style="display: flex; gap: 8px;"> |
|
|
<input type="password" id="huggingfaceToken" placeholder="Hugging Face ํ ํฐ์ ์
๋ ฅํ์ธ์" style="flex: 1; padding: 8px 12px; border: 1px solid #dadce0; border-radius: 4px; font-size: 14px;"> |
|
|
<button class="btn btn-primary" onclick="saveHuggingFaceToken()">์ ์ฅ</button> |
|
|
<button class="btn btn-secondary" onclick="loadHuggingFaceToken()">ํ์ฌ ์ํ ํ์ธ</button> |
|
|
</div> |
|
|
<small style="color: #5f6368; font-size: 12px; display: block; margin-top: 4px;"> |
|
|
Hugging Face(<a href="https://huggingface.co/settings/tokens" target="_blank">https://huggingface.co/settings/tokens</a>)์์ ํ ํฐ์ ๋ฐ๊ธ๋ฐ์ ์ ์์ต๋๋ค. |
|
|
</small> |
|
|
<div id="huggingfaceTokenStatus" style="margin-top: 8px; font-size: 13px;"></div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="card"> |
|
|
<div class="card-header"> |
|
|
<div class="card-title">๊ธฐ๋ณธ AI ๋ชจ๋ธ ์ค์ </div> |
|
|
<button class="btn btn-secondary" onclick="loadDefaultModels()">์๋ก๊ณ ์นจ</button> |
|
|
</div> |
|
|
<div style="padding: 16px 0;"> |
|
|
<div id="defaultModelsStatus" style="margin-bottom: 16px; font-size: 13px;"></div> |
|
|
<div style="display: grid; gap: 16px;"> |
|
|
<div class="form-group"> |
|
|
<label for="defaultAnalysisModel">๊ธฐ๋ณธ ์ง๋ฌธ ๋ถ์์ฉ AI ๋ชจ๋ธ (AI ๋ชจ๋ธ ์ ํ)</label> |
|
|
<div style="display: flex; gap: 8px;"> |
|
|
<select id="defaultAnalysisModel" style="flex: 1; padding: 8px 12px; border: 1px solid #dadce0; border-radius: 4px; font-size: 14px;"> |
|
|
<option value="">๊ธฐ๋ณธ๊ฐ ์์</option> |
|
|
</select> |
|
|
<button class="btn btn-primary" onclick="saveDefaultModels()">์ ์ฅ</button> |
|
|
</div> |
|
|
<small style="color: #5f6368; font-size: 12px; display: block; margin-top: 4px;"> |
|
|
์ฌ์ฉ์ ํ๋ฉด์ "AI ๋ชจ๋ธ ์ ํ" ๋๋กญ๋ค์ด์์ ๊ธฐ๋ณธ์ผ๋ก ์ ํ๋ ๋ชจ๋ธ์
๋๋ค. |
|
|
</small> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<label for="defaultAnswerModel">๊ธฐ๋ณธ ๋ต๋ณ ์์ฑ์ฉ AI ๋ชจ๋ธ (์ฌ์ฉ ๊ฐ๋ฅํ AI ๋ชฉ๋ก)</label> |
|
|
<div style="display: flex; gap: 8px;"> |
|
|
<select id="defaultAnswerModel" style="flex: 1; padding: 8px 12px; border: 1px solid #dadce0; border-radius: 4px; font-size: 14px;"> |
|
|
<option value="">๊ธฐ๋ณธ๊ฐ ์์</option> |
|
|
</select> |
|
|
<button class="btn btn-primary" onclick="saveDefaultModels()">์ ์ฅ</button> |
|
|
</div> |
|
|
<small style="color: #5f6368; font-size: 12px; display: block; margin-top: 4px;"> |
|
|
์ฌ์ฉ์ ํ๋ฉด์ "์ฌ์ฉ ๊ฐ๋ฅํ AI ๋ชฉ๋ก" ๋๋กญ๋ค์ด์์ ๊ธฐ๋ณธ์ผ๋ก ์ ํ๋ ๋ชจ๋ธ์
๋๋ค. |
|
|
</small> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="card"> |
|
|
<div class="card-header"> |
|
|
<div class="card-title">AI ๋ชจ๋ธ๋ณ ํ ํฐ ์ ๊ด๋ฆฌ</div> |
|
|
<button class="btn btn-secondary" onclick="loadModelTokens()">์๋ก๊ณ ์นจ</button> |
|
|
</div> |
|
|
<div style="padding: 16px 0;"> |
|
|
<div id="modelTokensStatus" style="margin-bottom: 16px; font-size: 13px;"></div> |
|
|
<div id="modelTokensList" style="display: grid; gap: 12px;"> |
|
|
<div style="text-align: center; padding: 20px; color: #5f6368;">๋ก๋ฉ ์ค...</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<script> |
|
|
function toggleMobileMenu() { |
|
|
const menu = document.getElementById('mobileMenu'); |
|
|
menu.classList.toggle('active'); |
|
|
document.body.style.overflow = menu.classList.contains('active') ? 'hidden' : ''; |
|
|
} |
|
|
|
|
|
function closeMobileMenu() { |
|
|
const menu = document.getElementById('mobileMenu'); |
|
|
menu.classList.remove('active'); |
|
|
document.body.style.overflow = ''; |
|
|
} |
|
|
|
|
|
function closeMobileMenuOnBackdrop(event) { |
|
|
if (event.target.id === 'mobileMenu') { |
|
|
closeMobileMenu(); |
|
|
} |
|
|
} |
|
|
|
|
|
function showAlert(message, type = 'success') { |
|
|
const container = document.getElementById('alertContainer'); |
|
|
container.innerHTML = `<div class="alert ${type}">${message}</div>`; |
|
|
setTimeout(() => { |
|
|
container.innerHTML = ''; |
|
|
}, 5000); |
|
|
} |
|
|
|
|
|
|
|
|
async function loadGeminiApiKey() { |
|
|
try { |
|
|
const response = await fetch('/api/admin/gemini-api-key', { |
|
|
credentials: 'include' |
|
|
}); |
|
|
|
|
|
|
|
|
const contentType = response.headers.get('content-type'); |
|
|
if (!contentType || !contentType.includes('application/json')) { |
|
|
const text = await response.text(); |
|
|
console.error('Non-JSON response:', text.substring(0, 200)); |
|
|
const statusDiv = document.getElementById('geminiApiKeyStatus'); |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">์๋ฒ ์ค๋ฅ: ์๋ต ํ์์ด ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค.</span>`; |
|
|
return; |
|
|
} |
|
|
|
|
|
const data = await response.json(); |
|
|
|
|
|
const statusDiv = document.getElementById('geminiApiKeyStatus'); |
|
|
if (!response.ok) { |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">์ค๋ฅ: ${data.error || '์ ์ ์๋ ์ค๋ฅ'}</span>`; |
|
|
return; |
|
|
} |
|
|
|
|
|
if (data.has_api_key) { |
|
|
statusDiv.innerHTML = `<span style="color: #137333;">โ API ํค๊ฐ ์ค์ ๋์ด ์์ต๋๋ค (${data.masked_key})</span>`; |
|
|
} else { |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">โ API ํค๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค</span>`; |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('Gemini API ํค ๋ก๋ ์ค๋ฅ:', error); |
|
|
const statusDiv = document.getElementById('geminiApiKeyStatus'); |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">์ค๋ฅ: ${error.message}</span>`; |
|
|
} |
|
|
} |
|
|
|
|
|
async function saveGeminiApiKey() { |
|
|
const apiKeyInput = document.getElementById('geminiApiKey'); |
|
|
const apiKey = apiKeyInput.value.trim(); |
|
|
|
|
|
if (!apiKey) { |
|
|
showAlert('API ํค๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.', 'error'); |
|
|
return; |
|
|
} |
|
|
|
|
|
try { |
|
|
const response = await fetch('/api/admin/gemini-api-key', { |
|
|
method: 'POST', |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
}, |
|
|
credentials: 'include', |
|
|
body: JSON.stringify({ api_key: apiKey }) |
|
|
}); |
|
|
|
|
|
|
|
|
const contentType = response.headers.get('content-type'); |
|
|
if (!contentType || !contentType.includes('application/json')) { |
|
|
const text = await response.text(); |
|
|
console.error('Non-JSON response:', text.substring(0, 200)); |
|
|
showAlert('์๋ฒ ์ค๋ฅ: ์๋ต ํ์์ด ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค.', 'error'); |
|
|
return; |
|
|
} |
|
|
|
|
|
const data = await response.json(); |
|
|
|
|
|
if (response.ok) { |
|
|
showAlert(data.message, 'success'); |
|
|
apiKeyInput.value = ''; |
|
|
loadGeminiApiKey(); |
|
|
} else { |
|
|
showAlert(data.error || 'API ํค ์ ์ฅ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.', 'error'); |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('Gemini API ํค ์ ์ฅ ์ค๋ฅ:', error); |
|
|
showAlert(`์ค๋ฅ: ${error.message}`, 'error'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function loadHuggingFaceToken() { |
|
|
try { |
|
|
const response = await fetch('/api/admin/huggingface-token', { |
|
|
credentials: 'include' |
|
|
}); |
|
|
|
|
|
|
|
|
const contentType = response.headers.get('content-type'); |
|
|
if (!contentType || !contentType.includes('application/json')) { |
|
|
const text = await response.text(); |
|
|
console.error('Non-JSON response:', text.substring(0, 200)); |
|
|
const statusDiv = document.getElementById('huggingfaceTokenStatus'); |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">์๋ฒ ์ค๋ฅ: ์๋ต ํ์์ด ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค.</span>`; |
|
|
return; |
|
|
} |
|
|
|
|
|
const data = await response.json(); |
|
|
|
|
|
const statusDiv = document.getElementById('huggingfaceTokenStatus'); |
|
|
if (!response.ok) { |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">์ค๋ฅ: ${data.error || '์ ์ ์๋ ์ค๋ฅ'}</span>`; |
|
|
return; |
|
|
} |
|
|
|
|
|
if (data.has_token) { |
|
|
statusDiv.innerHTML = `<span style="color: #137333;">โ ํ ํฐ์ด ์ค์ ๋์ด ์์ต๋๋ค (${data.masked_token})</span>`; |
|
|
} else { |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">โ ํ ํฐ์ด ์ค์ ๋์ง ์์์ต๋๋ค</span>`; |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('Hugging Face ํ ํฐ ๋ก๋ ์ค๋ฅ:', error); |
|
|
const statusDiv = document.getElementById('huggingfaceTokenStatus'); |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">์ค๋ฅ: ${error.message}</span>`; |
|
|
} |
|
|
} |
|
|
|
|
|
async function saveHuggingFaceToken() { |
|
|
const tokenInput = document.getElementById('huggingfaceToken'); |
|
|
const token = tokenInput.value.trim(); |
|
|
|
|
|
if (!token) { |
|
|
showAlert('ํ ํฐ์ ์
๋ ฅํด์ฃผ์ธ์.', 'error'); |
|
|
return; |
|
|
} |
|
|
|
|
|
try { |
|
|
const response = await fetch('/api/admin/huggingface-token', { |
|
|
method: 'POST', |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
}, |
|
|
credentials: 'include', |
|
|
body: JSON.stringify({ token: token }) |
|
|
}); |
|
|
|
|
|
|
|
|
const contentType = response.headers.get('content-type'); |
|
|
if (!contentType || !contentType.includes('application/json')) { |
|
|
const text = await response.text(); |
|
|
console.error('Non-JSON response:', text.substring(0, 200)); |
|
|
showAlert('์๋ฒ ์ค๋ฅ: ์๋ต ํ์์ด ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค.', 'error'); |
|
|
return; |
|
|
} |
|
|
|
|
|
const data = await response.json(); |
|
|
|
|
|
if (response.ok) { |
|
|
showAlert(data.message, 'success'); |
|
|
tokenInput.value = ''; |
|
|
loadHuggingFaceToken(); |
|
|
} else { |
|
|
showAlert(data.error || 'ํ ํฐ ์ ์ฅ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.', 'error'); |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('Hugging Face ํ ํฐ ์ ์ฅ ์ค๋ฅ:', error); |
|
|
showAlert(`์ค๋ฅ: ${error.message}`, 'error'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function loadModelTokens() { |
|
|
const statusDiv = document.getElementById('modelTokensStatus'); |
|
|
const listDiv = document.getElementById('modelTokensList'); |
|
|
|
|
|
try { |
|
|
statusDiv.innerHTML = '<span style="color: #1a73e8;">ํ ํฐ ์ ์ค์ ์ ๋ถ๋ฌ์ค๋ ์ค...</span>'; |
|
|
listDiv.innerHTML = '<div style="text-align: center; padding: 20px; color: #5f6368;">๋ก๋ฉ ์ค...</div>'; |
|
|
|
|
|
const response = await fetch('/api/admin/model-tokens', { |
|
|
credentials: 'include' |
|
|
}); |
|
|
|
|
|
if (!response.ok) { |
|
|
const error = await response.json().catch(() => ({ error: '์๋ฒ ์ค๋ฅ' })); |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">์ค๋ฅ: ${error.error || 'ํ ํฐ ์ ์ค์ ์ ๋ถ๋ฌ์ฌ ์ ์์ต๋๋ค'}</span>`; |
|
|
listDiv.innerHTML = '<div style="text-align: center; padding: 20px; color: #ea4335;">ํ ํฐ ์ ์ค์ ์ ๋ถ๋ฌ์ฌ ์ ์์ต๋๋ค.</div>'; |
|
|
return; |
|
|
} |
|
|
|
|
|
const data = await response.json(); |
|
|
|
|
|
if (!data.models || data.models.length === 0) { |
|
|
statusDiv.innerHTML = '<span style="color: #5f6368;">์ฌ์ฉ ๊ฐ๋ฅํ AI ๋ชจ๋ธ์ด ์์ต๋๋ค.</span>'; |
|
|
listDiv.innerHTML = '<div style="text-align: center; padding: 20px; color: #5f6368;">์ฌ์ฉ ๊ฐ๋ฅํ AI ๋ชจ๋ธ์ด ์์ต๋๋ค.</div>'; |
|
|
return; |
|
|
} |
|
|
|
|
|
statusDiv.innerHTML = `<span style="color: #137333;">โ ${data.models.length}๊ฐ ๋ชจ๋ธ ๋ฐ๊ฒฌ</span>`; |
|
|
|
|
|
let html = ''; |
|
|
data.models.forEach(modelName => { |
|
|
|
|
|
const inputTokens = data.input_tokens || {}; |
|
|
const outputTokens = data.output_tokens || {}; |
|
|
const parentChunkTokens = data.parent_chunk_tokens || {}; |
|
|
const defaultInputTokens = data.default_input_tokens || {}; |
|
|
const defaultOutputTokens = data.default_output_tokens || {}; |
|
|
const defaultParentChunkTokens = data.default_parent_chunk_tokens || {}; |
|
|
|
|
|
const currentInputTokens = inputTokens[modelName] || ''; |
|
|
const currentOutputTokens = outputTokens[modelName] || ''; |
|
|
const currentParentChunkTokens = parentChunkTokens[modelName] || ''; |
|
|
const defaultInputToken = defaultInputTokens[modelName] || 100000; |
|
|
const defaultOutputToken = defaultOutputTokens[modelName] || 2000; |
|
|
const defaultParentChunkToken = defaultParentChunkTokens[modelName] || 8192; |
|
|
const modelType = modelName.startsWith('gemini:') ? 'Gemini' : 'Ollama'; |
|
|
const displayName = modelName.startsWith('gemini:') ? modelName.replace('gemini:', '') : modelName; |
|
|
|
|
|
|
|
|
const actualInputToken = currentInputTokens ? parseInt(currentInputTokens) : defaultInputToken; |
|
|
const actualOutputToken = currentOutputTokens ? parseInt(currentOutputTokens) : defaultOutputToken; |
|
|
const actualParentChunkToken = currentParentChunkTokens ? parseInt(currentParentChunkTokens) : defaultParentChunkToken; |
|
|
|
|
|
|
|
|
const getTokenStatusText = (actual, defaultVal, isUsingDefault) => { |
|
|
if (isUsingDefault) { |
|
|
return `์ค์ ์ฌ์ฉ: ${actual.toLocaleString()} (๊ธฐ๋ณธ๊ฐ)`; |
|
|
} else { |
|
|
return `์ค์ ์ฌ์ฉ: ${actual.toLocaleString()} (์ค์ ๊ฐ)`; |
|
|
} |
|
|
}; |
|
|
|
|
|
const inputStatusText = getTokenStatusText(actualInputToken, defaultInputToken, !currentInputTokens); |
|
|
const outputStatusText = getTokenStatusText(actualOutputToken, defaultOutputToken, !currentOutputTokens); |
|
|
const parentChunkStatusText = getTokenStatusText(actualParentChunkToken, defaultParentChunkToken, !currentParentChunkTokens); |
|
|
|
|
|
|
|
|
const safeId = modelNameToId(modelName); |
|
|
|
|
|
html += ` |
|
|
<div style="padding: 16px; background: #f8f9fa; border-radius: 6px; border: 1px solid #dadce0; margin-bottom: 12px;" data-model-name="${escapeHtml(modelName)}"> |
|
|
<div style="margin-bottom: 12px;"> |
|
|
<div style="font-weight: 500; margin-bottom: 4px; font-size: 15px;">${escapeHtml(displayName)}</div> |
|
|
<div style="font-size: 12px; color: #5f6368; line-height: 1.6;"> |
|
|
<div><strong>ํ์
:</strong> ${modelType}</div> |
|
|
<div><strong>์
๋ ฅ ํ ํฐ:</strong> ${inputStatusText}</div> |
|
|
<div><strong>์ถ๋ ฅ ํ ํฐ:</strong> ${outputStatusText}</div> |
|
|
<div><strong>Parent Chunk ํ ํฐ:</strong> ${parentChunkStatusText}</div> |
|
|
</div> |
|
|
</div> |
|
|
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px;"> |
|
|
<div> |
|
|
<label style="display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: #202124;">์
๋ ฅ ํ ํฐ</label> |
|
|
<div style="display: flex; gap: 8px;"> |
|
|
<input |
|
|
type="number" |
|
|
id="input_tokens_${safeId}" |
|
|
data-model-name="${escapeHtml(modelName)}" |
|
|
value="${currentInputTokens || ''}" |
|
|
placeholder="๊ธฐ๋ณธ๊ฐ: ${defaultInputToken.toLocaleString()}" |
|
|
min="1" |
|
|
style="flex: 1; padding: 6px 10px; border: 1px solid #dadce0; border-radius: 4px; font-size: 14px;" |
|
|
> |
|
|
<button |
|
|
class="btn btn-primary" |
|
|
onclick="saveModelTokens('${escapeHtml(modelName)}', 'input')" |
|
|
style="padding: 6px 12px; font-size: 13px; white-space: nowrap;" |
|
|
> |
|
|
์ ์ฅ |
|
|
</button> |
|
|
</div> |
|
|
</div> |
|
|
<div> |
|
|
<label style="display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: #202124;">์ถ๋ ฅ ํ ํฐ</label> |
|
|
<div style="display: flex; gap: 8px;"> |
|
|
<input |
|
|
type="number" |
|
|
id="output_tokens_${safeId}" |
|
|
data-model-name="${escapeHtml(modelName)}" |
|
|
value="${currentOutputTokens || ''}" |
|
|
placeholder="๊ธฐ๋ณธ๊ฐ: ${defaultOutputToken.toLocaleString()}" |
|
|
min="1" |
|
|
style="flex: 1; padding: 6px 10px; border: 1px solid #dadce0; border-radius: 4px; font-size: 14px;" |
|
|
> |
|
|
<button |
|
|
class="btn btn-primary" |
|
|
onclick="saveModelTokens('${escapeHtml(modelName)}', 'output')" |
|
|
style="padding: 6px 12px; font-size: 13px; white-space: nowrap;" |
|
|
> |
|
|
์ ์ฅ |
|
|
</button> |
|
|
</div> |
|
|
</div> |
|
|
<div> |
|
|
<label style="display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: #202124;">Parent Chunk ํ ํฐ</label> |
|
|
<div style="display: flex; gap: 8px;"> |
|
|
<input |
|
|
type="number" |
|
|
id="parent_chunk_tokens_${safeId}" |
|
|
data-model-name="${escapeHtml(modelName)}" |
|
|
value="${currentParentChunkTokens || ''}" |
|
|
placeholder="๊ธฐ๋ณธ๊ฐ: ${defaultParentChunkToken.toLocaleString()}" |
|
|
min="1" |
|
|
style="flex: 1; padding: 6px 10px; border: 1px solid #dadce0; border-radius: 4px; font-size: 14px;" |
|
|
> |
|
|
<button |
|
|
class="btn btn-primary" |
|
|
onclick="saveModelTokens('${escapeHtml(modelName)}', 'parent_chunk')" |
|
|
style="padding: 6px 12px; font-size: 13px; white-space: nowrap;" |
|
|
> |
|
|
์ ์ฅ |
|
|
</button> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
`; |
|
|
}); |
|
|
|
|
|
listDiv.innerHTML = html; |
|
|
|
|
|
} catch (error) { |
|
|
console.error('ํ ํฐ ์ ์ค์ ๋ก๋ ์ค๋ฅ:', error); |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">์ค๋ฅ: ${error.message}</span>`; |
|
|
listDiv.innerHTML = '<div style="text-align: center; padding: 20px; color: #ea4335;">ํ ํฐ ์ ์ค์ ์ ๋ถ๋ฌ์ค๋ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.</div>'; |
|
|
} |
|
|
} |
|
|
|
|
|
async function saveModelTokens(modelName, tokenType) { |
|
|
|
|
|
const safeId = modelNameToId(modelName); |
|
|
let inputId; |
|
|
if (tokenType === 'input') { |
|
|
inputId = `input_tokens_${safeId}`; |
|
|
} else if (tokenType === 'output') { |
|
|
inputId = `output_tokens_${safeId}`; |
|
|
} else if (tokenType === 'parent_chunk') { |
|
|
inputId = `parent_chunk_tokens_${safeId}`; |
|
|
} else { |
|
|
showAlert('์๋ชป๋ ํ ํฐ ํ์
์
๋๋ค.', 'error'); |
|
|
return; |
|
|
} |
|
|
|
|
|
const input = document.getElementById(inputId); |
|
|
if (!input) { |
|
|
console.error(`Input element not found: ${inputId}`); |
|
|
showAlert('์
๋ ฅ ํ๋๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค. ํ์ด์ง๋ฅผ ์๋ก๊ณ ์นจํด์ฃผ์ธ์.', 'error'); |
|
|
return; |
|
|
} |
|
|
|
|
|
const tokens = input.value.trim(); |
|
|
console.log(`[ํ ํฐ ์ ์ฅ] ๋ชจ๋ธ: ${modelName}, ํ์
: ${tokenType}, ๊ฐ: ${tokens}`); |
|
|
|
|
|
|
|
|
if (!tokens) { |
|
|
if (!confirm('์
๋ ฅ๊ฐ์ด ๋น์ด์์ต๋๋ค. ๊ธฐ๋ณธ๊ฐ์ผ๋ก ๋๋๋ฆฌ์๊ฒ ์ต๋๊น?')) { |
|
|
return; |
|
|
} |
|
|
|
|
|
try { |
|
|
const response = await fetch('/api/admin/model-tokens', { |
|
|
method: 'POST', |
|
|
headers: { |
|
|
'Content-Type': 'application/json' |
|
|
}, |
|
|
credentials: 'include', |
|
|
body: JSON.stringify({ |
|
|
model_name: modelName, |
|
|
token_type: tokenType, |
|
|
tokens: null |
|
|
}) |
|
|
}); |
|
|
|
|
|
const data = await response.json(); |
|
|
|
|
|
if (response.ok) { |
|
|
showAlert('๊ธฐ๋ณธ๊ฐ์ผ๋ก ๋๋๋ ธ์ต๋๋ค.', 'success'); |
|
|
loadModelTokens(); |
|
|
} else { |
|
|
showAlert(data.error || '์ค์ ์ญ์ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.', 'error'); |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('์ค์ ์ญ์ ์ค๋ฅ:', error); |
|
|
showAlert(`์ค๋ฅ: ${error.message}`, 'error'); |
|
|
} |
|
|
return; |
|
|
} |
|
|
|
|
|
try { |
|
|
const tokensNum = parseInt(tokens); |
|
|
if (isNaN(tokensNum) || tokensNum < 1) { |
|
|
showAlert('ํ ํฐ ์๋ 1 ์ด์์ ์ ์์ฌ์ผ ํฉ๋๋ค.', 'error'); |
|
|
return; |
|
|
} |
|
|
|
|
|
const response = await fetch('/api/admin/model-tokens', { |
|
|
method: 'POST', |
|
|
headers: { |
|
|
'Content-Type': 'application/json' |
|
|
}, |
|
|
credentials: 'include', |
|
|
body: JSON.stringify({ |
|
|
model_name: modelName, |
|
|
token_type: tokenType, |
|
|
tokens: tokensNum |
|
|
}) |
|
|
}); |
|
|
|
|
|
const data = await response.json(); |
|
|
console.log(`[ํ ํฐ ์ ์ฅ ์๋ต]`, data); |
|
|
|
|
|
if (response.ok) { |
|
|
showAlert(data.message || 'ํ ํฐ ์๊ฐ ์ ์ฅ๋์์ต๋๋ค.', 'success'); |
|
|
|
|
|
setTimeout(() => { |
|
|
loadModelTokens(); |
|
|
}, 300); |
|
|
} else { |
|
|
console.error(`[ํ ํฐ ์ ์ฅ ์คํจ]`, data); |
|
|
showAlert(data.error || 'ํ ํฐ ์ ์ ์ฅ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.', 'error'); |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('ํ ํฐ ์ ์ ์ฅ ์ค๋ฅ:', error); |
|
|
showAlert(`์ค๋ฅ: ${error.message}`, 'error'); |
|
|
} |
|
|
} |
|
|
|
|
|
function escapeHtml(text) { |
|
|
const div = document.createElement('div'); |
|
|
div.textContent = text; |
|
|
return div.innerHTML; |
|
|
} |
|
|
|
|
|
|
|
|
function modelNameToId(modelName) { |
|
|
|
|
|
return modelName.replace(/[^a-zA-Z0-9]/g, '_'); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function idToModelName(id) { |
|
|
|
|
|
return id; |
|
|
} |
|
|
|
|
|
|
|
|
async function loadDefaultModels() { |
|
|
const statusDiv = document.getElementById('defaultModelsStatus'); |
|
|
const analysisSelect = document.getElementById('defaultAnalysisModel'); |
|
|
const answerSelect = document.getElementById('defaultAnswerModel'); |
|
|
|
|
|
try { |
|
|
statusDiv.innerHTML = '<span style="color: #1a73e8;">๊ธฐ๋ณธ ๋ชจ๋ธ ์ค์ ์ ๋ถ๋ฌ์ค๋ ์ค...</span>'; |
|
|
|
|
|
|
|
|
const modelsResponse = await fetch('/api/admin/ollama/models', { |
|
|
credentials: 'include' |
|
|
}); |
|
|
|
|
|
if (!modelsResponse.ok) { |
|
|
throw new Error('๋ชจ๋ธ ๋ชฉ๋ก์ ๋ถ๋ฌ์ฌ ์ ์์ต๋๋ค.'); |
|
|
} |
|
|
|
|
|
const modelsData = await modelsResponse.json(); |
|
|
|
|
|
|
|
|
analysisSelect.innerHTML = '<option value="">๊ธฐ๋ณธ๊ฐ ์์</option>'; |
|
|
answerSelect.innerHTML = '<option value="">๊ธฐ๋ณธ๊ฐ ์์</option>'; |
|
|
|
|
|
|
|
|
const ollamaModels = []; |
|
|
const geminiModels = []; |
|
|
|
|
|
if (modelsData.models && modelsData.models.length > 0) { |
|
|
modelsData.models.forEach(model => { |
|
|
if (model.type === 'ollama') { |
|
|
ollamaModels.push(model); |
|
|
} else if (model.type === 'gemini') { |
|
|
geminiModels.push(model); |
|
|
} |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
if (ollamaModels.length > 0) { |
|
|
const optgroup1 = document.createElement('optgroup'); |
|
|
optgroup1.label = 'Ollama ๋ชจ๋ธ'; |
|
|
ollamaModels.forEach(model => { |
|
|
const option = document.createElement('option'); |
|
|
option.value = model.name; |
|
|
option.textContent = model.name; |
|
|
optgroup1.appendChild(option); |
|
|
}); |
|
|
analysisSelect.appendChild(optgroup1); |
|
|
|
|
|
const optgroup2 = document.createElement('optgroup'); |
|
|
optgroup2.label = 'Ollama ๋ชจ๋ธ'; |
|
|
ollamaModels.forEach(model => { |
|
|
const option = document.createElement('option'); |
|
|
option.value = model.name; |
|
|
option.textContent = model.name; |
|
|
optgroup2.appendChild(option); |
|
|
}); |
|
|
answerSelect.appendChild(optgroup2); |
|
|
} |
|
|
|
|
|
|
|
|
if (geminiModels.length > 0) { |
|
|
const optgroup1 = document.createElement('optgroup'); |
|
|
optgroup1.label = 'Gemini ๋ชจ๋ธ'; |
|
|
geminiModels.forEach(model => { |
|
|
const option = document.createElement('option'); |
|
|
option.value = model.name; |
|
|
option.textContent = model.name.replace('gemini:', ''); |
|
|
optgroup1.appendChild(option); |
|
|
}); |
|
|
analysisSelect.appendChild(optgroup1); |
|
|
|
|
|
const optgroup2 = document.createElement('optgroup'); |
|
|
optgroup2.label = 'Gemini ๋ชจ๋ธ'; |
|
|
geminiModels.forEach(model => { |
|
|
const option = document.createElement('option'); |
|
|
option.value = model.name; |
|
|
option.textContent = model.name.replace('gemini:', ''); |
|
|
optgroup2.appendChild(option); |
|
|
}); |
|
|
answerSelect.appendChild(optgroup2); |
|
|
} |
|
|
|
|
|
|
|
|
const defaultResponse = await fetch('/api/admin/default-models', { |
|
|
credentials: 'include' |
|
|
}); |
|
|
|
|
|
if (defaultResponse.ok) { |
|
|
const defaultData = await defaultResponse.json(); |
|
|
if (defaultData.default_analysis_model) { |
|
|
analysisSelect.value = defaultData.default_analysis_model; |
|
|
} |
|
|
if (defaultData.default_answer_model) { |
|
|
answerSelect.value = defaultData.default_answer_model; |
|
|
} |
|
|
statusDiv.innerHTML = '<span style="color: #137333;">โ ๊ธฐ๋ณธ ๋ชจ๋ธ ์ค์ ์ ๋ถ๋ฌ์์ต๋๋ค.</span>'; |
|
|
} else { |
|
|
statusDiv.innerHTML = '<span style="color: #ea4335;">๊ธฐ๋ณธ ๋ชจ๋ธ ์ค์ ์ ๋ถ๋ฌ์ฌ ์ ์์ต๋๋ค.</span>'; |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('๊ธฐ๋ณธ ๋ชจ๋ธ ์ค์ ๋ก๋ ์ค๋ฅ:', error); |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">์ค๋ฅ: ${error.message}</span>`; |
|
|
} |
|
|
} |
|
|
|
|
|
async function saveDefaultModels() { |
|
|
const analysisSelect = document.getElementById('defaultAnalysisModel'); |
|
|
const answerSelect = document.getElementById('defaultAnswerModel'); |
|
|
const statusDiv = document.getElementById('defaultModelsStatus'); |
|
|
|
|
|
const defaultAnalysisModel = analysisSelect.value; |
|
|
const defaultAnswerModel = answerSelect.value; |
|
|
|
|
|
try { |
|
|
statusDiv.innerHTML = '<span style="color: #1a73e8;">์ ์ฅ ์ค...</span>'; |
|
|
|
|
|
const response = await fetch('/api/admin/default-models', { |
|
|
method: 'POST', |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
}, |
|
|
credentials: 'include', |
|
|
body: JSON.stringify({ |
|
|
default_analysis_model: defaultAnalysisModel, |
|
|
default_answer_model: defaultAnswerModel |
|
|
}) |
|
|
}); |
|
|
|
|
|
const data = await response.json(); |
|
|
|
|
|
if (response.ok) { |
|
|
showAlert(data.message || '๊ธฐ๋ณธ AI ๋ชจ๋ธ์ด ์ ์ฅ๋์์ต๋๋ค.', 'success'); |
|
|
statusDiv.innerHTML = '<span style="color: #137333;">โ ๊ธฐ๋ณธ ๋ชจ๋ธ ์ค์ ์ด ์ ์ฅ๋์์ต๋๋ค.</span>'; |
|
|
} else { |
|
|
showAlert(data.error || '๊ธฐ๋ณธ ๋ชจ๋ธ ์ค์ ์ ์ฅ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.', 'error'); |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">์ค๋ฅ: ${data.error || '์ ์ ์๋ ์ค๋ฅ'}</span>`; |
|
|
} |
|
|
} catch (error) { |
|
|
console.error('๊ธฐ๋ณธ ๋ชจ๋ธ ์ค์ ์ ์ฅ ์ค๋ฅ:', error); |
|
|
showAlert(`์ค๋ฅ: ${error.message}`, 'error'); |
|
|
statusDiv.innerHTML = `<span style="color: #ea4335;">์ค๋ฅ: ${error.message}</span>`; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
window.addEventListener('load', () => { |
|
|
loadGeminiApiKey(); |
|
|
loadHuggingFaceToken(); |
|
|
loadModelTokens(); |
|
|
loadDefaultModels(); |
|
|
}); |
|
|
</script> |
|
|
</body> |
|
|
</html> |
|
|
|
|
|
|