url = '' // for example <https://example.forefront.link>
api_key = '' // navigate to Settings => API Key
encodeURIComponent(JSON.stringify(stop.map(s => s.replaceAll('\\n', '\n'))))
// helper function to construct URL
const makeUrlForEventSource = (input) => (
`${url}/?text=${encodeURIComponent(input)
}&repetition_penalty=${rep
}&temperature=${temperature
}&stop_sequences=${processStopSequences(stop)
}&authorization=Bearer ${api_key}`
// helper function to submit request and listen for events
const handleEventSourceSubmit = (input) => {
const url = makeUrlForEventSource(input)
const source = new EventSource(url, { withCredentials: false });
source.addEventListener('update', (e) => {
source.addEventListener('end', () => {