diff --git a/index.html b/index.html index 3b2d7203..99c9f849 100644 --- a/index.html +++ b/index.html @@ -4951,7 +4951,18 @@ >Model: - + Temperature: + + + Key: @@ -8098,7 +8109,7 @@ - + diff --git a/modules/ui/ai-generator.js b/modules/ui/ai-generator.js index c28efc8a..daa8cde6 100644 --- a/modules/ui/ai-generator.js +++ b/modules/ui/ai-generator.js @@ -3,7 +3,7 @@ const GPT_MODELS = ["gpt-4o-mini", "chatgpt-4o-latest", "gpt-4o", "gpt-4-turbo", "gpt-4", "gpt-3.5-turbo"]; const SYSTEM_MESSAGE = "I'm working on my fantasy map."; -function geneateWithAi(defaultPrompt, onApply) { +function generateWithAi(defaultPrompt, onApply) { updateValues(); $("#aiGenerator").dialog({ @@ -26,13 +26,14 @@ function geneateWithAi(defaultPrompt, onApply) { } }); - if (modules.geneateWithAi) return; - modules.geneateWithAi = true; + if (modules.generateWithAi) return; + modules.generateWithAi = true; function updateValues() { byId("aiGeneratorResult").value = ""; byId("aiGeneratorPrompt").value = defaultPrompt; byId("aiGeneratorKey").value = localStorage.getItem("fmg-ai-kl") || ""; + byId("aiGeneratorTemperature").value = localStorage.getItem("fmg-ai-temperature") || "1.2"; const select = byId("aiGeneratorModel"); select.options.length = 0; @@ -52,6 +53,12 @@ function geneateWithAi(defaultPrompt, onApply) { const prompt = byId("aiGeneratorPrompt").value; if (!prompt) return tip("Please enter a prompt", true, "error", 4000); + const temperature = parseFloat(byId("aiGeneratorTemperature").value); + if (isNaN(temperature) || temperature < 0 || temperature > 2) { + return tip("Temperature must be a number between 0 and 2", true, "error", 4000); + } + localStorage.setItem("fmg-ai-temperature", temperature.toString()); + try { button.disabled = true; const resultArea = byId("aiGeneratorResult"); @@ -70,7 +77,7 @@ function geneateWithAi(defaultPrompt, onApply) { {role: "system", content: SYSTEM_MESSAGE}, {role: "user", content: prompt} ], - temperature: 1.2, + temperature: temperature, stream: true // Enable streaming }) }); diff --git a/modules/ui/notes-editor.js b/modules/ui/notes-editor.js index 378cec3c..2b5d1c79 100644 --- a/modules/ui/notes-editor.js +++ b/modules/ui/notes-editor.js @@ -160,7 +160,7 @@ function editNotes(id, name) { } }; - geneateWithAi(prompt, onApply); + generateWithAi(prompt, onApply); } function downloadLegends() { diff --git a/versioning.js b/versioning.js index c5bf2fa4..fa8da7ec 100644 --- a/versioning.js +++ b/versioning.js @@ -13,7 +13,7 @@ * Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2 */ -const VERSION = "1.105.21"; +const VERSION = "1.105.22"; if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function"); {