Telegram: fix /think command to show current level when no arg
This commit is contained in:
@@ -309,6 +309,7 @@ export async function handleDirectiveOnly(params: {
|
||||
model: string;
|
||||
initialModelLabel: string;
|
||||
formatModelSwitchEvent: (label: string, alias?: string) => string;
|
||||
currentThinkLevel?: ThinkLevel;
|
||||
}): Promise<ReplyPayload | undefined> {
|
||||
const {
|
||||
directives,
|
||||
@@ -326,6 +327,7 @@ export async function handleDirectiveOnly(params: {
|
||||
resetModelOverride,
|
||||
initialModelLabel,
|
||||
formatModelSwitchEvent,
|
||||
currentThinkLevel,
|
||||
} = params;
|
||||
|
||||
if (directives.hasModelDirective) {
|
||||
@@ -379,8 +381,13 @@ export async function handleDirectiveOnly(params: {
|
||||
}
|
||||
|
||||
if (directives.hasThinkDirective && !directives.thinkLevel) {
|
||||
// If no argument was provided, show the current level
|
||||
if (!directives.rawThinkLevel) {
|
||||
const level = currentThinkLevel ?? "off";
|
||||
return { text: `Current thinking level: ${level}.` };
|
||||
}
|
||||
return {
|
||||
text: `Unrecognized thinking level "${directives.rawThinkLevel ?? ""}". Valid levels: off, minimal, low, medium, high.`,
|
||||
text: `Unrecognized thinking level "${directives.rawThinkLevel}". Valid levels: off, minimal, low, medium, high.`,
|
||||
};
|
||||
}
|
||||
if (directives.hasVerboseDirective && !directives.verboseLevel) {
|
||||
|
||||
@@ -16,9 +16,9 @@ export function extractThinkDirective(body?: string): {
|
||||
hasDirective: boolean;
|
||||
} {
|
||||
if (!body) return { cleaned: "", hasDirective: false };
|
||||
// Match the longest keyword first to avoid partial captures (e.g. "/think:high")
|
||||
// Match with optional argument - require word boundary via lookahead after keyword
|
||||
const match = body.match(
|
||||
/(?:^|\s)\/(?:thinking|think|t)\s*:?\s*([a-zA-Z-]+)\b/i,
|
||||
/(?:^|\s)\/(?:thinking|think|t)(?=$|\s|:)(?:\s*:?\s*([a-zA-Z-]+)\b)?/i,
|
||||
);
|
||||
const thinkLevel = normalizeThinkLevel(match?.[1]);
|
||||
const cleaned = match
|
||||
|
||||
Reference in New Issue
Block a user