Spaces:
Running
Running
Upload 6 files
Browse files- control.js +29 -22
- index.html +16 -14
- prompt.js +13 -1
control.js
CHANGED
|
@@ -32,19 +32,6 @@ document.getElementById('sidebarToggle').addEventListener('click', function () {
|
|
| 32 |
}
|
| 33 |
});
|
| 34 |
|
| 35 |
-
function resizeQueryTextarea() {
|
| 36 |
-
const queryTextarea = document.getElementById('query');
|
| 37 |
-
const cardBody = queryTextarea.closest('.card-body');
|
| 38 |
-
queryTextarea.style.minHeight = cardBody.offsetHeight + 'px';
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
document.addEventListener('DOMContentLoaded', function () {
|
| 42 |
-
resizeQueryTextarea();
|
| 43 |
-
initSidebarResize(); // 新しい関数を呼び出し
|
| 44 |
-
});
|
| 45 |
-
|
| 46 |
-
window.addEventListener('resize', resizeQueryTextarea);
|
| 47 |
-
|
| 48 |
// サイドバーのリサイズ機能を修正
|
| 49 |
function initSidebarResize() {
|
| 50 |
const sidebarContainer = document.getElementById('sidebar-container');
|
|
@@ -92,18 +79,38 @@ function initClearStorageButton() {
|
|
| 92 |
});
|
| 93 |
}
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
// DOMContentLoadedイベントリスナーを更新
|
| 96 |
document.addEventListener('DOMContentLoaded', function () {
|
| 97 |
-
|
| 98 |
initSidebarResize();
|
| 99 |
initClearStorageButton();
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
// 初期状態でサイドバーを非表示にする処理も不要になるため、削除
|
| 103 |
-
// const sidebarContainer = document.getElementById('sidebar-container');
|
| 104 |
-
// const content = document.getElementById('content');
|
| 105 |
-
// sidebarContainer.classList.remove('active');
|
| 106 |
-
// content.classList.remove('sidebar-active');
|
| 107 |
});
|
| 108 |
|
| 109 |
-
window.addEventListener(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
}
|
| 33 |
});
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
// サイドバーのリサイズ機能を修正
|
| 36 |
function initSidebarResize() {
|
| 37 |
const sidebarContainer = document.getElementById('sidebar-container');
|
|
|
|
| 79 |
});
|
| 80 |
}
|
| 81 |
|
| 82 |
+
function resizeMain() {
|
| 83 |
+
if (window.innerWidth >= 768) {
|
| 84 |
+
document.querySelector("main").style.height = `calc(100vh - ${document.querySelector("main").offsetTop}px)`
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
// DOMContentLoadedイベントリスナーを更新
|
| 89 |
document.addEventListener('DOMContentLoaded', function () {
|
| 90 |
+
resizeMain();
|
| 91 |
initSidebarResize();
|
| 92 |
initClearStorageButton();
|
| 93 |
+
updateModelList(); // 新しい関数を呼び出し
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
});
|
| 95 |
|
| 96 |
+
window.addEventListener("resize", resizeMain);
|
| 97 |
+
|
| 98 |
+
async function updateModelList() {
|
| 99 |
+
try {
|
| 100 |
+
const models = await getModelList();
|
| 101 |
+
const endpointSelect = document.getElementById('endpointSelect');
|
| 102 |
+
const currentOptions = Array.from(endpointSelect.options).map(option => option.value);
|
| 103 |
+
|
| 104 |
+
models.forEach(model => {
|
| 105 |
+
const modelPath = `models/${model.name.split('/').pop()}`;
|
| 106 |
+
if (!currentOptions.includes(modelPath)) {
|
| 107 |
+
const option = document.createElement('option');
|
| 108 |
+
option.value = modelPath;
|
| 109 |
+
option.textContent = model.name.split('/').pop();
|
| 110 |
+
endpointSelect.appendChild(option);
|
| 111 |
+
}
|
| 112 |
+
});
|
| 113 |
+
} catch (error) {
|
| 114 |
+
console.error('モデルリストの更新中にエラーが発生しました:', error);
|
| 115 |
+
}
|
| 116 |
+
}
|
index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
| 10 |
crossorigin="anonymous">
|
| 11 |
<style>
|
| 12 |
textarea.form-control {
|
| 13 |
-
min-height:
|
| 14 |
}
|
| 15 |
|
| 16 |
#sidebar-container {
|
|
@@ -131,10 +131,12 @@
|
|
| 131 |
<div class="form-group mb-3">
|
| 132 |
<label for="endpointSelect" class="form-label" id="endpointSelectLabel">エンドポイント</label>
|
| 133 |
<select class="form-select" id="endpointSelect">
|
| 134 |
-
<option value="gemini-1.5-pro-
|
| 135 |
-
<option value="gemini-1.5-flash-
|
| 136 |
-
<option value="gemini-1.5-pro-
|
| 137 |
-
<option value="gemini-1.5-flash-
|
|
|
|
|
|
|
| 138 |
</select>
|
| 139 |
</div>
|
| 140 |
|
|
@@ -184,9 +186,9 @@
|
|
| 184 |
</div>
|
| 185 |
</nav>
|
| 186 |
|
| 187 |
-
<div class="container
|
| 188 |
-
<
|
| 189 |
-
<div id="inputQuery" class="col-lg-4 col-md-12 mb-4">
|
| 190 |
<div class="card h-100">
|
| 191 |
<div class="card-header bg-primary text-white">
|
| 192 |
<h5 class="mb-0" id="inputQueryTitle">入力クエリ</h5>
|
|
@@ -211,7 +213,7 @@
|
|
| 211 |
</div>
|
| 212 |
</div>
|
| 213 |
</div>
|
| 214 |
-
<div id="outputPrompt" class="col-lg-8 col-md-12 mb-4">
|
| 215 |
<div class="card h-100">
|
| 216 |
<div class="card-header bg-success text-white">
|
| 217 |
<h5 class="mb-0" id="outputPromptTitle">生成されたプロンプト</h5>
|
|
@@ -221,13 +223,13 @@
|
|
| 221 |
<label for="promptEn" class="form-label" id="promptEnLabel">English Prompt</label>
|
| 222 |
<textarea class="form-control" id="promptEn" placeholder="English Prompt"></textarea>
|
| 223 |
</div>
|
| 224 |
-
<div class="form-group
|
| 225 |
-
<label for="promptMyLanguage" class="form-label" id="promptMyLanguageLabel">Your
|
| 226 |
Language Translation</label>
|
| 227 |
<textarea class="form-control" id="promptMyLanguage" disabled></textarea>
|
| 228 |
</div>
|
| 229 |
-
<div class="form-group
|
| 230 |
-
<label for="danbooruTags" class="form-label" id="danbooruTagsLabel">
|
| 231 |
danbooru tags
|
| 232 |
</label>
|
| 233 |
<input type="text" class="form-control" id="danbooruTags" placeholder="danbooru tags"
|
|
@@ -236,7 +238,7 @@
|
|
| 236 |
</div>
|
| 237 |
</div>
|
| 238 |
</div>
|
| 239 |
-
</
|
| 240 |
</div>
|
| 241 |
</div>
|
| 242 |
|
|
|
|
| 10 |
crossorigin="anonymous">
|
| 11 |
<style>
|
| 12 |
textarea.form-control {
|
| 13 |
+
min-height: 25vh;
|
| 14 |
}
|
| 15 |
|
| 16 |
#sidebar-container {
|
|
|
|
| 131 |
<div class="form-group mb-3">
|
| 132 |
<label for="endpointSelect" class="form-label" id="endpointSelectLabel">エンドポイント</label>
|
| 133 |
<select class="form-select" id="endpointSelect">
|
| 134 |
+
<option value="models/gemini-1.5-pro-002">gemini-1.5-pro-002</option>
|
| 135 |
+
<option value="models/gemini-1.5-flash-002">gemini-1.5-flash-002</option>
|
| 136 |
+
<option value="models/gemini-1.5-pro-exp-0827">gemini-1.5-pro-exp-0827</option>
|
| 137 |
+
<option value="models/gemini-1.5-flash-exp-0827">gemini-1.5-flash-exp-0827</option>
|
| 138 |
+
<option value="models/gemini-1.5-pro-latest">gemini-1.5-pro-latest</option>
|
| 139 |
+
<option value="models/gemini-1.5-flash-latest">gemini-1.5-flash-latest</option>
|
| 140 |
</select>
|
| 141 |
</div>
|
| 142 |
|
|
|
|
| 186 |
</div>
|
| 187 |
</nav>
|
| 188 |
|
| 189 |
+
<div class="container">
|
| 190 |
+
<main class="row">
|
| 191 |
+
<div id="inputQuery" class="col-lg-4 col-md-12 mb-4 h-100">
|
| 192 |
<div class="card h-100">
|
| 193 |
<div class="card-header bg-primary text-white">
|
| 194 |
<h5 class="mb-0" id="inputQueryTitle">入力クエリ</h5>
|
|
|
|
| 213 |
</div>
|
| 214 |
</div>
|
| 215 |
</div>
|
| 216 |
+
<div id="outputPrompt" class="col-lg-8 col-md-12 mb-4 h-100">
|
| 217 |
<div class="card h-100">
|
| 218 |
<div class="card-header bg-success text-white">
|
| 219 |
<h5 class="mb-0" id="outputPromptTitle">生成されたプロンプト</h5>
|
|
|
|
| 223 |
<label for="promptEn" class="form-label" id="promptEnLabel">English Prompt</label>
|
| 224 |
<textarea class="form-control" id="promptEn" placeholder="English Prompt"></textarea>
|
| 225 |
</div>
|
| 226 |
+
<div class="form-group">
|
| 227 |
+
<label for="promptMyLanguage" class="form-label mt-3" id="promptMyLanguageLabel">Your
|
| 228 |
Language Translation</label>
|
| 229 |
<textarea class="form-control" id="promptMyLanguage" disabled></textarea>
|
| 230 |
</div>
|
| 231 |
+
<div class="form-group">
|
| 232 |
+
<label for="danbooruTags" class="form-label mt-3" id="danbooruTagsLabel">
|
| 233 |
danbooru tags
|
| 234 |
</label>
|
| 235 |
<input type="text" class="form-control" id="danbooruTags" placeholder="danbooru tags"
|
|
|
|
| 238 |
</div>
|
| 239 |
</div>
|
| 240 |
</div>
|
| 241 |
+
</main>
|
| 242 |
</div>
|
| 243 |
</div>
|
| 244 |
|
prompt.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
function generatePrompt() {
|
| 2 |
if (!document.getElementById('apiKey').value) {
|
| 3 |
alert("APIキーを入力してください");
|
|
@@ -23,7 +35,7 @@ function generatePrompt() {
|
|
| 23 |
}
|
| 24 |
|
| 25 |
const selectedEndpoint = document.getElementById('endpointSelect').value;
|
| 26 |
-
const url = `https://generativelanguage.googleapis.com/v1beta
|
| 27 |
|
| 28 |
const text = `「 ${query} 」をテーマに画像生成AIに送るプロンプトを考えてください。
|
| 29 |
背景や小物のディテイール、構図、視覚効果など視覚的な情報のみに言及すること。
|
|
|
|
| 1 |
+
async function getModelList() {
|
| 2 |
+
const url = 'https://generativelanguage.googleapis.com/v1beta/models?key=' + document.getElementById('apiKey').value;
|
| 3 |
+
const response = await fetch(url);
|
| 4 |
+
const data = await response.json();
|
| 5 |
+
return data.models
|
| 6 |
+
.filter(x => x.supportedGenerationMethods.includes("generateContent"))
|
| 7 |
+
.filter(x => {
|
| 8 |
+
const versionMatch = x.name.match(/gemini-(\d+\.\d+)/);
|
| 9 |
+
return versionMatch && parseFloat(versionMatch[1]) >= 1.5;
|
| 10 |
+
});
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
function generatePrompt() {
|
| 14 |
if (!document.getElementById('apiKey').value) {
|
| 15 |
alert("APIキーを入力してください");
|
|
|
|
| 35 |
}
|
| 36 |
|
| 37 |
const selectedEndpoint = document.getElementById('endpointSelect').value;
|
| 38 |
+
const url = `https://generativelanguage.googleapis.com/v1beta/${selectedEndpoint}:generateContent?key=` + document.getElementById('apiKey').value;
|
| 39 |
|
| 40 |
const text = `「 ${query} 」をテーマに画像生成AIに送るプロンプトを考えてください。
|
| 41 |
背景や小物のディテイール、構図、視覚効果など視覚的な情報のみに言及すること。
|