Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] [Auto Import] Fix cases where LLM generates incorrect array field access (#196207) #196329

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

…ess (elastic#196207)

## Release Note

Fixes cases where LLM was likely to generate invalid processors
containing array access in Automatic Import.

## Context

Previously, it happened from time to time that the LLM attempts to add
related fields or apply categorization conditions that use a field, path
to which goes through an array.

The problem is that such an access is invalid and leads to an immediate
error (key part highlighted):

Even including explicit instructions to avoid brackets or an array
access did not seem enough, as the LLM would try to use a different
syntax, owing to the aggressiveness of our review instructions.

The suggested solution is to remove all arrays from the information
shown to the LLM in the related chain. This guarantees that no illegal
access will ever be attempted.

### Summary

- Introduces a utility function to remove all arrays from a JSON object.
- Applies this function for all LLM calls in the related chain.
- Modifies the prompts of related and categorization chain to skip the
arrays as well.

---------

Co-authored-by: Bharat Pasupula <[email protected]>
(cherry picked from commit 8abe259)
@kibanamachine kibanamachine merged commit 7583e1d into elastic:8.x Oct 15, 2024
25 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

cc @ilyannn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants