Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Auto Import] Fix cases where LLM generates incorrect array fie…
…ld access (#196207) (#196329) # Backport This will backport the following commits from `main` to `8.x`: - [[Auto Import] Fix cases where LLM generates incorrect array field access (#196207)](#196207) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Ilya Nikokoshev","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-15T14:24:41Z","message":"[Auto Import] Fix cases where LLM generates incorrect array field access (#196207)\n\n## Release Note\r\n\r\nFixes cases where LLM was likely to generate invalid processors\r\ncontaining array access in Automatic Import.\r\n\r\n## Context\r\n\r\nPreviously, it happened from time to time that the LLM attempts to add\r\nrelated fields or apply categorization conditions that use a field, path\r\nto which goes through an array. \r\n\r\nThe problem is that such an access is invalid and leads to an immediate\r\nerror (key part highlighted):\r\n\r\nEven including explicit instructions to avoid brackets or an array\r\naccess did not seem enough, as the LLM would try to use a different\r\nsyntax, owing to the aggressiveness of our review instructions.\r\n\r\nThe suggested solution is to remove all arrays from the information\r\nshown to the LLM in the related chain. This guarantees that no illegal\r\naccess will ever be attempted.\r\n\r\n### Summary\r\n\r\n- Introduces a utility function to remove all arrays from a JSON object.\r\n- Applies this function for all LLM calls in the related chain.\r\n- Modifies the prompts of related and categorization chain to skip the\r\narrays as well.\r\n\r\n---------\r\n\r\nCo-authored-by: Bharat Pasupula <[email protected]>","sha":"8abe25970aa1b483676dde17b7972359c8c55475","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","v9.0.0","backport:prev-minor","Team:Security-Scalability","Feature:AutomaticImport"],"title":"[Auto Import] Fix cases where LLM generates incorrect array field access","number":196207,"url":"https://github.com/elastic/kibana/pull/196207","mergeCommit":{"message":"[Auto Import] Fix cases where LLM generates incorrect array field access (#196207)\n\n## Release Note\r\n\r\nFixes cases where LLM was likely to generate invalid processors\r\ncontaining array access in Automatic Import.\r\n\r\n## Context\r\n\r\nPreviously, it happened from time to time that the LLM attempts to add\r\nrelated fields or apply categorization conditions that use a field, path\r\nto which goes through an array. \r\n\r\nThe problem is that such an access is invalid and leads to an immediate\r\nerror (key part highlighted):\r\n\r\nEven including explicit instructions to avoid brackets or an array\r\naccess did not seem enough, as the LLM would try to use a different\r\nsyntax, owing to the aggressiveness of our review instructions.\r\n\r\nThe suggested solution is to remove all arrays from the information\r\nshown to the LLM in the related chain. This guarantees that no illegal\r\naccess will ever be attempted.\r\n\r\n### Summary\r\n\r\n- Introduces a utility function to remove all arrays from a JSON object.\r\n- Applies this function for all LLM calls in the related chain.\r\n- Modifies the prompts of related and categorization chain to skip the\r\narrays as well.\r\n\r\n---------\r\n\r\nCo-authored-by: Bharat Pasupula <[email protected]>","sha":"8abe25970aa1b483676dde17b7972359c8c55475"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196207","number":196207,"mergeCommit":{"message":"[Auto Import] Fix cases where LLM generates incorrect array field access (#196207)\n\n## Release Note\r\n\r\nFixes cases where LLM was likely to generate invalid processors\r\ncontaining array access in Automatic Import.\r\n\r\n## Context\r\n\r\nPreviously, it happened from time to time that the LLM attempts to add\r\nrelated fields or apply categorization conditions that use a field, path\r\nto which goes through an array. \r\n\r\nThe problem is that such an access is invalid and leads to an immediate\r\nerror (key part highlighted):\r\n\r\nEven including explicit instructions to avoid brackets or an array\r\naccess did not seem enough, as the LLM would try to use a different\r\nsyntax, owing to the aggressiveness of our review instructions.\r\n\r\nThe suggested solution is to remove all arrays from the information\r\nshown to the LLM in the related chain. This guarantees that no illegal\r\naccess will ever be attempted.\r\n\r\n### Summary\r\n\r\n- Introduces a utility function to remove all arrays from a JSON object.\r\n- Applies this function for all LLM calls in the related chain.\r\n- Modifies the prompts of related and categorization chain to skip the\r\narrays as well.\r\n\r\n---------\r\n\r\nCo-authored-by: Bharat Pasupula <[email protected]>","sha":"8abe25970aa1b483676dde17b7972359c8c55475"}}]}] BACKPORT--> Co-authored-by: Ilya Nikokoshev <[email protected]>
- Loading branch information