feat(tui): pass modelRouter to both TUI modes
This commit is contained in:
+32
-17
@@ -19,6 +19,8 @@ function createModelRouter(config: Config): ModelRouter {
|
|||||||
|
|
||||||
const defaultClient = new AnthropicClient({
|
const defaultClient = new AnthropicClient({
|
||||||
model: models.default.model,
|
model: models.default.model,
|
||||||
|
apiKey: models.default.api_key,
|
||||||
|
authToken: models.default.auth_token,
|
||||||
});
|
});
|
||||||
|
|
||||||
let fastClient;
|
let fastClient;
|
||||||
@@ -26,11 +28,19 @@ function createModelRouter(config: Config): ModelRouter {
|
|||||||
let localClient;
|
let localClient;
|
||||||
|
|
||||||
if (models.fast) {
|
if (models.fast) {
|
||||||
fastClient = new AnthropicClient({ model: models.fast.model });
|
fastClient = new AnthropicClient({
|
||||||
|
model: models.fast.model,
|
||||||
|
apiKey: models.fast.api_key,
|
||||||
|
authToken: models.fast.auth_token,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (models.complex) {
|
if (models.complex) {
|
||||||
complexClient = new AnthropicClient({ model: models.complex.model });
|
complexClient = new AnthropicClient({
|
||||||
|
model: models.complex.model,
|
||||||
|
apiKey: models.complex.api_key,
|
||||||
|
authToken: models.complex.auth_token,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (models.local) {
|
if (models.local) {
|
||||||
@@ -100,15 +110,19 @@ async function main() {
|
|||||||
await startFullscreenTui({
|
await startFullscreenTui({
|
||||||
session,
|
session,
|
||||||
modelClient: modelRouter,
|
modelClient: modelRouter,
|
||||||
|
modelRouter,
|
||||||
systemPrompt: SYSTEM_PROMPT,
|
systemPrompt: SYSTEM_PROMPT,
|
||||||
model: config.models.default.model,
|
model: config.models.default.model,
|
||||||
onExit: cleanup,
|
onExit: cleanup,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Start minimal readline UI
|
// Start minimal readline UI
|
||||||
|
let switchingToFullscreen = false;
|
||||||
|
|
||||||
const tui = new MinimalTui({
|
const tui = new MinimalTui({
|
||||||
session,
|
session,
|
||||||
modelClient: modelRouter,
|
modelClient: modelRouter,
|
||||||
|
modelRouter,
|
||||||
systemPrompt: SYSTEM_PROMPT,
|
systemPrompt: SYSTEM_PROMPT,
|
||||||
onTransfer: (target) => {
|
onTransfer: (target) => {
|
||||||
if (target === 'telegram') {
|
if (target === 'telegram') {
|
||||||
@@ -119,25 +133,26 @@ async function main() {
|
|||||||
console.log(`Unknown transfer target: ${target}\n`);
|
console.log(`Unknown transfer target: ${target}\n`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onFullscreen: async () => {
|
onFullscreen: () => {
|
||||||
tui.stop();
|
switchingToFullscreen = true;
|
||||||
console.clear();
|
tui.stop(true); // Preserve stdin for fullscreen mode
|
||||||
await startFullscreenTui({
|
|
||||||
session,
|
|
||||||
modelClient: modelRouter,
|
|
||||||
systemPrompt: SYSTEM_PROMPT,
|
|
||||||
model: config.models.default.model,
|
|
||||||
onExit: () => {
|
|
||||||
// Return to minimal mode would require re-init
|
|
||||||
// For now, just exit
|
|
||||||
cleanup();
|
|
||||||
process.exit(0);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await tui.start();
|
await tui.start();
|
||||||
|
|
||||||
|
if (switchingToFullscreen) {
|
||||||
|
console.clear();
|
||||||
|
await startFullscreenTui({
|
||||||
|
session,
|
||||||
|
modelClient: modelRouter,
|
||||||
|
modelRouter,
|
||||||
|
systemPrompt: SYSTEM_PROMPT,
|
||||||
|
model: config.models.default.model,
|
||||||
|
onExit: cleanup,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|||||||
Reference in New Issue
Block a user