Skip to content

Commit 72ecee5

Browse files
committed
fix: include embedding models in models tab and add playground redirect in configure modal
- Include embedding models in useFetchLlamaModels on Models tab - Add redirectToPlayground to ChatbotConfigurationModal in VectorStoreTableRow.tsx - Move computeEmbeddingModelStatus and reuse in Configuration modal - Update tests
1 parent 5a1fdad commit 72ecee5

5 files changed

Lines changed: 60 additions & 46 deletions

File tree

packages/gen-ai/frontend/src/app/AIAssets/AIAssetsModelsTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import useAiAssetCustomEndpointsEnabled from '~/app/hooks/useAiAssetCustomEndpoi
1313

1414
const AIAssetsModelsTab: React.FC = () => {
1515
const { namespace } = React.useContext(GenAiContext);
16-
const { data: playgroundModels } = useFetchLlamaModels();
16+
const { data: playgroundModels } = useFetchLlamaModels(undefined, true);
1717

1818
const { models, loaded, aiError, maasError, refresh } = useMergedModels();
1919
const { data: lsdStatus } = useFetchLSDStatus();

packages/gen-ai/frontend/src/app/AIAssets/components/vectorstores/VectorStoreTableRow.tsx

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,13 @@ import {
1616
LlamaStackDistributionModel,
1717
VectorStore,
1818
} from '~/app/types';
19-
import { splitLlamaModelId } from '~/app/utilities/utils';
19+
import { computeEmbeddingModelStatus } from '~/app/utilities/utils';
2020
import { GenAiContext } from '~/app/context/GenAiContext';
2121
import { genAiChatPlaygroundRoute } from '~/app/utilities/routes';
2222
import ChatbotConfigurationModal from '~/app/Chatbot/components/chatbotConfiguration/ChatbotConfigurationModal';
2323
import VectorStoreTableRowInfo from './VectorStoreTableRowInfo';
2424

25-
export type EmbeddingModelStatus = 'not_available' | 'available' | 'registered';
26-
27-
export const computeEmbeddingModelStatus = (
28-
embeddingModel: string,
29-
allModels: AIModel[],
30-
playgroundModels: LlamaModel[],
31-
): EmbeddingModelStatus => {
32-
const { id: normalizedId } = splitLlamaModelId(embeddingModel);
33-
34-
// "registered": embedding model is in the LlamaStack playground.
35-
// playgroundModels[].modelId is already normalized via splitLlamaModelId.
36-
const isRegistered = playgroundModels.some(
37-
(m) => m.modelId === embeddingModel || m.modelId === normalizedId,
38-
);
39-
if (isRegistered) {
40-
return 'registered';
41-
}
42-
43-
// "available": embedding model exists in the unified AI Assets models list (AAE + MaaS).
44-
// Normalize both sides to handle provider-prefixed vs plain IDs.
45-
const isAvailable = allModels.some((m) => {
46-
const { id: normalizedModelId } = splitLlamaModelId(m.model_id);
47-
return m.model_id === embeddingModel || normalizedModelId === normalizedId;
48-
});
49-
if (isAvailable) {
50-
return 'available';
51-
}
52-
53-
return 'not_available';
54-
};
25+
export type { EmbeddingModelStatus } from '~/app/utilities/utils';
5526

5627
interface VectorStoreTableRowProps {
5728
store: ExternalVectorStoreSummary;
@@ -174,6 +145,7 @@ const VectorStoreTableRow: React.FC<VectorStoreTableRowProps> = ({
174145
existingCollections={existingCollections}
175146
extraSelectedCollections={[store]}
176147
initialStepId="collections"
148+
redirectToPlayground
177149
/>
178150
)}
179151
</>

packages/gen-ai/frontend/src/app/AIAssets/components/vectorstores/__tests__/computeEmbeddingModelStatus.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
/* eslint-disable camelcase */
22
import type { AIModel, LlamaModel } from '~/app/types';
3-
import {
4-
computeEmbeddingModelStatus,
5-
EmbeddingModelStatus,
6-
} from '~/app/AIAssets/components/vectorstores/VectorStoreTableRow';
3+
import { computeEmbeddingModelStatus, EmbeddingModelStatus } from '~/app/utilities/utils';
74

85
const makeAIModel = (model_id: string, overrides: Partial<AIModel> = {}): AIModel => ({
96
model_name: 'test',

packages/gen-ai/frontend/src/app/Chatbot/components/chatbotConfiguration/ChatbotConfigurationModal.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import {
2222
MaaSModel,
2323
VectorStore,
2424
} from '~/app/types';
25-
import { convertMaaSModelToAIModel, splitLlamaModelId } from '~/app/utilities/utils';
25+
import {
26+
computeEmbeddingModelStatus,
27+
convertMaaSModelToAIModel,
28+
splitLlamaModelId,
29+
} from '~/app/utilities/utils';
2630
import { useGenAiAPI } from '~/app/hooks/useGenAiAPI';
2731
import useGuardrailsEnabled from '~/app/Chatbot/hooks/useGuardrailsEnabled';
2832
import useAiAssetVectorStoresEnabled from '~/app/hooks/useAiAssetVectorStoresEnabled';
@@ -137,14 +141,12 @@ const ChatbotConfigurationModal: React.FC<ChatbotConfigurationModalProps> = ({
137141

138142
const availableCollections = React.useMemo(
139143
() =>
140-
allCollections.filter((c) => {
141-
const { id: normalizedEmbedId } = splitLlamaModelId(c.embedding_model);
142-
return allModels.some((m) => {
143-
const { id: normalizedModelId } = splitLlamaModelId(m.model_id);
144-
return m.model_id === c.embedding_model || normalizedModelId === normalizedEmbedId;
145-
});
146-
}),
147-
[allCollections, allModels],
144+
allCollections.filter(
145+
(c) =>
146+
computeEmbeddingModelStatus(c.embedding_model, allModels, existingModels) !==
147+
'not_available',
148+
),
149+
[allCollections, allModels, existingModels],
148150
);
149151

150152
const preSelectedCollections = React.useMemo(() => {

packages/gen-ai/frontend/src/app/utilities/utils.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
/* eslint-disable camelcase */
22
import { K8sResourceCommon } from 'mod-arch-shared';
33
import { fireMiscTrackingEvent } from '@odh-dashboard/internal/concepts/analyticsTracking/segmentIOUtils';
4-
import { AIModel, TokenInfo, MCPServerFromAPI, MCPServerConfig, MaaSModel } from '~/app/types';
4+
import {
5+
AIModel,
6+
LlamaModel,
7+
TokenInfo,
8+
MCPServerFromAPI,
9+
MCPServerConfig,
10+
MaaSModel,
11+
} from '~/app/types';
512

613
/**
714
* Generates a UUID v4 string
@@ -244,3 +251,39 @@ export const copyToClipboardWithTracking = async (
244251
// Do nothing
245252
}
246253
};
254+
255+
export type EmbeddingModelStatus = 'not_available' | 'available' | 'registered';
256+
257+
/**
258+
* Determines whether a vector store's embedding model is available for use.
259+
* - 'registered': the model is already registered and running in the LlamaStack Distribution (LSD).
260+
* - 'available': the model exists in AI Assets or MaaS but is not yet installed in the LSD.
261+
* - 'not_available': the model is unknown — the vector store cannot be used.
262+
*
263+
* @param assetModels - AI Assets + MaaS models (candidates that can be installed into the LSD)
264+
* @param playgroundModels - models currently registered in the LSD (referred to as lsdModels elsewhere)
265+
*/
266+
export const computeEmbeddingModelStatus = (
267+
embeddingModel: string,
268+
assetModels: AIModel[],
269+
playgroundModels: LlamaModel[],
270+
): EmbeddingModelStatus => {
271+
const { id: normalizedId } = splitLlamaModelId(embeddingModel);
272+
273+
const isRegistered = playgroundModels.some(
274+
(m) => m.modelId === embeddingModel || m.modelId === normalizedId,
275+
);
276+
if (isRegistered) {
277+
return 'registered';
278+
}
279+
280+
const isAvailable = assetModels.some((m) => {
281+
const { id: normalizedModelId } = splitLlamaModelId(m.model_id);
282+
return m.model_id === embeddingModel || normalizedModelId === normalizedId;
283+
});
284+
if (isAvailable) {
285+
return 'available';
286+
}
287+
288+
return 'not_available';
289+
};

0 commit comments

Comments
 (0)