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