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.
[product doc] implement
highlight
summarizer (elastic#206578)
## Summary Fix elastic#205921 - Implements a new summary strategy for the product documentation, based on `semantic_text` highlights - set that new strategy as the default one ### Why ? Until now, in case of excessive token count, we were using a LLM based summarizer. Realistically, highlights will always be worse than calling a LLM for a "in context summary", but from my testing, highlights seem "good enough", and the speed difference (instant for highlights vs multiple seconds, up to a dozen, for the LLM summary) is very significant, and seems overall worth it. The main upside with that change, given that requesting the product doc will be waaaay faster, is that we can then tweak the assistant's instruction to more aggressively call the product_doc tool between each user message without the risk of the user experience being impacted (waiting way longer between messages). - *which will be done as a follow-up* ### How to test ? Install the product doc, ask questions to the assistant, check the tool calls (sorry, don't have a better option atm...) Note: that works with both versions of the product doc artifacts, so don't need the dev repository
- Loading branch information
1 parent
7e48400
commit c9286ec
Showing
14 changed files
with
308 additions
and
44 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
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
58 changes: 58 additions & 0 deletions
58
...rm/plugins/shared/ai_infra/product_doc_base/server/services/search/perform_search.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,58 @@ | ||
/* | ||
* 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 { elasticsearchServiceMock } from '@kbn/core/server/mocks'; | ||
import { performSearch } from './perform_search'; | ||
|
||
describe('performSearch', () => { | ||
let esClient: ReturnType<typeof elasticsearchServiceMock.createElasticsearchClient>; | ||
|
||
beforeEach(() => { | ||
esClient = elasticsearchServiceMock.createElasticsearchClient(); | ||
|
||
esClient.search.mockResolvedValue({ hits: { hits: [] } } as any); | ||
}); | ||
|
||
it('calls esClient.search with the correct parameters', async () => { | ||
await performSearch({ | ||
searchQuery: 'query', | ||
highlights: 3, | ||
size: 3, | ||
index: ['index1', 'index2'], | ||
client: esClient, | ||
}); | ||
|
||
expect(esClient.search).toHaveBeenCalledTimes(1); | ||
expect(esClient.search).toHaveBeenCalledWith({ | ||
index: ['index1', 'index2'], | ||
size: 3, | ||
query: expect.any(Object), | ||
highlight: { | ||
fields: { | ||
content_body: expect.any(Object), | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('calls esClient.search without highlight when highlights=0', async () => { | ||
await performSearch({ | ||
searchQuery: 'query', | ||
highlights: 0, | ||
size: 3, | ||
index: ['index1', 'index2'], | ||
client: esClient, | ||
}); | ||
|
||
expect(esClient.search).toHaveBeenCalledTimes(1); | ||
expect(esClient.search).toHaveBeenCalledWith( | ||
expect.not.objectContaining({ | ||
highlight: expect.any(Object), | ||
}) | ||
); | ||
}); | ||
}); |
Oops, something went wrong.