2026-06-13 20:48:24 +05:30
|
|
|
import type { ConnectionRead } from "@/contracts/types/model-connections.types";
|
|
|
|
|
|
|
|
|
|
export function hasEnabledChatModel(connections: ConnectionRead[]): boolean {
|
|
|
|
|
return connections.some(
|
|
|
|
|
(connection) =>
|
|
|
|
|
connection.enabled &&
|
|
|
|
|
connection.models.some((model) => model.enabled && Boolean(model.supports_chat))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-07 17:53:18 +05:30
|
|
|
export function isLlmOnboardingComplete(
|
2026-06-13 20:48:24 +05:30
|
|
|
chatModelId: number | null | undefined,
|
|
|
|
|
globalConnections: ConnectionRead[],
|
|
|
|
|
searchSpaceConnections: ConnectionRead[]
|
2026-06-07 17:53:18 +05:30
|
|
|
): boolean {
|
2026-06-13 20:48:24 +05:30
|
|
|
const connections = [...globalConnections, ...searchSpaceConnections];
|
|
|
|
|
const resolvedChatModelId = chatModelId ?? 0;
|
|
|
|
|
|
|
|
|
|
if (resolvedChatModelId === 0) {
|
|
|
|
|
return hasEnabledChatModel(connections);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return connections.some((connection) =>
|
|
|
|
|
connection.models.some(
|
2026-06-13 21:59:35 +05:30
|
|
|
(model) => model.id === resolvedChatModelId && model.enabled && Boolean(model.supports_chat)
|
2026-06-13 20:48:24 +05:30
|
|
|
)
|
|
|
|
|
);
|
2026-06-07 17:53:18 +05:30
|
|
|
}
|