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

UI extension for new Corpus feature #499

Merged
merged 60 commits into from
Sep 6, 2024
Merged

Conversation

nenb
Copy link
Contributor

@nenb nenb commented Aug 23, 2024

(Separate branch from #484 to ease initial review.)

ragna/deploy/_ui/api_wrapper.py Outdated Show resolved Hide resolved
if op not in EXCLUDED_OPERATORS
]

DUNDER_METHODS = {f"__{op}__".lower(): op for op in ALLOWED_OPERATORS}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this validation if not helpful. It uses the type information passed by the source storage to infer a list of valid operators.

It's not super useful though as string will still allow 'GT' etc., which I don't think is helpful (e.g. path > /my_path is valid Python code, but I don't think it's what users will want).

See below (compute_valid_operator_options etc) for more details.

return None
return MetadataFilter.and_(metadata_filters).to_primitive()

def validate(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Called in modal_configuration.py ...

css_classes=["metadata-filter-row-collection"],
)

def construct_metadata_filters(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Called in modal_configuration.py...

corpus_name=self.metadata_filter_rows.corpus_names_select.value,
)

async def did_finish_upload(self, uploaded_documents, corpus_name=None):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now need to pass corpus_name as it is attached to the chat.

@@ -146,22 +197,20 @@ async def did_finish_upload(self, uploaded_documents):
self.start_chat_button.disabled = False

def change_upload_files_label(self, mode="normal"):
self.error = False
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required to introduce error so that we can watch it, and update the CSS whenever a user performs an invalid operation.

This was previously implicitly watched by other components, but now that we have added many more components to the modal, we need to introduce an explicit component to watch it (otherwise there are edge cases that arise where the CSS is not updated when a user performs an error).

Copy link
Member

@pmeier pmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments, but mostly LGTM. Thanks Nick!

ragna/deploy/_ui/api_wrapper.py Outdated Show resolved Hide resolved
ragna/deploy/_ui/central_view.py Outdated Show resolved Hide resolved
ragna/deploy/_ui/components/file_uploader.py Outdated Show resolved Hide resolved
super().__init__(**params)

key_select_disabled = True
if valid_key_value_pairs:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ok for the EQ, NE, IN, and NOT_IN cases, but falls flat for the numeric ones. Imagine I have [1, 3, 5, 7] in my DB. < 4 should be valid although 4 is not inside the DB.

ragna/deploy/_ui/components/metadata_filters_builder.py Outdated Show resolved Hide resolved
ragna/deploy/_ui/components/metadata_filters_builder.py Outdated Show resolved Hide resolved
ragna/deploy/_ui/components/metadata_filters_builder.py Outdated Show resolved Hide resolved
ragna/deploy/_ui/components/metadata_filters_builder.py Outdated Show resolved Hide resolved
ragna/deploy/_ui/components/metadata_filters_builder.py Outdated Show resolved Hide resolved
ragna/deploy/_ui/modal_configuration.py Show resolved Hide resolved
Copy link
Member

@pmeier pmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Nick for all the hard work here! I found a few bugs, but I don't want to keep this PR open any longer. Let me send a small cleanup commit to fix any nits I might have and fix CI. I'll open issues for all of my comments so we can fix them in follow-up PRs.

Comment on lines +208 to +210
metadata_filters_readable = str(
MetadataFilter.from_primitive(self.current_chat["metadata"]["input"])
).replace("\n", "<br>")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs further processing than just the newlines. The child should be indented

form ragna.core import MetadataFilter

print(MetadataFilter.and_([MetadataFilter.in_("document_name", ["foo.md"])]))
AND(
  IN('document_name', ['foo.md']),
)

image

]

NO_CORPUS_KEY = "No corpuses available"
NO_FILTER_KEY = "Empty Filter"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I don't like this "empty filter" idea. I'd prefer we just have no filter row by default and the user has to click the plus to add one. No filter row would just mean to use the full corpus and don't apply a MetadataFilter.

If we don't go with 1. all the points below apply.

  1. The operator and value field are not cleared when first selecting something and afterwards switching back to the "Empty filter"

    image

  2. When doing 2. with the IN or NOT_IN operator, the value field is not disabled

    image

disabled=True,
)

self.multi_value_select = pn.widgets.MultiChoice.from_param(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I like the idea and the widget in general, but right now I'm only able to see a single row

    image

    Plus, it also leads to another vertical scroll bar so we now have two scroll bars on a modal, which is a big no-no according to Smera.

  2. Not sure where this is handled, but the value is extracted wrong from the widget. For example if I select the following filter in the modal

    image

    I get the following output in the chat history

    image

    There are two issues here:

    1. It did pick a different document as I did select. In my test I couldn't make out a pattern other than it only ever picked a single one.
    2. The value is still a string rather than a list of strings. This leads to errors in the backed, e.g. Chroma, as reported in a previous round of review.

@pmeier pmeier mentioned this pull request Sep 5, 2024
@pmeier pmeier merged commit 9221bb8 into corpus-dev Sep 6, 2024
11 checks passed
@pmeier pmeier deleted the corpus-dev-ui-rework branch September 6, 2024 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants