[Security Solution] Disable streaming when RAG Alerts is on (#173566)

This commit is contained in:
Steph Milovic 2023-12-19 08:16:24 -06:00 committed by GitHub
parent 40b354958f
commit 1a78fed75d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View file

@ -133,6 +133,28 @@ describe('API tests', () => {
);
});
it('calls the actions connector api with invoke when assistantStreamingEnabled is true when assistantLangChain is false and alerts is true', async () => {
const testProps: FetchConnectorExecuteAction = {
...fetchConnectorArgs,
assistantLangChain: false,
alerts: true,
};
await fetchConnectorExecuteAction(testProps);
expect(mockHttp.fetch).toHaveBeenCalledWith(
'/internal/elastic_assistant/actions/connector/foo/_execute',
{
body: '{"params":{"subActionParams":{"model":"gpt-4","messages":[{"role":"user","content":"This is a test"}],"n":1,"stop":null,"temperature":0.2},"subAction":"invokeAI"},"assistantLangChain":false}',
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
signal: undefined,
}
);
});
it('returns API_ERROR when the response status is error and langchain is on', async () => {
(mockHttp.fetch as jest.Mock).mockResolvedValue({ status: 'error' });

View file

@ -84,7 +84,7 @@ export const fetchConnectorExecuteAction = async ({
// tracked here: https://github.com/elastic/security-team/issues/7363
// In part 3 I will make enhancements to langchain to introduce streaming
// Once implemented, invokeAI can be removed
const isStream = assistantStreamingEnabled && !assistantLangChain;
const isStream = assistantStreamingEnabled && !assistantLangChain && !alerts;
const optionalRequestParams = getOptionalRequestParams({
alerts,
alertsIndexPattern,