Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/sse/handlers/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ async function handleSingleModelChat(body, modelStr, clientRawRequest = null, re
while (true) {
const credentials = await getProviderCredentials(provider, excludeConnectionIds, model);

// If the model is a bare name (no "/" — e.g. "auto" resolved from a connection alias),
// and the connection has a defaultModel, use that so the upstream receives a real model ID
let effectiveModel = model;
if (!modelStr.includes("/") && credentials?.defaultModel) {
effectiveModel = credentials.defaultModel;
}

// All accounts unavailable
if (!credentials || credentials.allRateLimited) {
if (credentials?.allRateLimited) {
Expand Down Expand Up @@ -201,8 +208,8 @@ async function handleSingleModelChat(body, modelStr, clientRawRequest = null, re
const chatSettings = await getSettings();
const providerThinking = (chatSettings.providerThinking || {})[provider] || null;
const result = await handleChatCore({
body: { ...body, model: `${provider}/${model}` },
modelInfo: { provider, model },
body: { ...body, model: `${provider}/${effectiveModel}` },
modelInfo: { provider, model: effectiveModel },
credentials: refreshedCredentials,
log,
clientRawRequest,
Expand Down
10 changes: 8 additions & 2 deletions src/sse/handlers/embeddings.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ export async function handleEmbeddings(request) {
while (true) {
const credentials = await getProviderCredentials(provider, excludeConnectionIds, model);

// If the model is a bare name and the connection has a defaultModel, use that
let effectiveModel = model;
if (!modelStr.includes("/") && credentials?.defaultModel) {
effectiveModel = credentials.defaultModel;
}

// All accounts unavailable
if (!credentials || credentials.allRateLimited) {
if (credentials?.allRateLimited) {
Expand All @@ -108,8 +114,8 @@ export async function handleEmbeddings(request) {
const refreshedCredentials = await checkAndRefreshToken(provider, credentials);

const result = await handleEmbeddingsCore({
body: { ...body, model: `${provider}/${model}` },
modelInfo: { provider, model },
body: { ...body, model: `${provider}/${effectiveModel}` },
modelInfo: { provider, model: effectiveModel },
credentials: refreshedCredentials,
log,
onCredentialsRefreshed: async (newCreds) => {
Expand Down
1 change: 1 addition & 0 deletions src/sse/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export async function getProviderCredentials(provider, excludeConnectionIds = nu
projectId: connection.projectId,
connectionName: connection.displayName || connection.name || connection.email || connection.id,
copilotToken: connection.providerSpecificData?.copilotToken,
defaultModel: connection.defaultModel || null,
providerSpecificData: {
...(connection.providerSpecificData || {}),
connectionProxyEnabled: resolvedProxy.connectionProxyEnabled,
Expand Down