mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-12 22:42:13 +02:00
refactor(onboarding, model-connections): enhance onboarding logic and streamline model connection handling by integrating chat model checks and improving state management
This commit is contained in:
parent
ab5423d2d2
commit
97f004e7e1
4 changed files with 97 additions and 130 deletions
|
|
@ -1,8 +1,29 @@
|
|||
export function isLlmOnboardingComplete(
|
||||
agentLlmId: number | null | undefined,
|
||||
hasGlobalConfigs: boolean
|
||||
): boolean {
|
||||
if (agentLlmId === null || agentLlmId === undefined) return false;
|
||||
if (agentLlmId === 0) return hasGlobalConfigs;
|
||||
return true;
|
||||
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))
|
||||
);
|
||||
}
|
||||
|
||||
export function isLlmOnboardingComplete(
|
||||
chatModelId: number | null | undefined,
|
||||
globalConnections: ConnectionRead[],
|
||||
searchSpaceConnections: ConnectionRead[]
|
||||
): boolean {
|
||||
const connections = [...globalConnections, ...searchSpaceConnections];
|
||||
const resolvedChatModelId = chatModelId ?? 0;
|
||||
|
||||
if (resolvedChatModelId === 0) {
|
||||
return hasEnabledChatModel(connections);
|
||||
}
|
||||
|
||||
return connections.some((connection) =>
|
||||
connection.models.some(
|
||||
(model) =>
|
||||
model.id === resolvedChatModelId && model.enabled && Boolean(model.supports_chat)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue