Files
smartchat/ts_cli/smartchat.startchat.ts
T

35 lines
962 B
TypeScript
Raw Normal View History

import { React, h, render } from './plugins.js';
import type { LanguageModelV3, ToolSet } from './plugins.js';
import { ChatApp } from './components.chatapp.js';
export interface IStartChatOptions {
/** The language model to use */
model: LanguageModelV3;
/** System prompt for the agent */
system?: string;
/** Tools available to the agent */
tools?: ToolSet;
/** Maximum agentic steps per turn */
maxSteps?: number;
/** Display name for the model (shown in header/status) */
modelName?: string;
}
/**
* Start an interactive chat TUI in the terminal.
* Returns a promise that resolves when the user exits.
*/
export async function startChat(options: IStartChatOptions): Promise<void> {
const instance = render(
h(ChatApp, {
model: options.model,
system: options.system,
tools: options.tools,
maxSteps: options.maxSteps,
modelName: options.modelName,
}),
);
await instance.waitUntilExit();
}