mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix empty chat if creating new assistant
This commit is contained in:
@@ -281,7 +281,7 @@ async function getRecentChats() {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function openPermanentAssistantChat({ tryCreate = true } = {}) {
|
export async function openPermanentAssistantChat({ tryCreate = true, created = false } = {}) {
|
||||||
const avatar = getPermanentAssistantAvatar();
|
const avatar = getPermanentAssistantAvatar();
|
||||||
const characterId = characters.findIndex(x => x.avatar === avatar);
|
const characterId = characters.findIndex(x => x.avatar === avatar);
|
||||||
if (characterId === -1) {
|
if (characterId === -1) {
|
||||||
@@ -293,7 +293,7 @@ export async function openPermanentAssistantChat({ tryCreate = true } = {}) {
|
|||||||
try {
|
try {
|
||||||
console.log(`Character not found for avatar ID: ${avatar}. Creating new assistant.`);
|
console.log(`Character not found for avatar ID: ${avatar}. Creating new assistant.`);
|
||||||
await createPermanentAssistant();
|
await createPermanentAssistant();
|
||||||
return openPermanentAssistantChat({ tryCreate: false });
|
return openPermanentAssistantChat({ tryCreate: false, created: true });
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('Error creating permanent assistant:', error);
|
console.error('Error creating permanent assistant:', error);
|
||||||
@@ -304,7 +304,9 @@ export async function openPermanentAssistantChat({ tryCreate = true } = {}) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await selectCharacterById(characterId);
|
await selectCharacterById(characterId);
|
||||||
await doNewChat({ deleteCurrentChat: false });
|
if (!created) {
|
||||||
|
await doNewChat({ deleteCurrentChat: false });
|
||||||
|
}
|
||||||
console.log(`Opened permanent assistant chat for ${neutralCharacterName}.`, getCurrentChatId());
|
console.log(`Opened permanent assistant chat for ${neutralCharacterName}.`, getCurrentChatId());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error opening permanent assistant chat:', error);
|
console.error('Error opening permanent assistant chat:', error);
|
||||||
|
Reference in New Issue
Block a user