fix: align tui editor with pi-tui API
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Api, Model, OpenAICompat } from "@mariozechner/pi-ai";
|
||||
import type { Api, Model, OpenAICompletionsCompat } from "@mariozechner/pi-ai";
|
||||
|
||||
function isOpenAiCompletionsModel(model: Model<Api>): model is Model<"openai-completions"> {
|
||||
return model.api === "openai-completions";
|
||||
@@ -10,7 +10,7 @@ export function normalizeModelCompat(model: Model<Api>): Model<Api> {
|
||||
if (!isZai || !isOpenAiCompletionsModel(model)) return model;
|
||||
|
||||
const openaiModel = model as Model<"openai-completions">;
|
||||
const compat = openaiModel.compat as OpenAICompat | undefined;
|
||||
const compat = openaiModel.compat as OpenAICompletionsCompat | undefined;
|
||||
if (compat?.supportsDeveloperRole === false) return model;
|
||||
|
||||
openaiModel.compat = compat
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
Editor,
|
||||
type EditorTheme,
|
||||
Key,
|
||||
matchesKey,
|
||||
} from "@mariozechner/pi-tui";
|
||||
import { Editor, type EditorTheme, type TUI, Key, matchesKey } from "@mariozechner/pi-tui";
|
||||
|
||||
export class CustomEditor extends Editor {
|
||||
onEscape?: () => void;
|
||||
@@ -17,8 +12,8 @@ export class CustomEditor extends Editor {
|
||||
onShiftTab?: () => void;
|
||||
onAltEnter?: () => void;
|
||||
|
||||
constructor(theme: EditorTheme) {
|
||||
super(theme);
|
||||
constructor(tui: TUI, theme: EditorTheme) {
|
||||
super(tui, theme);
|
||||
}
|
||||
handleInput(data: string): void {
|
||||
if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) {
|
||||
|
||||
@@ -193,7 +193,7 @@ export async function runTui(opts: TuiOptions) {
|
||||
const statusContainer = new Container();
|
||||
const footer = new Text("", 1, 0);
|
||||
const chatLog = new ChatLog();
|
||||
const editor = new CustomEditor(editorTheme);
|
||||
const editor = new CustomEditor(tui, editorTheme);
|
||||
const root = new Container();
|
||||
root.addChild(header);
|
||||
root.addChild(chatLog);
|
||||
|
||||
Reference in New Issue
Block a user