ChatUI support LaTeX out of the box
import { ChatSection } from '@llamaindex/chat-ui'
import '@llamaindex/chat-ui/styles/markdown.css'
import { useChat } from 'ai/react'
function DemoLatexChat() {
const handler = useChat()
return <ChatSection handler={handler} />
}
javascriptfunction greetFromLocation(location) { console.log(`Hello from ${location}`); } // Example usage: greetFromLocation("New York"); greetFromLocation("Tokyo"); greetFromLocation("Paris");
greetFromLocation
function takes one parameter, location
.console.log
function is used to print the message to the console.javascriptfunction calculateTriangleArea(base, height) { if (base <= 0 || height <= 0) { throw new Error("Base and height must be positive numbers."); } return 0.5 * base * height; } // Example usage: const base = 5; // Example base length const height = 10; // Example height length try { const area = calculateTriangleArea(base, height); console.log(`The area of the triangle is: ${area}`); } catch (error) { console.error(error.message); }
calculateTriangleArea
takes two parameters: base
and height
.base
and height
variables to test with different values.