[Obs AI Assistant] Specify embedding model during onboarding for the Knowledge Base (#218448)

Closes https://github.com/elastic/obs-ai-assistant-team/issues/230
Closes https://github.com/elastic/obs-ai-assistant-team/issues/232

Related to https://github.com/elastic/kibana/pull/215591

## Summary

This PR implements the changes related to the first phase of supporing
multilingual Knowledge Base. The users have the ability to pick the
`e5-small` model for the Knowledge Base, if they want support for
languages other than English.

<img width="610" alt="image"
src="https://github.com/user-attachments/assets/4c815aa4-aa97-4845-98c5-e079dd92f23a"
/>

<img width="1281" alt="image"
src="https://github.com/user-attachments/assets/7c1bcd82-5464-497f-a053-7fe271da1cdd"
/>

<img width="1280" alt="image"
src="https://github.com/user-attachments/assets/bc084e90-c291-44ea-8560-e033729bfcca"
/>

When the KB model is not allocated due to nodes scaling down:


![image](https://github.com/user-attachments/assets/2f52e31e-81e4-4824-bc5b-b97df714da5c)


### Checklist

- [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/src/platform/packages/shared/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
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)


## Upgrade testing steps

### 9.0 - 9.1 (main)

Checkout `9.0` branch and start Kibana and ES. ES must be started with
`path.data` to persist data:

```
yarn es snapshot --license trial --E path.data=/Users/sorenlouv/elastic/es_data/upgrade_test_9.0
```

---------

Co-authored-by: Søren Louv-Jansen <soren.louv@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Søren Louv-Jansen <sorenlouv@gmail.com>
This commit is contained in:
Viduni Wickramarachchi 2025-05-05 04:13:10 -04:00 committed by GitHub
parent 10692211bc
commit dc019f85e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
169 changed files with 4312 additions and 2106 deletions

View file

@ -256,6 +256,19 @@ export class LockManager {
}
}
export async function getLock({
esClient,
logger,
lockId,
}: {
esClient: ElasticsearchClient;
logger: Logger;
lockId: LockId;
}): Promise<LockDocument | undefined> {
const lockManager = new LockManager(lockId, esClient, logger);
return lockManager.get();
}
export async function withLock<T>(
{
esClient,
@ -280,9 +293,7 @@ export async function withLock<T>(
// extend the ttl periodically
const extendInterval = Math.floor(ttl / 4);
logger.debug(
`Lock "${lockId}" acquired. Extending TTL every ${prettyMilliseconds(extendInterval)}`
);
logger.debug(`Extending TTL for lock "${lockId}" every ${prettyMilliseconds(extendInterval)}`);
let extendTTlPromise = Promise.resolve(true);
const intervalId = setInterval(() => {

View file

@ -8,7 +8,7 @@
*/
import { CoreSetup, Logger } from '@kbn/core/server';
import { LockId, withLock } from './lock_manager_client';
import { LockId, withLock, getLock } from './lock_manager_client';
export class LockManagerService {
constructor(private readonly coreSetup: CoreSetup<any>, private readonly logger: Logger) {}
@ -35,8 +35,16 @@ export class LockManagerService {
) {
const [coreStart] = await this.coreSetup.getStartServices();
const esClient = coreStart.elasticsearch.client.asInternalUser;
const logger = this.logger.get('LockManager');
const logger = this.logger.get('lock-manager');
return withLock<T>({ esClient, logger, lockId, metadata }, callback);
}
async getLock(lockId: LockId) {
const [coreStart] = await this.coreSetup.getStartServices();
const esClient = coreStart.elasticsearch.client.asInternalUser;
const logger = this.logger.get('lock-manager');
return getLock({ esClient, logger, lockId });
}
}