Allow arbitrary component parameters in the web UI #217
Labels
area: python-api ⌨️
area: rest-api 💻
area: web-ui 💻
dev: corpus
impact: high 🟥
This issue affects most of the users or is a critical issue
type: enhancement 💅
New feature or request
Milestone
Feature description
One of the core features of Ragna is its extension mechanism that allows users (or third-party projects) to integrate well with it. The flexibility happens on two levels:
Point 1. is fully supported by the Python and REST API as well as the web UI. Point 2. however is only properly supported by the Python and REST API. The web UI currently hardcodes the available parameters:
ragna/ragna/deploy/_ui/modal_configuration.py
Lines 214 to 280 in 2c1e5c4
This relies on the fact that almost all builtin source storages and assistants rely on the same set of parameters. However, we already got bitten by it ourselves, see #155. This will not become any easier in the future when we actually go for #191.
My proposal here is to add functionality to the
to be able to support any custom component without hardcoding it.
Fortunately, we already have most of the things done for 1. and 2.
**kwargs
of theragna.core.Chat
construction withpydantic
. We are able to do so by dynamically building a model for each function that is part of the Ragna protocol and merging them together for all components that are used for a chat. Right now we only do this on the type. However, we could optionally allow additional metadata the same way that FastAPI and typer do: instead just declaringfoo: int
we could dofoo: typing.Annotated[int, <metadata>]
. The<metadata>
could just be apydantic.FieldInfo
that can have some additional information likegt
(greater than),title
, anddescription
./components
endpoint. We return the name of the component as well as the JSON schema from the model we build in 1. Meaning, if we implement 1. as suggested above, the new metadata is automatically included and we don't need to change anything else.For example:
So the real task here is to update the web UI to
Point 1. should be fairly simple to do. Since we'll always have the
type
field, we can branch on that and find the relative fields. I don't thinkpydantic
forbids users to put thegt
field on string parameters, but we don't need to care. We just need look for a few named fields for each type.Point 2. could be split into two parts again:
Point 1. should again not be terribly hard. Panels widgets are usually build from
param.Parameter
s, e.g.ragna/ragna/deploy/_ui/modal_configuration.py
Lines 25 to 29 in 2c1e5c4
So just from this, we can already see that we can set the default as well as the limits. The title and description can also be set. From that, we can just create the actual widget with
ragna/ragna/deploy/_ui/modal_configuration.py
Lines 223 to 225 in 2c1e5c4
Of course we can't use an
IntSlider
for everything, but since we are already branching on the type, we can set the widget type as well. For example sliders for int and float parameters, a dropdown menu for enums, and so on.So ultimately after this very long proposal, I think the most important problem that we need to solve is to how to present all the widgets. And while I'm comfortable with all the other points above, I'm not comfortable with this part. I'll add my idea below, but we need a proper design here @smeragoel
My naive idea for this would be to have a tabbed view under the advanced configuration where each tab corresponds to one component type. Meaning, right now we would have two tabs for source storages and assistants. After #191 we would have another tab for the embedding model. Within each tab we would have a matrix of widgets like 2 columns and n number of rows however many we need. IMO, we should not display more than 2-3 rows at once and add a scrollbar after that. That would give us 4-6 parameters visible by default, which is more than enough for our current components.
Value and/or benefit
Without this, the Ragna Python and REST APIs are really flexible and easy to extend for users, but the web UI is not. That was good enough for the first release, but since the web UI is an integral part of Ragna, it should also support the extensions fully.
This came up multiple times so far, e.g. #203 (comment)
Anything else?
No response
The text was updated successfully, but these errors were encountered: