mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
Resolves https://github.com/elastic/kibana/issues/159598
## Summary
This PR modifies the `test` subaction of the Generative AI connector to
accept a `stream` parameter (default: `false`) that allows for a
streaming response.
The Generative AI connector is basically a pass-through to the Open
AI/Azure OpenAI APIs, where the `stream` parameter is passed in via the
body of the request. This means that with the existing connector, users
could specify `stream: true` in the body which would lead to unexpected
results when the action is unprepared to return streaming results. This
PR sanitizes the body that is passed in the `run` subaction to prevent
the `stream` parameter from being set to `true` and explicitly sets the
`stream` parameter for the `test` subaction.
In order to test the streaming response, I created an example plugin
that prompts users to create a Generative AI connector if one does not
exist and then executes actions using the connector with `stream` set to
`true`. This borrows liberally from @dgieselaar's existing work from
https://github.com/elastic/kibana/pull/158678
441694cb
-0154-4450-bd93-3907c4a9995c
## To Verify
1. Navigate to https://localhost:5601/app/GenAiStreamingResponseExample
2. Set up a Generative AI connector
3. Open the network console. Enter a prompt and click `Stream Response`
4. You should see the chat response return streaming results.
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
18 lines
678 B
JavaScript
18 lines
678 B
JavaScript
/*
|
|
* 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.
|
|
*/
|
|
|
|
module.exports = {
|
|
preset: '@kbn/test',
|
|
rootDir: '../../..',
|
|
roots: ['<rootDir>/x-pack/examples/gen_ai_streaming_response_example'],
|
|
coverageDirectory:
|
|
'<rootDir>/target/kibana-coverage/jest/x-pack/examples/gen_ai_streaming_response_example',
|
|
coverageReporters: ['text', 'html'],
|
|
collectCoverageFrom: [
|
|
'<rootDir>/x-pack/examples/gen_ai_streaming_response_example/{public,server}/**/*.{ts,tsx}',
|
|
],
|
|
};
|