Compare commits
4 Commits
main
...
96432d22f5
| Author | SHA1 | Date | |
|---|---|---|---|
| 96432d22f5 | |||
| a4cbc2db86 | |||
| 49f2b9261d | |||
| 56e78053cf |
@@ -43,3 +43,6 @@ Thumbs.db
|
|||||||
# Testing
|
# Testing
|
||||||
coverage
|
coverage
|
||||||
.nyc_output
|
.nyc_output
|
||||||
|
|
||||||
|
# Deploy scripts
|
||||||
|
deploy.ps1
|
||||||
|
|||||||
+2
-2
@@ -1207,7 +1207,7 @@ app.post("/api/deepseek/chat", requireAuth, async (req, res) => {
|
|||||||
return res.status(500).json({ error: "DeepSeek API key not configured" });
|
return res.status(500).json({ error: "DeepSeek API key not configured" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { temperature = 0.8, max_tokens = 1000 } = req.body;
|
const { messages, temperature = 0.8, max_tokens = 1000 } = req.body;
|
||||||
const sanitizedMessages = sanitizeDeepSeekMessages(messages);
|
const sanitizedMessages = sanitizeDeepSeekMessages(messages);
|
||||||
const clampedMaxTokens = Math.min(
|
const clampedMaxTokens = Math.min(
|
||||||
max_tokens,
|
max_tokens,
|
||||||
@@ -1268,7 +1268,7 @@ app.post("/api/deepseek/chat/stream", requireAuth, async (req, res) => {
|
|||||||
return res.status(500).json({ error: "DeepSeek API key not configured" });
|
return res.status(500).json({ error: "DeepSeek API key not configured" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { temperature = 0.8, max_tokens = 1000 } = req.body;
|
const { messages, temperature = 0.8, max_tokens = 1000 } = req.body;
|
||||||
const sanitizedMessages = sanitizeDeepSeekMessages(messages);
|
const sanitizedMessages = sanitizeDeepSeekMessages(messages);
|
||||||
const clampedMaxTokens = Math.min(
|
const clampedMaxTokens = Math.min(
|
||||||
max_tokens,
|
max_tokens,
|
||||||
|
|||||||
@@ -703,6 +703,10 @@
|
|||||||
font-size: 0.95rem;
|
font-size: 0.95rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.character-fields textarea {
|
||||||
|
resize: vertical;
|
||||||
|
}
|
||||||
|
|
||||||
.character-fields input:focus,
|
.character-fields input:focus,
|
||||||
.character-fields select:focus,
|
.character-fields select:focus,
|
||||||
.character-fields textarea:focus {
|
.character-fields textarea:focus {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
getStory,
|
getStory,
|
||||||
updateStory,
|
updateStory,
|
||||||
getNPCCharacters,
|
getNPCCharacters,
|
||||||
|
createNPCCharacter,
|
||||||
} from "../services/api";
|
} from "../services/api";
|
||||||
import { generateAvatarUrl } from "../services/imageGen";
|
import { generateAvatarUrl } from "../services/imageGen";
|
||||||
import { useStoryGeneration } from "../hooks/useStoryGeneration";
|
import { useStoryGeneration } from "../hooks/useStoryGeneration";
|
||||||
@@ -424,6 +425,8 @@ export default function CreateStoryPage() {
|
|||||||
allSettings.push(form.customSetting.trim());
|
allSettings.push(form.customSetting.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const storyCharacters = form.characters.filter((c) => c.name.trim());
|
||||||
|
|
||||||
const storyData = {
|
const storyData = {
|
||||||
title: form.title,
|
title: form.title,
|
||||||
description: form.description || `Исекай история: ${form.title}`,
|
description: form.description || `Исекай история: ${form.title}`,
|
||||||
@@ -436,7 +439,7 @@ export default function CreateStoryPage() {
|
|||||||
summary: form.summary,
|
summary: form.summary,
|
||||||
plot: form.plot,
|
plot: form.plot,
|
||||||
firstMessage: form.firstMessage,
|
firstMessage: form.firstMessage,
|
||||||
characters: form.characters.filter((c) => c.name.trim()),
|
characters: storyCharacters,
|
||||||
isNsfw: form.isNsfw,
|
isNsfw: form.isNsfw,
|
||||||
temperature: form.temperature,
|
temperature: form.temperature,
|
||||||
narrativeRules: form.narrativeRules.trim() || undefined,
|
narrativeRules: form.narrativeRules.trim() || undefined,
|
||||||
@@ -447,14 +450,39 @@ export default function CreateStoryPage() {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helper function to save characters as global NPCs
|
||||||
|
const saveCharactersAsGlobalNPCs = async () => {
|
||||||
|
const existingNames = savedNPCs.map((npc) => npc.name.toLowerCase());
|
||||||
|
|
||||||
|
for (const char of storyCharacters) {
|
||||||
|
// Skip if NPC with this name already exists
|
||||||
|
if (existingNames.includes(char.name.toLowerCase())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create global NPC from story character
|
||||||
|
await createNPCCharacter({
|
||||||
|
name: char.name,
|
||||||
|
description: char.description,
|
||||||
|
role: char.role,
|
||||||
|
age: char.age || "adult",
|
||||||
|
gender: char.gender || "female",
|
||||||
|
isNsfw: form.isNsfw,
|
||||||
|
avatarUrl: char.avatarUrl,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (isEditMode && id) {
|
if (isEditMode && id) {
|
||||||
const success = await updateStory(id, storyData);
|
const success = await updateStory(id, storyData);
|
||||||
if (success) {
|
if (success) {
|
||||||
|
await saveCharactersAsGlobalNPCs();
|
||||||
navigate(`/story/${id}`);
|
navigate(`/story/${id}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const story = await createStory(storyData);
|
const story = await createStory(storyData);
|
||||||
if (story) {
|
if (story) {
|
||||||
|
await saveCharactersAsGlobalNPCs();
|
||||||
navigate(`/story/${story.id}`);
|
navigate(`/story/${story.id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user