Add writing style template selection to CharacterCardImport component and update scene loading logic to apply selected template

This commit is contained in:
vegu-ai-tools
2025-11-20 11:41:26 +02:00
parent 152f47a12e
commit dde6c76aa9
4 changed files with 41 additions and 2 deletions

View File

@@ -137,6 +137,9 @@ class CharacterCardImportOptions(pydantic.BaseModel):
player_character_existing: str | None = None # detected character name
player_character_import: PlayerCharacterImport | None = None
# Scene settings
writing_style_template: str | None = None # Format: "group__template_uid"
# Internal: track pending asset transfers (deferred until scene name is set)
_pending_asset_transfers: list[AssetTransfer] = pydantic.PrivateAttr(
default_factory=list
@@ -1098,6 +1101,10 @@ async def load_scene_from_character_card(
# Set scene name: use spec's name field if available, otherwise use first character name
scene.name = scene_name if scene_name else first_character.name
# Set writing style template if provided
if import_options.writing_style_template:
scene.writing_style_template = import_options.writing_style_template
# Initialize memory and load character book entries (only once, for first character)
await _initialize_scene_memory(
scene,

View File

@@ -90,6 +90,20 @@
</div>
</v-card-text>
</v-card>
<v-card elevation="0" class="mt-3">
<v-card-text>
<v-select
v-model="options.writing_style_template"
:items="writingStyleItems"
label="Writing Style"
hint="Optional: Select a writing style template to apply to the scene."
persistent-hint
clearable
density="compact"
variant="outlined"
></v-select>
</v-card-text>
</v-card>
</v-col>
<v-col cols="12" md="4">
<v-card elevation="0">
@@ -327,6 +341,9 @@
<script>
export default {
name: 'CharacterCardImport',
props: {
templates: Object,
},
inject: ['getWebsocket', 'registerMessageHandler', 'appConfig'],
data() {
return {
@@ -345,6 +362,7 @@ export default {
generate_episode_titles: true,
setup_shared_context: false,
selected_character_names: [],
writing_style_template: null,
},
resolveCallback: null,
fileData: null,
@@ -400,6 +418,7 @@ export default {
generate_episode_titles: true,
setup_shared_context: false,
selected_character_names: [],
writing_style_template: null,
};
this.analysis = null;
this.analysisError = null;
@@ -610,6 +629,17 @@ export default {
}
return false;
},
writingStyleItems() {
if (!this.templates || !this.templates.by_type || !this.templates.by_type.writing_style) {
return [];
}
const items = Object.values(this.templates.by_type.writing_style).map(t => ({
value: `${t.group}__${t.uid}`,
title: t.name,
props: { subtitle: t.description }
}));
return items;
},
},
created() {
this.registerMessageHandler(this.handleMessage);

View File

@@ -49,7 +49,7 @@
</v-card-text>
</v-card>
</div>
<CharacterCardImport ref="characterCardImportModal"></CharacterCardImport>
<CharacterCardImport ref="characterCardImportModal" :templates="worldStateTemplates"></CharacterCardImport>
</v-list>
</template>
@@ -63,7 +63,8 @@ export default {
CharacterCardImport,
},
props: {
sceneLoadingAvailable: Boolean
sceneLoadingAvailable: Boolean,
worldStateTemplates: Object,
},
computed: {
cols () {

View File

@@ -121,6 +121,7 @@
<LoadScene
ref="loadScene"
:scene-loading-available="ready && connected"
:world-state-templates="worldStateTemplates"
@loading="sceneStartedLoading" />
</v-tabs-window-item>
<v-tabs-window-item :transition="false" :reverse-transition="false" value="main">