add claude code model selection (opus, sonnet, haiku)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -104,13 +104,14 @@ export async function sendAndAwait(params: SendAndAwaitParams): Promise<SendAndA
|
||||
const override = channelModelOverrides.get(sessionId);
|
||||
const resolvedModel = params.model ?? override ?? (await getUserDefaultModel(params.userId)) ?? DEFAULT_MODEL;
|
||||
|
||||
if (resolvedModel === 'claude-code') {
|
||||
if (resolvedModel.startsWith('claude-code')) {
|
||||
return await sendClaudeCode({
|
||||
userId: params.userId,
|
||||
email: params.email,
|
||||
username: params.username,
|
||||
prompt: params.prompt,
|
||||
sessionKey: sessionId,
|
||||
model: resolvedModel,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ type ClaudeCodeParams = {
|
||||
username: string;
|
||||
prompt: string;
|
||||
sessionKey: string;
|
||||
model?: string;
|
||||
};
|
||||
|
||||
type ClaudeCodeResult = {
|
||||
@@ -151,6 +152,9 @@ export async function sendClaudeCode(params: ClaudeCodeParams): Promise<ClaudeCo
|
||||
|
||||
const claudeArgs = [CLAUDE_BIN, '-p', prompt, '--dangerously-skip-permissions', '--output-format', 'json'];
|
||||
|
||||
const subModel = params.model?.split('/')[1];
|
||||
if (subModel) claudeArgs.push('--model', subModel);
|
||||
|
||||
const existingSession = claudeCodeSessions.get(sessionKey);
|
||||
if (existingSession) {
|
||||
claudeArgs.push('--resume', existingSession);
|
||||
@@ -268,6 +272,7 @@ type ClaudeCodeStreamingParams = {
|
||||
prompt: string;
|
||||
sessionKey: string;
|
||||
cwd?: string;
|
||||
model?: string;
|
||||
onEvent: (event: PiEvent) => void;
|
||||
};
|
||||
|
||||
@@ -293,6 +298,9 @@ export async function sendClaudeCodeStreaming(params: ClaudeCodeStreamingParams)
|
||||
'--include-partial-messages',
|
||||
];
|
||||
|
||||
const subModel = params.model?.split('/')[1];
|
||||
if (subModel) claudeArgs.push('--model', subModel);
|
||||
|
||||
const existingSession = claudeCodeSessions.get(sessionKey);
|
||||
if (existingSession) {
|
||||
claudeArgs.push('--resume', existingSession);
|
||||
|
||||
Reference in New Issue
Block a user