Feature Request for st_annotated_text

Hi Guys,

i want to use annotated_text() - (see GitHub - tvst/st-annotated-text: A simple component to display annotated text in Streamlit apps. ) .
Can someone explain what I am doing wrong or if it’s simple not possible yet.

I want to iterate over a document and append the annotation for each sentence.

If i do the following:

> def createTuple(text, annoText, color):
>     return (text, annoText, color)
> 
> def main():
>    tuple = createTuple("ich bin ein bunt makierter Text","", Color.GREEN.value)
>    annotated_text("Hallo " , tuple ,  " .")

Can someone tell me what I am doing wrong or what I do have to adjust to make it work?
Also it would be nice if one could just pass a list or a single string to annotated_text()
containing both, simple strings and triples for annotated text.
Thank you in andvance.

Hi @chris_klose -

Does this component do what you are looking for?

Best,
Randy

Hello @Randy,

are you some sort of AI?
I have linked this component above too.
The question is, how to pass multiple variables ( strings and tuples)
from the outside to the function.

e.g.
tuple1 = (“text”,"", rgb(0,0,1)
list_of_strings_ands_tuples = [“First stenence,” , tuple1, “sentence2”]
annotated_text(list_of_strings_ands_tuples)

Sorry, I didn’t read carefully. No, I’m not a robot :slight_smile:

That component was written by @thiago, maybe he can give a quick hint.

Hello @chris_klose,

The component doesn’t support lists as argument, but you can unpack it and pass its elements as arguments.

If I take your example:

tuple1 = ("text", "", "rgb(0,0,1)")
list_of_strings_ands_tuples = ["First stenence, ", tuple1, "sentence2"]
annotated_text(*list_of_strings_ands_tuples)
#              ^ There, that operator unpacks the list
3 Likes

Thanks a lot @okld.
So simple actually.
Also thank you @randyzwitch for your attempt to help, it has been recognized appreciated.

Short follow up question:
How can I make the text bold as well?

What I have tried is:
annotation("world", "", color="#8ef", font-weight=700)
Problem here is that font-weight contains the -
Any ideas? Thank you guys.

Try to use font_weight, with an underscore.

1 Like

Thank you, bro.