forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Tech Preview badge for Reranker (elastic#202561)
## Summary Adding a `Tech Preview` badge for `reranker` model. ![reranker](https://github.com/user-attachments/assets/eb370f82-5127-4a9c-a00d-9a6d8adca34c) ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [X] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [X] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
6c8ee9e
commit e7fe5e2
Showing
8 changed files
with
200 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
x-pack/plugins/search_inference_endpoints/public/utils/reranker_helper.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { isProviderTechPreview } from './reranker_helper'; | ||
|
||
describe('Reranker Tech preview badge', () => { | ||
const mockProvider = { | ||
inference_id: 'elastic-rerank', | ||
task_type: 'rerank', | ||
service: 'elasticsearch', | ||
service_settings: { | ||
num_allocations: 1, | ||
num_threads: 1, | ||
model_id: '.rerank-v1', | ||
}, | ||
task_settings: { | ||
return_documents: true, | ||
}, | ||
} as any; | ||
|
||
it('return true for reranker', () => { | ||
expect(isProviderTechPreview(mockProvider)).toEqual(true); | ||
}); | ||
|
||
it('return false for other provider', () => { | ||
const otherProviderServiceSettings = { | ||
...mockProvider.service_settings, | ||
model_id: '.elser_model_2', | ||
}; | ||
const otherProvider = { | ||
...mockProvider, | ||
task_type: 'sparse_embedding', | ||
service_settings: otherProviderServiceSettings, | ||
} as any; | ||
expect(isProviderTechPreview(otherProvider)).toEqual(false); | ||
}); | ||
|
||
it('return false for other provider without model_id', () => { | ||
const mockThirdPartyProvider = { | ||
inference_id: 'azure-openai-1', | ||
service: 'azureopenai', | ||
service_settings: { | ||
resource_name: 'resource-xyz', | ||
deployment_id: 'deployment-123', | ||
api_version: 'v1', | ||
}, | ||
} as any; | ||
expect(isProviderTechPreview(mockThirdPartyProvider)).toEqual(false); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
x-pack/plugins/search_inference_endpoints/public/utils/reranker_helper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils'; | ||
export const isProviderTechPreview = (provider: InferenceAPIConfigResponse) => { | ||
if (hasModelId(provider)) { | ||
return provider.task_type === 'rerank' && provider.service_settings?.model_id?.startsWith('.'); | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
function hasModelId( | ||
service: InferenceAPIConfigResponse | ||
): service is Extract<InferenceAPIConfigResponse, { service_settings: { model_id: string } }> { | ||
return 'model_id' in service.service_settings; | ||
} |