-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Tech Preview badge for Reranker #202561
Merged
Samiul-TheSoccerFan
merged 7 commits into
elastic:main
from
Samiul-TheSoccerFan:reranker-badge
Dec 4, 2024
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a4325d8
Adding reranker support in inference management with tech preview badge
Samiul-TheSoccerFan 862592b
Fixing type issues and added helper function for tech preview badge
Samiul-TheSoccerFan 052f8ac
Refactor code to remove unnecessary variable
Samiul-TheSoccerFan 7de1c5e
Updating badge color to subdued
Samiul-TheSoccerFan ac1f5b8
Merge branch 'main' into reranker-badge
elasticmachine 1e3d6f7
Updating type for taskType
Samiul-TheSoccerFan 1e1a0b9
Updating API response to match from ES library
Samiul-TheSoccerFan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,26 +7,49 @@ | |||||
|
||||||
import { EuiBetaBadge, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||||||
import React from 'react'; | ||||||
import { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils'; | ||||||
import { isEndpointPreconfigured } from '../../../../utils/preconfigured_endpoint_helper'; | ||||||
import * as i18n from './translations'; | ||||||
import { isProviderTechPreview } from '../../../../utils/reranker_helper'; | ||||||
|
||||||
export interface EndpointInfoProps { | ||||||
inferenceId: string; | ||||||
provider: InferenceAPIConfigResponse; | ||||||
} | ||||||
|
||||||
export const EndpointInfo: React.FC<EndpointInfoProps> = ({ inferenceId }) => ( | ||||||
<EuiFlexGroup justifyContent="spaceBetween"> | ||||||
<EuiFlexItem grow={false}> | ||||||
<span> | ||||||
<strong>{inferenceId}</strong> | ||||||
</span> | ||||||
</EuiFlexItem> | ||||||
<EuiFlexItem grow={false}> | ||||||
<span> | ||||||
{isEndpointPreconfigured(inferenceId) ? ( | ||||||
<EuiBetaBadge label={i18n.PRECONFIGURED_LABEL} size="s" color="hollow" /> | ||||||
) : null} | ||||||
</span> | ||||||
</EuiFlexItem> | ||||||
</EuiFlexGroup> | ||||||
); | ||||||
export const EndpointInfo: React.FC<EndpointInfoProps> = ({ inferenceId, provider }) => { | ||||||
const isInTechPreview = isProviderTechPreview(provider); | ||||||
|
||||||
return ( | ||||||
<EuiFlexGroup justifyContent="spaceBetween"> | ||||||
<EuiFlexItem grow={false}> | ||||||
<EuiFlexGroup gutterSize="s" alignItems="center"> | ||||||
<EuiFlexItem grow={false}> | ||||||
<span> | ||||||
<strong>{inferenceId}</strong> | ||||||
</span> | ||||||
</EuiFlexItem> | ||||||
{isInTechPreview ? ( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||
<EuiFlexItem grow={false}> | ||||||
<span> | ||||||
<EuiBetaBadge | ||||||
label={i18n.TECH_PREVIEW_LABEL} | ||||||
size="s" | ||||||
color="hollow" | ||||||
alignment="middle" | ||||||
/> | ||||||
</span> | ||||||
</EuiFlexItem> | ||||||
) : null} | ||||||
</EuiFlexGroup> | ||||||
</EuiFlexItem> | ||||||
<EuiFlexItem grow={false}> | ||||||
<span> | ||||||
{isEndpointPreconfigured(inferenceId) ? ( | ||||||
<EuiBetaBadge label={i18n.PRECONFIGURED_LABEL} size="s" color="hollow" /> | ||||||
) : null} | ||||||
</span> | ||||||
</EuiFlexItem> | ||||||
</EuiFlexGroup> | ||||||
); | ||||||
}; |
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; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type was defined a long time ago when the elasticsearch client didn't contain the type definition. You can use
InferenceTaskType
here instead.Or the entire type can be replaced with
InferenceInferenceEndpointInfo
from the elasticsearch client.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type InferenceAPIConfigResponse = InferenceInferenceEndpointInfo & InferenceServiceSettings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done