This commit is contained in:
2026-02-25 16:04:11 +00:00
parent 05c5b648fa
commit b6a0a57893
11 changed files with 698 additions and 22 deletions
+10
View File
@@ -451,6 +451,16 @@ function writeRpcCommand(proc: Subprocess, command: Record<string, unknown>): vo
}
}
export function setThinkingLevel(
process: Subprocess,
level: string,
): void {
writeRpcCommand(process, {
type: 'set_thinking_level',
level,
});
}
export function sendPrompt(
process: Subprocess,
prompt: string,
+3
View File
@@ -39,6 +39,8 @@ export type GroupMeta = {
sessionCount: number;
};
export type ThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
export type ClientMessage =
| {
type: "chat";
@@ -50,6 +52,7 @@ export type ClientMessage =
sandboxed?: boolean;
groupSlug?: string;
attachmentIds?: string[];
thinking?: ThinkingLevel;
}
| {
type: "resume";
+6 -1
View File
@@ -244,7 +244,7 @@ function createEventHandler(sessionId: string, model: string, cwd: string, stora
async function handleChat(
ws: ServerWebSocket<WSData>,
msg: { prompt: string; sessionId?: string; model?: string; cwd?: string; cwdRoot?: string; sandboxed?: boolean; groupSlug?: string; attachmentIds?: string[] }
msg: { prompt: string; sessionId?: string; model?: string; cwd?: string; cwdRoot?: string; sandboxed?: boolean; groupSlug?: string; attachmentIds?: string[]; thinking?: string }
): Promise<void> {
const { email, username, userId } = ws.data;
const sessionId = msg.sessionId || randomUUID();
@@ -312,6 +312,11 @@ async function handleChat(
session.meta.title = msg.prompt.slice(0, 100);
}
// Set thinking level if provided
if (msg.thinking) {
piBridge.setThinkingLevel(session.piProcess, msg.thinking);
}
// Send prompt to Pi
const requestId = randomUUID();
session.isGenerating = true;
@@ -75,7 +75,7 @@ export async function syncLocalProvidersToPiConfig(): Promise<void> {
models: models.map(m => ({
id: m.id,
name: m.name || m.id,
reasoning: false,
reasoning: isReasoningModel(m.id),
input: ['text'],
contextWindow: m.contextWindow || 128000,
maxTokens: m.maxTokens || 4096,
@@ -94,6 +94,20 @@ export async function syncLocalProvidersToPiConfig(): Promise<void> {
}
}
/** Detect reasoning-capable models by name patterns */
const REASONING_PATTERNS = [
/\bqwen3\b/i,
/\bqwq\b/i,
/\bdeepseek-r1\b/i,
/\br1\b/i,
/\breasoning\b/i,
/\bthink/i,
];
function isReasoningModel(modelId: string): boolean {
return REASONING_PATTERNS.some(p => p.test(modelId));
}
async function fetchModelsFromLocalProvider(
lp: LocalProvider,
): Promise<{ id: string; name?: string; contextWindow?: number; maxTokens?: number }[]> {