mirror of
https://github.com/lone-cloud/gerbil
synced 2026-06-03 19:54:44 -07:00
more sillytavern integration fixes
This commit is contained in:
parent
6597d1f417
commit
c00b97a3f6
5 changed files with 39 additions and 38 deletions
|
|
@ -55,7 +55,7 @@
|
||||||
"@eslint/js": "^9.34.0",
|
"@eslint/js": "^9.34.0",
|
||||||
"@types/node": "^24.3.0",
|
"@types/node": "^24.3.0",
|
||||||
"@types/react": "^19.1.12",
|
"@types/react": "^19.1.12",
|
||||||
"@types/react-dom": "^19.1.8",
|
"@types/react-dom": "^19.1.9",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.41.0",
|
"@typescript-eslint/eslint-plugin": "^8.41.0",
|
||||||
"@typescript-eslint/parser": "^8.41.0",
|
"@typescript-eslint/parser": "^8.41.0",
|
||||||
"@vitejs/plugin-react": "^5.0.2",
|
"@vitejs/plugin-react": "^5.0.2",
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ export const ServerTab = ({
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack align="center" gap="md">
|
<Stack align="center" gap="md" mt="xl">
|
||||||
<Text c="dimmed" size="lg">
|
<Text c="dimmed" size="lg">
|
||||||
Waiting for the KoboldCpp server to start...
|
Waiting for the KoboldCpp server to start...
|
||||||
</Text>
|
</Text>
|
||||||
|
|
|
||||||
|
|
@ -43,13 +43,18 @@ export class IPCHandlers {
|
||||||
error?: string;
|
error?: string;
|
||||||
}> {
|
}> {
|
||||||
try {
|
try {
|
||||||
|
const finalArgs = [...args];
|
||||||
const frontendPreference = (await this.configManager.get(
|
const frontendPreference = (await this.configManager.get(
|
||||||
'frontendPreference'
|
'frontendPreference'
|
||||||
)) as FrontendPreference | undefined;
|
)) as FrontendPreference | undefined;
|
||||||
|
|
||||||
|
if (frontendPreference !== 'koboldcpp' && !finalArgs.includes('--cli')) {
|
||||||
|
finalArgs.push('--cli');
|
||||||
|
}
|
||||||
|
|
||||||
if (frontendPreference === 'sillytavern') {
|
if (frontendPreference === 'sillytavern') {
|
||||||
try {
|
try {
|
||||||
await this.sillyTavernManager.startFrontend(args);
|
await this.sillyTavernManager.startFrontend(finalArgs);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logManager.logError(
|
this.logManager.logError(
|
||||||
'Failed to setup SillyTavern:',
|
'Failed to setup SillyTavern:',
|
||||||
|
|
@ -58,7 +63,7 @@ export class IPCHandlers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.koboldManager.launchKoboldCpp(args);
|
return await this.koboldManager.launchKoboldCpp(finalArgs);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logManager.logError('Error in enhanced launch:', error as Error);
|
this.logManager.logError('Error in enhanced launch:', error as Error);
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,17 @@ export class SillyTavernManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getSillyTavernBaseArgs(): string[] {
|
||||||
|
return [
|
||||||
|
'sillytavern',
|
||||||
|
'--listen',
|
||||||
|
'--browserLaunchEnabled',
|
||||||
|
'false',
|
||||||
|
'--securityOverride',
|
||||||
|
'true',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
async isNpxAvailable(): Promise<boolean> {
|
async isNpxAvailable(): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const testProcess = spawn('npx', ['--version'], { stdio: 'pipe' });
|
const testProcess = spawn('npx', ['--version'], { stdio: 'pipe' });
|
||||||
|
|
@ -114,7 +125,7 @@ export class SillyTavernManager {
|
||||||
'SillyTavern settings not found, starting SillyTavern briefly to generate config...'
|
'SillyTavern settings not found, starting SillyTavern briefly to generate config...'
|
||||||
);
|
);
|
||||||
|
|
||||||
const spawnArgs = ['sillytavern', '--browserLaunchEnabled', 'false'];
|
const spawnArgs = this.getSillyTavernBaseArgs();
|
||||||
|
|
||||||
this.windowManager.sendKoboldOutput(
|
this.windowManager.sendKoboldOutput(
|
||||||
`Running command: npx ${spawnArgs.join(' ')}`
|
`Running command: npx ${spawnArgs.join(' ')}`
|
||||||
|
|
@ -143,7 +154,7 @@ export class SillyTavernManager {
|
||||||
initProcess.kill('SIGTERM');
|
initProcess.kill('SIGTERM');
|
||||||
}
|
}
|
||||||
cleanupAndResolve();
|
cleanupAndResolve();
|
||||||
}, 20000);
|
}, 90000);
|
||||||
|
|
||||||
initProcess.on('exit', (code: number | null, signal: string | null) => {
|
initProcess.on('exit', (code: number | null, signal: string | null) => {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
|
|
@ -156,6 +167,7 @@ export class SillyTavernManager {
|
||||||
|
|
||||||
initProcess.on('error', (error) => {
|
initProcess.on('error', (error) => {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
|
|
||||||
if (!hasResolved) {
|
if (!hasResolved) {
|
||||||
hasResolved = true;
|
hasResolved = true;
|
||||||
this.logManager.logError(
|
this.logManager.logError(
|
||||||
|
|
@ -172,9 +184,7 @@ export class SillyTavernManager {
|
||||||
if (initProcess.stdout) {
|
if (initProcess.stdout) {
|
||||||
initProcess.stdout.on('data', (data: Buffer) => {
|
initProcess.stdout.on('data', (data: Buffer) => {
|
||||||
const output = data.toString();
|
const output = data.toString();
|
||||||
this.windowManager.sendKoboldOutput(
|
|
||||||
`[SillyTavern stdout]: ${output.trim()}`
|
|
||||||
);
|
|
||||||
if (output.includes('SillyTavern is listening')) {
|
if (output.includes('SillyTavern is listening')) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!initProcess.killed && !hasResolved) {
|
if (!initProcess.killed && !hasResolved) {
|
||||||
|
|
@ -189,21 +199,17 @@ export class SillyTavernManager {
|
||||||
if (initProcess.stderr) {
|
if (initProcess.stderr) {
|
||||||
initProcess.stderr.on('data', (data: Buffer) => {
|
initProcess.stderr.on('data', (data: Buffer) => {
|
||||||
const output = data.toString();
|
const output = data.toString();
|
||||||
this.windowManager.sendKoboldOutput(
|
this.windowManager.sendKoboldOutput(output.trim());
|
||||||
`[SillyTavern stderr]: ${output.trim()}`
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!initProcess.killed && !hasResolved) {
|
if (!initProcess.killed && !hasResolved) {
|
||||||
this.windowManager.sendKoboldOutput(
|
this.windowManager.sendKoboldOutput(
|
||||||
'SillyTavern initialization taking longer than expected, proceeding...'
|
'SillyTavern initialization taking longer than expected, please wait...'
|
||||||
);
|
);
|
||||||
initProcess.kill('SIGTERM');
|
|
||||||
cleanupAndResolve();
|
|
||||||
}
|
}
|
||||||
}, 10000);
|
}, 30000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -329,17 +335,13 @@ export class SillyTavernManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultSillyTavernConfig(): SillyTavernConfig {
|
async startFrontend(args: string[]): Promise<void> {
|
||||||
return {
|
try {
|
||||||
|
const config = {
|
||||||
name: 'sillytavern',
|
name: 'sillytavern',
|
||||||
port: SILLYTAVERN.PORT,
|
port: SILLYTAVERN.PORT,
|
||||||
proxyPort: SILLYTAVERN.PROXY_PORT,
|
proxyPort: SILLYTAVERN.PROXY_PORT,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
async startFrontend(args: string[]): Promise<void> {
|
|
||||||
try {
|
|
||||||
const config = this.getDefaultSillyTavernConfig();
|
|
||||||
const { host: koboldHost, port: koboldPort } =
|
const { host: koboldHost, port: koboldPort } =
|
||||||
this.parseKoboldConfig(args);
|
this.parseKoboldConfig(args);
|
||||||
|
|
||||||
|
|
@ -357,14 +359,9 @@ export class SillyTavernManager {
|
||||||
);
|
);
|
||||||
|
|
||||||
const sillyTavernArgs = [
|
const sillyTavernArgs = [
|
||||||
'sillytavern',
|
...this.getSillyTavernBaseArgs(),
|
||||||
'--port',
|
'--port',
|
||||||
config.port.toString(),
|
config.port.toString(),
|
||||||
'--listen',
|
|
||||||
'--browserLaunchEnabled',
|
|
||||||
'false',
|
|
||||||
'--dataRoot',
|
|
||||||
this.getSillyTavernSettingsPath().replace('/settings.json', ''),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
this.sillyTavernProcess = spawn('npx', sillyTavernArgs, {
|
this.sillyTavernProcess = spawn('npx', sillyTavernArgs, {
|
||||||
|
|
@ -381,8 +378,7 @@ export class SillyTavernManager {
|
||||||
|
|
||||||
if (this.sillyTavernProcess.stderr) {
|
if (this.sillyTavernProcess.stderr) {
|
||||||
this.sillyTavernProcess.stderr.on('data', (data: Buffer) => {
|
this.sillyTavernProcess.stderr.on('data', (data: Buffer) => {
|
||||||
const output = data.toString();
|
this.windowManager.sendKoboldOutput(data.toString(), true);
|
||||||
this.windowManager.sendKoboldOutput(output, true);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
10
yarn.lock
10
yarn.lock
|
|
@ -1324,12 +1324,12 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@types/react-dom@npm:^19.1.8":
|
"@types/react-dom@npm:^19.1.9":
|
||||||
version: 19.1.8
|
version: 19.1.9
|
||||||
resolution: "@types/react-dom@npm:19.1.8"
|
resolution: "@types/react-dom@npm:19.1.9"
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
"@types/react": ^19.0.0
|
"@types/react": ^19.0.0
|
||||||
checksum: 10c0/561f9679c99e93adba8ecdf7d5ad69cc9d5e35837fa996246a83713f0ce498fc5b871f9a2a3342c7d440fc02159abe10f29c4a4004527d5d38b2e84f21840793
|
checksum: 10c0/34c8dda86c1590b3ef0e7ecd38f9663a66ba2dd69113ba74fb0adc36b83bbfb8c94c1487a2505282a5f7e5e000d2ebf36f4c0fd41b3b672f5178fd1d4f1f8f58
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|
@ -3603,7 +3603,7 @@ __metadata:
|
||||||
"@mantine/hooks": "npm:^8.2.7"
|
"@mantine/hooks": "npm:^8.2.7"
|
||||||
"@types/node": "npm:^24.3.0"
|
"@types/node": "npm:^24.3.0"
|
||||||
"@types/react": "npm:^19.1.12"
|
"@types/react": "npm:^19.1.12"
|
||||||
"@types/react-dom": "npm:^19.1.8"
|
"@types/react-dom": "npm:^19.1.9"
|
||||||
"@typescript-eslint/eslint-plugin": "npm:^8.41.0"
|
"@typescript-eslint/eslint-plugin": "npm:^8.41.0"
|
||||||
"@typescript-eslint/parser": "npm:^8.41.0"
|
"@typescript-eslint/parser": "npm:^8.41.0"
|
||||||
"@vitejs/plugin-react": "npm:^5.0.2"
|
"@vitejs/plugin-react": "npm:^5.0.2"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue