I cannot parse my dict input into a summary model

Hi everyone,

This is a code I am working with below.

random_text =“The Goldfinch is an oil-on-panel painting by the Dutch Golden Age artist Carel Fabritius of a life-sized chained goldfinch. Signed and dated 1654, it is now in the collection of the Mauritshuis in The Hague, Netherlands. The work is a trompe-l’œil painting that was once part of a larger structure, perhaps a window jamb or a protective cover. It is possible that the work was in Fabritius’s studio in Delft at the time of a large gunpowder explosion on 12 October 1654 that killed him and destroyed much of the city. A common and colourful bird with a pleasant song, the goldfinch was a popular pet, and could be taught simple tricks including lifting a thimble-sized bucket of water. It was reputedly a bringer of good health, and was used in Italian Renaissance painting as a symbol of Christian redemption and the Passion of Jesus. The Goldfinch is unusual for the Dutch Golden Age painting period in the simplicity of its composition and use of illusionary techniques. Following the death of its creator, it was lost for more than two centuries before its rediscovery in Brussels”

Summ_set = {

        'context': random_text



I built an app using anvil and whenever I pass the Summ_set, it returns the error " have the wrong format. The should be either of type str or type list"

But if i have the text directly i.e random_text , it returns the summary.

Please can anyone help me out?

What is the aim of passing a dict instead of a list or string? The pipeline function seems to accept only string or list format. Anyway, if you want to use a dict, did you try that: nlp_pipeline(Summ_set['context']) ?

Thanks for the swift reply.

I am building an anvil web app using a Bart model I fine-tuned. I created a function that uses the model to summarize documents. But whenever I pass the inputs to the summary function the error " have the wrong format. They should be either of type str or type list"
I am a bit confused, please.

This is a link to the code on Kaggle summarizer | Kaggle
if you can take a look, I will be grateful.

I figured it out. The problem itself was returning the wrong key in the function. I was supposed to return “summary_text” which is the name of the key returned in the results object.

Thanks for the help, appreciate it.

1 Like