mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31:24 +01:00
Temperature parameters can be customized (#1162)
* Temperature parameters can be customized * fix typo * update to 1.105.22 * Update index.html
This commit is contained in:
parent
91dc16878e
commit
ca8e723006
4 changed files with 26 additions and 8 deletions
15
index.html
15
index.html
|
|
@ -4951,7 +4951,18 @@
|
||||||
>Model:
|
>Model:
|
||||||
<select id="aiGeneratorModel"></select>
|
<select id="aiGeneratorModel"></select>
|
||||||
</label>
|
</label>
|
||||||
|
<label for="aiGeneratorTemperature"
|
||||||
|
>Temperature:
|
||||||
|
<input id="aiGeneratorTemperature" type="number" min="0" max="2" placeholder="1.2" class="icon-key" />
|
||||||
|
<a
|
||||||
|
href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-temperature"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
class="icon-help-circled"
|
||||||
|
style="text-decoration: none"
|
||||||
|
data-tip="Between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic."
|
||||||
|
></a>
|
||||||
|
</label>
|
||||||
<label for="aiGeneratorKey"
|
<label for="aiGeneratorKey"
|
||||||
>Key:
|
>Key:
|
||||||
<input id="aiGeneratorKey" placeholder="Enter OpenAI API key" class="icon-key" />
|
<input id="aiGeneratorKey" placeholder="Enter OpenAI API key" class="icon-key" />
|
||||||
|
|
@ -8098,7 +8109,7 @@
|
||||||
<script defer src="modules/ui/burg-editor.js?v=1.102.00"></script>
|
<script defer src="modules/ui/burg-editor.js?v=1.102.00"></script>
|
||||||
<script defer src="modules/ui/units-editor.js?v=1.104.0"></script>
|
<script defer src="modules/ui/units-editor.js?v=1.104.0"></script>
|
||||||
<script defer src="modules/ui/notes-editor.js?v=1.99.06"></script>
|
<script defer src="modules/ui/notes-editor.js?v=1.99.06"></script>
|
||||||
<script defer src="modules/ui/ai-generator.js?v=1.99.09"></script>
|
<script defer src="modules/ui/ai-generator.js?v=1.105.22"></script>
|
||||||
<script defer src="modules/ui/diplomacy-editor.js?v=1.99.00"></script>
|
<script defer src="modules/ui/diplomacy-editor.js?v=1.99.00"></script>
|
||||||
<script defer src="modules/ui/zones-editor.js?v=1.105.20"></script>
|
<script defer src="modules/ui/zones-editor.js?v=1.105.20"></script>
|
||||||
<script defer src="modules/ui/burgs-overview.js?v=1.105.15"></script>
|
<script defer src="modules/ui/burgs-overview.js?v=1.105.15"></script>
|
||||||
|
|
|
||||||
|
|
@ -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 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.";
|
const SYSTEM_MESSAGE = "I'm working on my fantasy map.";
|
||||||
|
|
||||||
function geneateWithAi(defaultPrompt, onApply) {
|
function generateWithAi(defaultPrompt, onApply) {
|
||||||
updateValues();
|
updateValues();
|
||||||
|
|
||||||
$("#aiGenerator").dialog({
|
$("#aiGenerator").dialog({
|
||||||
|
|
@ -26,13 +26,14 @@ function geneateWithAi(defaultPrompt, onApply) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (modules.geneateWithAi) return;
|
if (modules.generateWithAi) return;
|
||||||
modules.geneateWithAi = true;
|
modules.generateWithAi = true;
|
||||||
|
|
||||||
function updateValues() {
|
function updateValues() {
|
||||||
byId("aiGeneratorResult").value = "";
|
byId("aiGeneratorResult").value = "";
|
||||||
byId("aiGeneratorPrompt").value = defaultPrompt;
|
byId("aiGeneratorPrompt").value = defaultPrompt;
|
||||||
byId("aiGeneratorKey").value = localStorage.getItem("fmg-ai-kl") || "";
|
byId("aiGeneratorKey").value = localStorage.getItem("fmg-ai-kl") || "";
|
||||||
|
byId("aiGeneratorTemperature").value = localStorage.getItem("fmg-ai-temperature") || "1.2";
|
||||||
|
|
||||||
const select = byId("aiGeneratorModel");
|
const select = byId("aiGeneratorModel");
|
||||||
select.options.length = 0;
|
select.options.length = 0;
|
||||||
|
|
@ -52,6 +53,12 @@ function geneateWithAi(defaultPrompt, onApply) {
|
||||||
const prompt = byId("aiGeneratorPrompt").value;
|
const prompt = byId("aiGeneratorPrompt").value;
|
||||||
if (!prompt) return tip("Please enter a prompt", true, "error", 4000);
|
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 {
|
try {
|
||||||
button.disabled = true;
|
button.disabled = true;
|
||||||
const resultArea = byId("aiGeneratorResult");
|
const resultArea = byId("aiGeneratorResult");
|
||||||
|
|
@ -70,7 +77,7 @@ function geneateWithAi(defaultPrompt, onApply) {
|
||||||
{role: "system", content: SYSTEM_MESSAGE},
|
{role: "system", content: SYSTEM_MESSAGE},
|
||||||
{role: "user", content: prompt}
|
{role: "user", content: prompt}
|
||||||
],
|
],
|
||||||
temperature: 1.2,
|
temperature: temperature,
|
||||||
stream: true // Enable streaming
|
stream: true // Enable streaming
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ function editNotes(id, name) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
geneateWithAi(prompt, onApply);
|
generateWithAi(prompt, onApply);
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadLegends() {
|
function downloadLegends() {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2
|
* 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");
|
if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function");
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue