streamlit-pydantic
streamlit-pydantic copied to clipboard
Handle Collection Type fields
Feature description:
Correctly handle fields such as List[str]
Curently when a field is of a collection type such as dict, list, Mapping, Sequence
etc. the behaviour is broken.
For the model
class ExampleModel(BaseModel):
text: str
many_texts: Sequence[str]
the output is broken
and pressing the submit button results in the following error
Whoops! There were some problems with your input: many_texts: field required
Problem and motivation:
I have forms where some of the inputs are an arbitrary number of strings. Up until now I have solved this with a text_area widget, and prompt the user to separate their inputs with commas. Then with a custom validator the strings can be put back into a list. While this kinda works, it is a very hacky solution, it prevents me from using this package without breaking up my model
Is this something you're interested in working on?
Currently I don't have the capacity but it is something that am willing to look into in the near future (in a couple of months)
Also add Key or Values of Dicts for the Option values instead of enum's only.
@papalotis Thanks for your feature suggestion. This is indeed broken when it is used with pydantic_form
(instead of pydantic_input
). The problem is that Streamlit currently does not provide any kind of input element that supports string lists. Streamlit supports list input only with the multiselect
and the file_uploader
widgets, but this does not help with string lists. Therefore, I had to combine multiple widget to support list inputs. However, this does not work within forms, since forms do not support interactive elements :(
One solution for that might be to use custom streamlit widgets (e.g. streamlit-tags), but I have to evaluate if that works with forms.
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 14 days
@LukasMasuch Just wanted to bump this as I am running into the issue as well. Any thoughts on a solution or workaround? I'd be happy to try to help contribute if you have ideas.
Great package btw!
@disbr007 Thanks for your comment! There is no good workaround I know of at the moment since streamlit does not provide any widgets for multi-element inputs. But there might be a solution for this soon :)
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 14 days
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 14 days
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 14 days