Skip to content

Commit

Permalink
[Search] Fixes a bug where third-party models could not be saved (#18…
Browse files Browse the repository at this point in the history
…9098)

## Summary

This enables saving a third-party model mappings in the UI with semantic
text.
  • Loading branch information
sphilipse authored Jul 25, 2024
1 parent 631baa3 commit fb34fc7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -789,5 +789,5 @@ export const getFieldByPathName = (fields: NormalizedFields, name: string) => {
export function isLocalModel(
model: InferenceServiceSettings
): model is LocalInferenceServiceSettings {
return Boolean((model as LocalInferenceServiceSettings).service_settings.model_id);
return ['elser', 'elasticsearch'].includes((model as LocalInferenceServiceSettings).service);
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export const DetailsPageMappingsContent: FunctionComponent<{
.map((field) => field.inference_id)
.filter(
(inferenceId: string) =>
state.inferenceToModelIdMap?.[inferenceId] &&
state.inferenceToModelIdMap?.[inferenceId].trainedModelId && // third-party inference models don't have trainedModelId
!state.inferenceToModelIdMap?.[inferenceId].isDeployed
);
setHasSavedFields(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,14 @@ export function TrainedModelsDeploymentModal({
useEffect(() => {
const models = inferenceIdsInPendingList.map(
(inferenceId) => inferenceToModelIdMap?.[inferenceId]
);
); // filter out third-party models
for (const model of models) {
if (model && !model.isDownloading && !model.isDeployed) {
if (
model?.trainedModelId &&
model.isDeployable &&
!model.isDownloading &&
!model.isDeployed
) {
// Sometimes the model gets stuck in a ready to deploy state, so we need to trigger deployment manually
startModelAllocation(model.trainedModelId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getCustomInferenceIdMap = (
const inferenceIdMap = models.reduce<InferenceToModelIdMap>((inferenceMap, model) => {
const inferenceEntry = isLocalModel(model)
? {
trainedModelId: model.service_settings.model_id, // third-party models don't have trained model ids
trainedModelId: model.service_settings.model_id,
isDeployable: model.service === Service.elser || model.service === Service.elasticsearch,
isDeployed: modelStatsById[model.service_settings.model_id]?.state === 'started',
isDownloading: Boolean(downloadStates[model.service_settings.model_id]),
Expand Down

0 comments on commit fb34fc7

Please sign in to comment.