-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Search][Playground] Support Multiple Context Fields #210703
[Search][Playground] Support Multiple Context Fields #210703
Conversation
c71a1fb
to
9bbdd10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x-pack/test/functional/config.base.js
changes LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left some comments. It might be worth having @yansavitski take a look as well.
}; | ||
}, [indexFields.source_fields, selectedContextFields]); | ||
const onSelectFields = useCallback( | ||
(updatedSelectedOptions: Array<EuiComboBoxOptionOption<unknown>>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we avoid defining unknown
and any
as a type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should avoid any
, uknown
is perfectly fine.
Using unknown
TS will make you do type checks to validate what the type is. But in this case thats the option data type and what we need to access is for the EuiComboBoxOptionOption
. So the option type is not needed in this callback currently.
size="s" | ||
/> | ||
)} | ||
<ContextFieldsSelect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat!
@@ -38,7 +38,7 @@ describe('conversational chain', () => { | |||
expectedTokens?: any; | |||
expectedErrorMessage?: string; | |||
expectedSearchRequest?: any; | |||
contentField?: Record<string, string>; | |||
contentField?: Record<string, string | string[]>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be replace this with ElasticsearchRetrieverContentField
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ElasticsearchRetrieverContentField
is string | Record<string, string | string[]>
which would then require this filed to handle contentField
being a string
. Which it never is. So it would just unnecessarily complicate this code IMO.
@Samiul-TheSoccerFan FYI this PR is 90% there but I still have to update the UI to select all the context fields by default. Which is what I'll be working on today. |
(hit: SearchHit): Document => { | ||
let pageContent: string = ''; | ||
const makePageContentForField = (field: string) => | ||
`${field}: ${getValueForSelectedField(hit, field)}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update this function to check if contentField has a field value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
works well! tested with a few scenarios. The only thing left is updating the view code example to include multiple context fields. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@joemcelroy can we update the python code to support multiple context fields? looking at the python code it looks like it only support Or does that just mean we need to show a custom document mapper if there is multiple context fields? I did update the vanilla python example to support multiple context fields, but I haven't had a chance to test that code yet. So i'll need to do that before we merge these changes. |
ed717eb
to
96f1989
Compare
Yes, for LangChain code lets have a custom document mapper if theres multiple context fields. We can consider in future to update the LangChain retriever to support multiple context fields. |
…en handling chat messages
…om the context documents
…le context fields
dd48e86
to
7d618de
Compare
@joemcelroy this is updated to use a custom document mapper for langchain retriever if you have >1 context field selected. I tested both scenarios locally and everything should be good and functional. I did update the question in the lang chain example to be more generic and try and encourage its replacement based on actually user data If you have time give it another 👀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Thank you.
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
History
|
Summary
This PR updates the search playground to allow selecting > 1 context fields to be included in context documents for the LLM.
Screenshots
Context Fields Updated to ComboBox:

Checklist