#Include Latex and/or Mathjax support

1 messages · Page 1 of 1 (latest)

modern badger
#

Some users (like myself) have text outputs that include mathematical equations and notations. LLMs have also been really good at maths and have multiple times output mathematical equations/notations that typebot users will be unable to see on typebot.

I think solution would be inclusion of the library

<script type="text/javascript" src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script type="text/javascript" id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

<p>Here is a mathematical equations example:</p>
[ \int x \cos(x^2) , dx = \frac{1}{2} \int \cos(u) , du = \frac{1}{2} \sin(u) + C = \frac{1}{2} \sin(x^2) + C. ]

woeful pendant
#

I just tested and it works for the math equation example you provided:
Raw:
https://latex.codecogs.com/png.latex?[\int x \cos(x^2) , dx = \frac{1}{2} \int \cos(u) , du = \frac{1}{2} \sin(u) + C = \frac{1}{2} \sin(x^2) + C.]
Auto URL encoded when pasted in the browser:
https://latex.codecogs.com/png.latex?%5B%5Cint%2520x%2520%5Ccos(x%5E2)%2520,%2520dx%2520=%2520%5Cfrac%7B1%7D%7B2%7D%2520%5Cint%2520%5Ccos(u)%2520,%2520du%2520=%2520%5Cfrac%7B1%7D%7B2%7D%2520%5Csin(u)%2520+%2520C%2520=%2520%5Cfrac%7B1%7D%7B2%7D%2520%5Csin(x%5E2)%2520+%2520C.%5D
Final output:
https://latex.codecogs.com/png.latex?[\int%2520x%2520\cos(x^2)%2520,%2520dx%2520=%2520\frac{1}{2}%2520\int%2520\cos(u)%2520,%2520du%2520=%2520\frac{1}{2}%2520\sin(u)%2520+%2520C%2520=%2520\frac{1}{2}%2520\sin(x^2)%2520+%2520C.]

Edit: Some URL Encoding characters get displayed on the image, as you can see on the example above.
It seems that it doesn't like space characters (encoded to %20).
Try performing an encodeURI() function in JavaScript and see which encoded characters are displayed or not

#

Now to use it in Typebot, you'd save the Latex string to a variable and use that variable in the URL (or paste it statically) within an Image block to display it 👌
I think it's the most satisfying solution I could find for now

modern badger
#

Tried the below with $$ ... $$ delimiters. It works so far but ONLY FOR BLOCK responses not STREAMING responses.

#

Cant paste the code as its too long.