Compare commits
4 Commits
96432d22f5
...
ce55101bc5
| Author | SHA1 | Date | |
|---|---|---|---|
| ce55101bc5 | |||
| 2423f5756a | |||
| 4346bcce40 | |||
| 28922fec29 |
@@ -43,3 +43,6 @@ Thumbs.db
|
||||
# Testing
|
||||
coverage
|
||||
.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" });
|
||||
}
|
||||
|
||||
const { temperature = 0.8, max_tokens = 1000 } = req.body;
|
||||
const { messages, temperature = 0.8, max_tokens = 1000 } = req.body;
|
||||
const sanitizedMessages = sanitizeDeepSeekMessages(messages);
|
||||
const clampedMaxTokens = Math.min(
|
||||
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" });
|
||||
}
|
||||
|
||||
const { temperature = 0.8, max_tokens = 1000 } = req.body;
|
||||
const { messages, temperature = 0.8, max_tokens = 1000 } = req.body;
|
||||
const sanitizedMessages = sanitizeDeepSeekMessages(messages);
|
||||
const clampedMaxTokens = Math.min(
|
||||
max_tokens,
|
||||
|
||||
@@ -703,6 +703,10 @@
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.character-fields textarea {
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.character-fields input:focus,
|
||||
.character-fields select:focus,
|
||||
.character-fields textarea:focus {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
getStory,
|
||||
updateStory,
|
||||
getNPCCharacters,
|
||||
createNPCCharacter,
|
||||
} from "../services/api";
|
||||
import { generateAvatarUrl } from "../services/imageGen";
|
||||
import { useStoryGeneration } from "../hooks/useStoryGeneration";
|
||||
@@ -424,6 +425,8 @@ export default function CreateStoryPage() {
|
||||
allSettings.push(form.customSetting.trim());
|
||||
}
|
||||
|
||||
const storyCharacters = form.characters.filter((c) => c.name.trim());
|
||||
|
||||
const storyData = {
|
||||
title: form.title,
|
||||
description: form.description || `Исекай история: ${form.title}`,
|
||||
@@ -436,7 +439,7 @@ export default function CreateStoryPage() {
|
||||
summary: form.summary,
|
||||
plot: form.plot,
|
||||
firstMessage: form.firstMessage,
|
||||
characters: form.characters.filter((c) => c.name.trim()),
|
||||
characters: storyCharacters,
|
||||
isNsfw: form.isNsfw,
|
||||
temperature: form.temperature,
|
||||
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) {
|
||||
const success = await updateStory(id, storyData);
|
||||
if (success) {
|
||||
await saveCharactersAsGlobalNPCs();
|
||||
navigate(`/story/${id}`);
|
||||
}
|
||||
} else {
|
||||
const story = await createStory(storyData);
|
||||
if (story) {
|
||||
await saveCharactersAsGlobalNPCs();
|
||||
navigate(`/story/${story.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user