From f959d787414d2581215f1aaad0244eaad9f765d7 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Tue, 10 Feb 2026 11:53:08 -0800 Subject: [PATCH] Fix azure anthropic --- apps/sim/app/api/copilot/chat/route.ts | 3 ++- apps/sim/lib/copilot/api.ts | 1 + apps/sim/lib/copilot/chat-payload.ts | 3 +++ apps/sim/stores/panel/copilot/store.ts | 9 +++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/sim/app/api/copilot/chat/route.ts b/apps/sim/app/api/copilot/chat/route.ts index 3fca3e32a..51568ed5f 100644 --- a/apps/sim/app/api/copilot/chat/route.ts +++ b/apps/sim/app/api/copilot/chat/route.ts @@ -50,7 +50,7 @@ const ChatMessageSchema = z.object({ stream: z.boolean().optional().default(true), implicitFeedback: z.string().optional(), fileAttachments: z.array(FileAttachmentSchema).optional(), - provider: z.string().optional().default('openai'), + provider: z.string().optional(), conversationId: z.string().optional(), contexts: z .array( @@ -205,6 +205,7 @@ export async function POST(req: NextRequest) { userMessageId: userMessageIdToUse, mode, model: selectedModel, + provider, conversationHistory, contexts: agentContexts, fileAttachments, diff --git a/apps/sim/lib/copilot/api.ts b/apps/sim/lib/copilot/api.ts index 06ac46b32..dd1bd8a0d 100644 --- a/apps/sim/lib/copilot/api.ts +++ b/apps/sim/lib/copilot/api.ts @@ -69,6 +69,7 @@ export interface SendMessageRequest { workflowId?: string mode?: CopilotMode | CopilotTransportMode model?: CopilotModelId + provider?: string prefetch?: boolean createNewChat?: boolean stream?: boolean diff --git a/apps/sim/lib/copilot/chat-payload.ts b/apps/sim/lib/copilot/chat-payload.ts index c4d92dae0..110dbfbc7 100644 --- a/apps/sim/lib/copilot/chat-payload.ts +++ b/apps/sim/lib/copilot/chat-payload.ts @@ -14,6 +14,7 @@ export interface BuildPayloadParams { userMessageId: string mode: string model: string + provider?: string conversationHistory?: unknown[] contexts?: Array<{ type: string; content: string }> fileAttachments?: Array<{ id: string; key: string; size: number; [key: string]: unknown }> @@ -58,6 +59,7 @@ export async function buildCopilotRequestPayload( userId, userMessageId, mode, + provider, contexts, fileAttachments, commands, @@ -146,6 +148,7 @@ export async function buildCopilotRequestPayload( workflowId, userId, model: selectedModel, + ...(provider ? { provider } : {}), mode: transportMode, messageId: userMessageId, version: SIM_AGENT_VERSION, diff --git a/apps/sim/stores/panel/copilot/store.ts b/apps/sim/stores/panel/copilot/store.ts index 01f81fb6d..d8684410d 100644 --- a/apps/sim/stores/panel/copilot/store.ts +++ b/apps/sim/stores/panel/copilot/store.ts @@ -299,6 +299,12 @@ type InitiateStreamResult = | { kind: 'success'; result: Awaited> } | { kind: 'error'; error: unknown } +/** Look up the provider for the currently selected model from the available models list. */ +function getSelectedProvider(get: CopilotGet): string | undefined { + const selectedModel = get().selectedModel + return get().availableModels.find((m) => m.id === selectedModel)?.provider +} + function prepareSendContext( get: CopilotGet, set: CopilotSet, @@ -489,6 +495,7 @@ async function initiateStream( workflowId: prepared.workflowId || undefined, mode: apiMode, model: get().selectedModel, + provider: getSelectedProvider(get), prefetch: get().agentPrefetch, createNewChat: !prepared.currentChat, stream: prepared.stream, @@ -866,6 +873,7 @@ async function resumeFromLiveStream( chatId: resume.nextStream.chatId || get().currentChat?.id || undefined, mode: get().mode === 'ask' ? 'ask' : get().mode === 'plan' ? 'plan' : 'agent', model: get().selectedModel, + provider: getSelectedProvider(get), prefetch: get().agentPrefetch, stream: true, resumeFromEventId: resume.resumeFromEventId, @@ -1437,6 +1445,7 @@ export const useCopilotStore = create()( workflowId, mode: apiMode, model: selectedModel, + provider: getSelectedProvider(get), prefetch: get().agentPrefetch, createNewChat: !currentChat, stream: true,