Thinking: gate xhigh by model
This commit is contained in:
committed by
Peter Steinberger
parent
f50e06a1b6
commit
a3641526ab
@@ -1,6 +1,9 @@
|
||||
import type { SlashCommand } from "@mariozechner/pi-tui";
|
||||
import {
|
||||
formatThinkingLevels,
|
||||
listThinkingLevels,
|
||||
} from "../auto-reply/thinking.js";
|
||||
|
||||
const THINK_LEVELS = ["off", "minimal", "low", "medium", "high"];
|
||||
const VERBOSE_LEVELS = ["on", "off"];
|
||||
const REASONING_LEVELS = ["on", "off"];
|
||||
const ELEVATED_LEVELS = ["on", "off"];
|
||||
@@ -12,6 +15,11 @@ export type ParsedCommand = {
|
||||
args: string;
|
||||
};
|
||||
|
||||
export type SlashCommandOptions = {
|
||||
provider?: string;
|
||||
model?: string;
|
||||
};
|
||||
|
||||
const COMMAND_ALIASES: Record<string, string> = {
|
||||
elev: "elevated",
|
||||
};
|
||||
@@ -27,7 +35,10 @@ export function parseCommand(input: string): ParsedCommand {
|
||||
};
|
||||
}
|
||||
|
||||
export function getSlashCommands(): SlashCommand[] {
|
||||
export function getSlashCommands(
|
||||
options: SlashCommandOptions = {},
|
||||
): SlashCommand[] {
|
||||
const thinkLevels = listThinkingLevels(options.provider, options.model);
|
||||
return [
|
||||
{ name: "help", description: "Show slash command help" },
|
||||
{ name: "status", description: "Show gateway status summary" },
|
||||
@@ -44,9 +55,9 @@ export function getSlashCommands(): SlashCommand[] {
|
||||
name: "think",
|
||||
description: "Set thinking level",
|
||||
getArgumentCompletions: (prefix) =>
|
||||
THINK_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map(
|
||||
(value) => ({ value, label: value }),
|
||||
),
|
||||
thinkLevels
|
||||
.filter((v) => v.startsWith(prefix.toLowerCase()))
|
||||
.map((value) => ({ value, label: value })),
|
||||
},
|
||||
{
|
||||
name: "verbose",
|
||||
@@ -105,7 +116,12 @@ export function getSlashCommands(): SlashCommand[] {
|
||||
];
|
||||
}
|
||||
|
||||
export function helpText(): string {
|
||||
export function helpText(options: SlashCommandOptions = {}): string {
|
||||
const thinkLevels = formatThinkingLevels(
|
||||
options.provider,
|
||||
options.model,
|
||||
"|",
|
||||
);
|
||||
return [
|
||||
"Slash commands:",
|
||||
"/help",
|
||||
@@ -113,7 +129,7 @@ export function helpText(): string {
|
||||
"/agent <id> (or /agents)",
|
||||
"/session <key> (or /sessions)",
|
||||
"/model <provider/model> (or /models)",
|
||||
"/think <off|minimal|low|medium|high>",
|
||||
`/think <${thinkLevels}>`,
|
||||
"/verbose <on|off>",
|
||||
"/reasoning <on|off>",
|
||||
"/cost <on|off>",
|
||||
|
||||
@@ -7,7 +7,10 @@ import {
|
||||
TUI,
|
||||
} from "@mariozechner/pi-tui";
|
||||
import { resolveDefaultAgentId } from "../agents/agent-scope.js";
|
||||
import { normalizeUsageDisplay } from "../auto-reply/thinking.js";
|
||||
import {
|
||||
formatThinkingLevels,
|
||||
normalizeUsageDisplay,
|
||||
} from "../auto-reply/thinking.js";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { formatAge } from "../infra/provider-summary.js";
|
||||
import {
|
||||
@@ -239,6 +242,18 @@ export async function runTui(opts: TuiOptions) {
|
||||
root.addChild(footer);
|
||||
root.addChild(editor);
|
||||
|
||||
const updateAutocompleteProvider = () => {
|
||||
editor.setAutocompleteProvider(
|
||||
new CombinedAutocompleteProvider(
|
||||
getSlashCommands({
|
||||
provider: sessionInfo.modelProvider,
|
||||
model: sessionInfo.model,
|
||||
}),
|
||||
process.cwd(),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
const tui = new TUI(new ProcessTerminal());
|
||||
tui.addChild(root);
|
||||
tui.setFocus(editor);
|
||||
@@ -524,6 +539,7 @@ export async function runTui(opts: TuiOptions) {
|
||||
} catch (err) {
|
||||
chatLog.addSystem(`sessions list failed: ${String(err)}`);
|
||||
}
|
||||
updateAutocompleteProvider();
|
||||
updateFooter();
|
||||
tui.requestRender();
|
||||
};
|
||||
@@ -861,7 +877,12 @@ export async function runTui(opts: TuiOptions) {
|
||||
if (!name) return;
|
||||
switch (name) {
|
||||
case "help":
|
||||
chatLog.addSystem(helpText());
|
||||
chatLog.addSystem(
|
||||
helpText({
|
||||
provider: sessionInfo.modelProvider,
|
||||
model: sessionInfo.model,
|
||||
}),
|
||||
);
|
||||
break;
|
||||
case "status":
|
||||
try {
|
||||
@@ -921,7 +942,12 @@ export async function runTui(opts: TuiOptions) {
|
||||
break;
|
||||
case "think":
|
||||
if (!args) {
|
||||
chatLog.addSystem("usage: /think <off|minimal|low|medium|high>");
|
||||
const levels = formatThinkingLevels(
|
||||
sessionInfo.modelProvider,
|
||||
sessionInfo.model,
|
||||
"|",
|
||||
);
|
||||
chatLog.addSystem(`usage: /think <${levels}>`);
|
||||
break;
|
||||
}
|
||||
try {
|
||||
@@ -1071,9 +1097,7 @@ export async function runTui(opts: TuiOptions) {
|
||||
tui.requestRender();
|
||||
};
|
||||
|
||||
editor.setAutocompleteProvider(
|
||||
new CombinedAutocompleteProvider(getSlashCommands(), process.cwd()),
|
||||
);
|
||||
updateAutocompleteProvider();
|
||||
editor.onSubmit = (text) => {
|
||||
const value = text.trim();
|
||||
editor.setText("");
|
||||
|
||||
Reference in New Issue
Block a user