integreat-cms
integreat-cms copied to clipboard
Use beta-handling of HTML tags in SUMM.AI API
Motivation
SUMM.AI published a beta version with they API which can handle basic HTML input (only links and bold text at the moment) by passing the flag input_text_type
:
https://summai.notion.site/SUMM-API-Documentation-fc41fa5ef1434ad2b311be4876b4685a?p=e8436a4a6d154249a70d32ba45c88e2e&pm=s
Proposed Solution
- Add
input_text_type="html"
to the SUMM.AI API call - Do a bit of additional testing whether additional changes to the API client are required
The purpose of this change is to preserve the formatting (bold, links) in the translated text, right?
As far as I tested, SUMM AI retains HTML tags only in some cases and I couldn't discover the exact logic.
For example, if I try to translate the following text in the html mode:
Deutsches Recht (<strong>Gesetzessammlungen</strong>) ist darüber hinaus der Name von verschiedenen Gesetzessammlungen, die das zum Erscheinungszeitpunkt in Deutschland geltende <a href='http://google.com'>Recht</a> oder auch nur bestimmte Teile davon, ggf. auch außer Kraft getretenes Recht, zusammenstellen und auf einfache Weise verfügbar machen.
I get the result without the boldface and link:
<p>Es gibt auch Bücher mit den Gesetzen.<br/>Die Bücher heißen: Deutsches Recht.<br/>In den Büchern stehen die Gesetze von Deutschland.<br/>Manchmal stehen auch nur die alten Gesetze in den Büchern.</p>
In addition (sometimes), the arrangement of tags in the text affects the translation result in unexpected ways.
For example, if I make 'strong' another word in the text above, I get a different translation 🤔
Request:
<strong>Deutsches Recht</strong> (Gesetzessammlungen) ist darüber hinaus der Name von verschiedenen Gesetzessammlungen, die das zum Erscheinungszeitpunkt in Deutschland geltende <a href='http://google.com'>Recht</a> oder auch nur bestimmte Teile davon, ggf. auch außer Kraft getretenes Recht, zusammenstellen und auf einfache Weise verfügbar machen.
Result:
<strong>Deutsches Recht</strong> (Gesetzes-Sammlungen) ist darüber hinaus der Name von verschiedenen Gesetzes-Sammlungen, die das zum Erscheinungs-Zeit-Punkt in Deutschland geltende <a href=\"http://google.com\">Recht</a> oder auch nur bestimmte Teile davon, ggf. auch außer Kraft getretenes Recht, zusammenstellen und auf einfache Weise verfügbar machen.
So, do we still want to introduce this? @timobrembeck could you pls take a look?
Do a bit of additional testing whether additional changes to the API client are required
Yes, we would need to refactor the way how we prepare the request to SUMM AI, because currently we clean all the tags. And the way how we process the response data, because we will need to adjust the processing of paragraphs.
Another curious example
Input text:
<a href='http://gooogle.com'>Willkommen</a> in Augsburg
Translation result - link is preserved:
<a href=\"http://gooogle.com\">Willkommen</a> in Augsburg
But for this input text:
Willkommen in <a href='http://gooogle.com'>Augsburg</a>
Translation result - link is lost:
<p>Willkommen in Augsburg</p>
Was moved to the ~~next milestone~~ backlog as we are still blocked by SummAI and therefore not feasible at the moment