chore: format

This commit is contained in:
Timothy J. Baek 2024-08-13 11:12:35 +01:00
parent 70f580ec45
commit 7ef5aa520c
24 changed files with 160 additions and 143 deletions

View File

@ -22,7 +22,6 @@ Noticed something off? Have an idea? Check our [Issues tab](https://github.com/o
> [!IMPORTANT] > [!IMPORTANT]
> >
> - **Template Compliance:** Please be aware that failure to follow the provided issue template, or not providing the requested information at all, will likely result in your issue being closed without further consideration. This approach is critical for maintaining the manageability and integrity of issue tracking. > - **Template Compliance:** Please be aware that failure to follow the provided issue template, or not providing the requested information at all, will likely result in your issue being closed without further consideration. This approach is critical for maintaining the manageability and integrity of issue tracking.
>
> - **Detail is Key:** To ensure your issue is understood and can be effectively addressed, it's imperative to include comprehensive details. Descriptions should be clear, including steps to reproduce, expected outcomes, and actual results. Lack of sufficient detail may hinder our ability to resolve your issue. > - **Detail is Key:** To ensure your issue is understood and can be effectively addressed, it's imperative to include comprehensive details. Descriptions should be clear, including steps to reproduce, expected outcomes, and actual results. Lack of sufficient detail may hinder our ability to resolve your issue.
### 🧭 Scope of Support ### 🧭 Scope of Support

View File

@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />

View File

@ -260,7 +260,7 @@ export const getOpenAIModelsDirect = async (
throw error; throw error;
} }
const models = Array.isArray(res) ? res : res?.data ?? null; const models = Array.isArray(res) ? res : (res?.data ?? null);
return models return models
.map((model) => ({ id: model.id, name: model.name ?? model.id, external: true })) .map((model) => ({ id: model.id, name: model.name ?? model.id, external: true }))

View File

@ -75,12 +75,12 @@
class="font-semibold uppercase text-xs {section === 'added' class="font-semibold uppercase text-xs {section === 'added'
? 'text-white bg-blue-600' ? 'text-white bg-blue-600'
: section === 'fixed' : section === 'fixed'
? 'text-white bg-green-600' ? 'text-white bg-green-600'
: section === 'changed' : section === 'changed'
? 'text-white bg-yellow-600' ? 'text-white bg-yellow-600'
: section === 'removed' : section === 'removed'
? 'text-white bg-red-600' ? 'text-white bg-red-600'
: ''} w-fit px-3 rounded-full my-2.5" : ''} w-fit px-3 rounded-full my-2.5"
> >
{section} {section}
</div> </div>

View File

@ -112,7 +112,7 @@
url: OpenAIUrl, url: OpenAIUrl,
batch_size: OpenAIBatchSize batch_size: OpenAIBatchSize
} }
} }
: {}) : {})
}).catch(async (error) => { }).catch(async (error) => {
toast.error(error); toast.error(error);

View File

@ -579,8 +579,8 @@
let selectedModelIds = modelId let selectedModelIds = modelId
? [modelId] ? [modelId]
: atSelectedModel !== undefined : atSelectedModel !== undefined
? [atSelectedModel.id] ? [atSelectedModel.id]
: selectedModels; : selectedModels;
// Create response messages for each selected model // Create response messages for each selected model
const responseMessageIds = {}; const responseMessageIds = {};
@ -739,11 +739,11 @@
? await getAndUpdateUserLocation(localStorage.token) ? await getAndUpdateUserLocation(localStorage.token)
: undefined : undefined
)}${ )}${
responseMessage?.userContext ?? null (responseMessage?.userContext ?? null)
? `\n\nUser Context:\n${responseMessage?.userContext ?? ''}` ? `\n\nUser Context:\n${responseMessage?.userContext ?? ''}`
: '' : ''
}` }`
} }
: undefined, : undefined,
...messages ...messages
] ]
@ -811,10 +811,10 @@
options: { options: {
...(params ?? $settings.params ?? {}), ...(params ?? $settings.params ?? {}),
stop: stop:
params?.stop ?? $settings?.params?.stop ?? undefined (params?.stop ?? $settings?.params?.stop ?? undefined)
? (params?.stop.split(',').map((token) => token.trim()) ?? $settings.params.stop).map( ? (params?.stop.split(',').map((token) => token.trim()) ?? $settings.params.stop).map(
(str) => decodeURIComponent(JSON.parse('"' + str.replace(/\"/g, '\\"') + '"')) (str) => decodeURIComponent(JSON.parse('"' + str.replace(/\"/g, '\\"') + '"'))
) )
: undefined, : undefined,
num_predict: params?.max_tokens ?? $settings?.params?.max_tokens ?? undefined, num_predict: params?.max_tokens ?? $settings?.params?.max_tokens ?? undefined,
repeat_penalty: repeat_penalty:
@ -1056,10 +1056,10 @@
stream: true, stream: true,
model: model.id, model: model.id,
stream_options: stream_options:
model.info?.meta?.capabilities?.usage ?? false (model.info?.meta?.capabilities?.usage ?? false)
? { ? {
include_usage: true include_usage: true
} }
: undefined, : undefined,
messages: [ messages: [
params?.system || $settings.system || (responseMessage?.userContext ?? null) params?.system || $settings.system || (responseMessage?.userContext ?? null)
@ -1072,11 +1072,11 @@
? await getAndUpdateUserLocation(localStorage.token) ? await getAndUpdateUserLocation(localStorage.token)
: undefined : undefined
)}${ )}${
responseMessage?.userContext ?? null (responseMessage?.userContext ?? null)
? `\n\nUser Context:\n${responseMessage?.userContext ?? ''}` ? `\n\nUser Context:\n${responseMessage?.userContext ?? ''}`
: '' : ''
}` }`
} }
: undefined, : undefined,
...messages ...messages
] ]
@ -1092,7 +1092,7 @@
text: text:
arr.length - 1 !== idx arr.length - 1 !== idx
? message.content ? message.content
: message?.raContent ?? message.content : (message?.raContent ?? message.content)
}, },
...message.files ...message.files
.filter((file) => file.type === 'image') .filter((file) => file.type === 'image')
@ -1103,20 +1103,20 @@
} }
})) }))
] ]
} }
: { : {
content: content:
arr.length - 1 !== idx arr.length - 1 !== idx
? message.content ? message.content
: message?.raContent ?? message.content : (message?.raContent ?? message.content)
}) })
})), })),
seed: params?.seed ?? $settings?.params?.seed ?? undefined, seed: params?.seed ?? $settings?.params?.seed ?? undefined,
stop: stop:
params?.stop ?? $settings?.params?.stop ?? undefined (params?.stop ?? $settings?.params?.stop ?? undefined)
? (params?.stop.split(',').map((token) => token.trim()) ?? $settings.params.stop).map( ? (params?.stop.split(',').map((token) => token.trim()) ?? $settings.params.stop).map(
(str) => decodeURIComponent(JSON.parse('"' + str.replace(/\"/g, '\\"') + '"')) (str) => decodeURIComponent(JSON.parse('"' + str.replace(/\"/g, '\\"') + '"'))
) )
: undefined, : undefined,
temperature: params?.temperature ?? $settings?.params?.temperature ?? undefined, temperature: params?.temperature ?? $settings?.params?.temperature ?? undefined,
top_p: params?.top_p ?? $settings?.params?.top_p ?? undefined, top_p: params?.top_p ?? $settings?.params?.top_p ?? undefined,

View File

@ -609,10 +609,10 @@
style="font-size:{rmsLevel * 100 > 4 style="font-size:{rmsLevel * 100 > 4
? '4.5' ? '4.5'
: rmsLevel * 100 > 2 : rmsLevel * 100 > 2
? '4.25' ? '4.25'
: rmsLevel * 100 > 1 : rmsLevel * 100 > 1
? '3.75' ? '3.75'
: '3.5'}rem;width: 100%; text-align:center;" : '3.5'}rem;width: 100%; text-align:center;"
> >
{emoji} {emoji}
</div> </div>
@ -658,10 +658,10 @@
class=" {rmsLevel * 100 > 4 class=" {rmsLevel * 100 > 4
? ' size-[4.5rem]' ? ' size-[4.5rem]'
: rmsLevel * 100 > 2 : rmsLevel * 100 > 2
? ' size-16' ? ' size-16'
: rmsLevel * 100 > 1 : rmsLevel * 100 > 1
? 'size-14' ? 'size-14'
: 'size-12'} transition-all rounded-full {(model?.info?.meta : 'size-12'} transition-all rounded-full {(model?.info?.meta
?.profile_image_url ?? '/static/favicon.png') !== '/static/favicon.png' ?.profile_image_url ?? '/static/favicon.png') !== '/static/favicon.png'
? ' bg-cover bg-center bg-no-repeat' ? ' bg-cover bg-center bg-no-repeat'
: 'bg-black dark:bg-white'} bg-black dark:bg-white" : 'bg-black dark:bg-white'} bg-black dark:bg-white"
@ -691,10 +691,10 @@
style="font-size:{rmsLevel * 100 > 4 style="font-size:{rmsLevel * 100 > 4
? '13' ? '13'
: rmsLevel * 100 > 2 : rmsLevel * 100 > 2
? '12' ? '12'
: rmsLevel * 100 > 1 : rmsLevel * 100 > 1
? '11.5' ? '11.5'
: '11'}rem;width:100%;text-align:center;" : '11'}rem;width:100%;text-align:center;"
> >
{emoji} {emoji}
</div> </div>
@ -740,10 +740,10 @@
class=" {rmsLevel * 100 > 4 class=" {rmsLevel * 100 > 4
? ' size-52' ? ' size-52'
: rmsLevel * 100 > 2 : rmsLevel * 100 > 2
? 'size-48' ? 'size-48'
: rmsLevel * 100 > 1 : rmsLevel * 100 > 1
? 'size-[11.5rem]' ? 'size-[11.5rem]'
: 'size-44'} transition-all rounded-full {(model?.info?.meta : 'size-44'} transition-all rounded-full {(model?.info?.meta
?.profile_image_url ?? '/static/favicon.png') !== '/static/favicon.png' ?.profile_image_url ?? '/static/favicon.png') !== '/static/favicon.png'
? ' bg-cover bg-center bg-no-repeat' ? ' bg-cover bg-center bg-no-repeat'
: 'bg-black dark:bg-white'} " : 'bg-black dark:bg-white'} "

View File

@ -27,7 +27,7 @@
title: $i18n.t('All Documents'), title: $i18n.t('All Documents'),
collection_names: $documents.map((doc) => doc.collection_name) collection_names: $documents.map((doc) => doc.collection_name)
} }
] ]
: []), : []),
...$documents ...$documents
.reduce((a, e, i, arr) => { .reduce((a, e, i, arr) => {

View File

@ -305,7 +305,7 @@
{#each messages as message, messageIdx} {#each messages as message, messageIdx}
<div class=" w-full {messageIdx === messages.length - 1 ? ' pb-12' : ''}"> <div class=" w-full {messageIdx === messages.length - 1 ? ' pb-12' : ''}">
<div <div
class="flex flex-col justify-between px-5 mb-3 {$settings?.widescreenMode ?? null class="flex flex-col justify-between px-5 mb-3 {($settings?.widescreenMode ?? null)
? 'max-w-full' ? 'max-w-full'
: 'max-w-5xl'} mx-auto rounded-lg group" : 'max-w-5xl'} mx-auto rounded-lg group"
> >
@ -317,10 +317,10 @@
{message} {message}
isFirstMessage={messageIdx === 0} isFirstMessage={messageIdx === 0}
siblings={message.parentId !== null siblings={message.parentId !== null
? history.messages[message.parentId]?.childrenIds ?? [] ? (history.messages[message.parentId]?.childrenIds ?? [])
: Object.values(history.messages) : (Object.values(history.messages)
.filter((message) => message.parentId === null) .filter((message) => message.parentId === null)
.map((message) => message.id) ?? []} .map((message) => message.id) ?? [])}
{confirmEditMessage} {confirmEditMessage}
{showPreviousMessage} {showPreviousMessage}
{showNextMessage} {showNextMessage}

View File

@ -60,8 +60,8 @@
href={document?.metadata?.file_id href={document?.metadata?.file_id
? `/api/v1/files/${document?.metadata?.file_id}/content` ? `/api/v1/files/${document?.metadata?.file_id}/content`
: document.source.name.includes('http') : document.source.name.includes('http')
? document.source.name ? document.source.name
: `#`} : `#`}
target="_blank" target="_blank"
> >
{document?.metadata?.name ?? document.source.name} {document?.metadata?.name ?? document.source.name}

View File

@ -191,7 +191,7 @@
const res = await synthesizeOpenAISpeech( const res = await synthesizeOpenAISpeech(
localStorage.token, localStorage.token,
$settings?.audio?.tts?.defaultVoice === $config.audio.tts.voice $settings?.audio?.tts?.defaultVoice === $config.audio.tts.voice
? $settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice ? ($settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice)
: $config?.audio?.tts?.voice, : $config?.audio?.tts?.voice,
sentence sentence
).catch((error) => { ).catch((error) => {
@ -803,7 +803,7 @@
100 100
) / 100 ) / 100
} tokens` ?? 'N/A' } tokens` ?? 'N/A'
}<br/> }<br/>
prompt_token/s: ${ prompt_token/s: ${
Math.round( Math.round(
((message.info.prompt_eval_count ?? 0) / ((message.info.prompt_eval_count ?? 0) /

View File

@ -62,8 +62,8 @@
{#if !($settings?.chatBubble ?? true)} {#if !($settings?.chatBubble ?? true)}
<ProfileImage <ProfileImage
src={message.user src={message.user
? $models.find((m) => m.id === message.user)?.info?.meta?.profile_image_url ?? '/user.png' ? ($models.find((m) => m.id === message.user)?.info?.meta?.profile_image_url ?? '/user.png')
: user?.profile_image_url ?? '/user.png'} : (user?.profile_image_url ?? '/user.png')}
/> />
{/if} {/if}
<div class="w-full overflow-hidden pl-1"> <div class="w-full overflow-hidden pl-1">
@ -96,7 +96,7 @@
{#if message.files} {#if message.files}
<div class="mt-2.5 mb-1 w-full flex flex-col justify-end overflow-x-auto gap-1 flex-wrap"> <div class="mt-2.5 mb-1 w-full flex flex-col justify-end overflow-x-auto gap-1 flex-wrap">
{#each message.files as file} {#each message.files as file}
<div class={$settings?.chatBubble ?? true ? 'self-end' : ''}> <div class={($settings?.chatBubble ?? true) ? 'self-end' : ''}>
{#if file.type === 'image'} {#if file.type === 'image'}
<img src={file.url} alt="input" class=" max-h-96 rounded-lg" draggable="false" /> <img src={file.url} alt="input" class=" max-h-96 rounded-lg" draggable="false" />
{:else} {:else}
@ -162,12 +162,12 @@
</div> </div>
{:else} {:else}
<div class="w-full"> <div class="w-full">
<div class="flex {$settings?.chatBubble ?? true ? 'justify-end' : ''} mb-2"> <div class="flex {($settings?.chatBubble ?? true) ? 'justify-end' : ''} mb-2">
<div <div
class="rounded-3xl {$settings?.chatBubble ?? true class="rounded-3xl {($settings?.chatBubble ?? true)
? `max-w-[90%] px-5 py-2 bg-gray-50 dark:bg-gray-850 ${ ? `max-w-[90%] px-5 py-2 bg-gray-50 dark:bg-gray-850 ${
message.files ? 'rounded-tr-lg' : '' message.files ? 'rounded-tr-lg' : ''
}` }`
: ''} " : ''} "
> >
<pre id="user-message">{message.content}</pre> <pre id="user-message">{message.content}</pre>
@ -175,7 +175,7 @@
</div> </div>
<div <div
class=" flex {$settings?.chatBubble ?? true class=" flex {($settings?.chatBubble ?? true)
? 'justify-end' ? 'justify-end'
: ''} text-gray-600 dark:text-gray-500" : ''} text-gray-600 dark:text-gray-500"
> >

View File

@ -66,7 +66,7 @@
$: filteredItems = searchValue $: filteredItems = searchValue
? fuse.search(searchValue).map((e) => { ? fuse.search(searchValue).map((e) => {
return e.item; return e.item;
}) })
: items.filter((item) => !item.model?.info?.meta?.hidden); : items.filter((item) => !item.model?.info?.meta?.hidden);
const pullModelHandler = async () => { const pullModelHandler = async () => {

View File

@ -65,8 +65,8 @@
{updateAvailable === null {updateAvailable === null
? $i18n.t('Checking for updates...') ? $i18n.t('Checking for updates...')
: updateAvailable : updateAvailable
? `(v${version.latest} ${$i18n.t('available!')})` ? `(v${version.latest} ${$i18n.t('available!')})`
: $i18n.t('(latest)')} : $i18n.t('(latest)')}
</a> </a>
</div> </div>

View File

@ -27,7 +27,7 @@
on:click={() => { on:click={() => {
valves[property] = valves[property] =
(valves[property] ?? null) === null (valves[property] ?? null) === null
? valvesSpec.properties[property]?.default ?? '' ? (valvesSpec.properties[property]?.default ?? '')
: null; : null;
dispatch('change'); dispatch('change');

View File

@ -83,8 +83,8 @@
class=" w-full flex justify-between rounded-xl px-3 py-2 {chat.id === $chatId || confirmEdit class=" w-full flex justify-between rounded-xl px-3 py-2 {chat.id === $chatId || confirmEdit
? 'bg-gray-200 dark:bg-gray-900' ? 'bg-gray-200 dark:bg-gray-900'
: selected : selected
? 'bg-gray-100 dark:bg-gray-950' ? 'bg-gray-100 dark:bg-gray-950'
: 'group-hover:bg-gray-100 dark:group-hover:bg-gray-950'} whitespace-nowrap text-ellipsis" : 'group-hover:bg-gray-100 dark:group-hover:bg-gray-950'} whitespace-nowrap text-ellipsis"
> >
<input <input
use:focusEdit use:focusEdit
@ -97,8 +97,8 @@
class=" w-full flex justify-between rounded-xl px-3 py-2 {chat.id === $chatId || confirmEdit class=" w-full flex justify-between rounded-xl px-3 py-2 {chat.id === $chatId || confirmEdit
? 'bg-gray-200 dark:bg-gray-900' ? 'bg-gray-200 dark:bg-gray-900'
: selected : selected
? 'bg-gray-100 dark:bg-gray-950' ? 'bg-gray-100 dark:bg-gray-950'
: ' group-hover:bg-gray-100 dark:group-hover:bg-gray-950'} whitespace-nowrap text-ellipsis" : ' group-hover:bg-gray-100 dark:group-hover:bg-gray-950'} whitespace-nowrap text-ellipsis"
href="/c/{chat.id}" href="/c/{chat.id}"
on:click={() => { on:click={() => {
dispatch('select'); dispatch('select');
@ -134,8 +134,8 @@
{chat.id === $chatId || confirmEdit {chat.id === $chatId || confirmEdit
? 'from-gray-200 dark:from-gray-900' ? 'from-gray-200 dark:from-gray-900'
: selected : selected
? 'from-gray-100 dark:from-gray-950' ? 'from-gray-100 dark:from-gray-950'
: 'invisible group-hover:visible from-gray-100 dark:from-gray-950'} : 'invisible group-hover:visible from-gray-100 dark:from-gray-950'}
absolute right-[10px] top-[6px] py-1 pr-2 pl-5 bg-gradient-to-l from-80% absolute right-[10px] top-[6px] py-1 pr-2 pl-5 bg-gradient-to-l from-80%
to-transparent" to-transparent"

View File

@ -121,7 +121,7 @@
? { ? {
role: 'system', role: 'system',
content: system content: system
} }
: undefined, : undefined,
...messages ...messages
].filter((message) => message) ].filter((message) => message)

View File

@ -88,7 +88,7 @@
tags?.length > 0 tags?.length > 0
? { ? {
tags: tags tags: tags
} }
: null : null
).catch((error) => { ).catch((error) => {
toast.error(error); toast.error(error);

View File

@ -292,7 +292,7 @@
> >
<div class=" self-start w-8 pt-0.5"> <div class=" self-start w-8 pt-0.5">
<div <div
class=" rounded-full bg-stone-700 {model?.info?.meta?.hidden ?? false class=" rounded-full bg-stone-700 {(model?.info?.meta?.hidden ?? false)
? 'brightness-90 dark:brightness-50' ? 'brightness-90 dark:brightness-50'
: ''} " : ''} "
> >
@ -305,7 +305,7 @@
</div> </div>
<div <div
class=" flex-1 self-center {model?.info?.meta?.hidden ?? false ? 'text-gray-500' : ''}" class=" flex-1 self-center {(model?.info?.meta?.hidden ?? false) ? 'text-gray-500' : ''}"
> >
<div class=" font-semibold line-clamp-1">{model.name}</div> <div class=" font-semibold line-clamp-1">{model.name}</div>
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1"> <div class=" text-xs overflow-hidden text-ellipsis line-clamp-1">

View File

@ -25,7 +25,7 @@
title: $i18n.t('All Documents'), title: $i18n.t('All Documents'),
collection_names: $documents.map((doc) => doc.collection_name) collection_names: $documents.map((doc) => doc.collection_name)
} }
] ]
: []), : []),
...$documents ...$documents
.reduce((a, e, i, arr) => { .reduce((a, e, i, arr) => {

View File

@ -227,7 +227,7 @@ export const generateInitialsImage = (name) => {
const initials = const initials =
sanitizedName.length > 0 sanitizedName.length > 0
? sanitizedName[0] + ? sanitizedName[0] +
(sanitizedName.split(' ').length > 1 (sanitizedName.split(' ').length > 1
? sanitizedName[sanitizedName.lastIndexOf(' ') + 1] ? sanitizedName[sanitizedName.lastIndexOf(' ') + 1]
: '') : '')
: ''; : '';
@ -286,7 +286,7 @@ export const compareVersion = (latest, current) => {
numeric: true, numeric: true,
sensitivity: 'case', sensitivity: 'case',
caseFirst: 'upper' caseFirst: 'upper'
}) < 0; }) < 0;
}; };
export const findWordIndices = (text) => { export const findWordIndices = (text) => {

View File

@ -1,80 +1,83 @@
import katex from 'katex'; import katex from 'katex';
const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/; const inlineRule =
/^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/;
const inlineRuleNonStandard = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1/; // Non-standard, even if there are no spaces before and after $ or $$, try to parse const inlineRuleNonStandard = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1/; // Non-standard, even if there are no spaces before and after $ or $$, try to parse
const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/; const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
export default function(options = {}) { export default function (options = {}) {
return { return {
extensions: [ extensions: [
inlineKatex(options, createRenderer(options, false)), inlineKatex(options, createRenderer(options, false)),
blockKatex(options, createRenderer(options, true)), blockKatex(options, createRenderer(options, true))
], ]
}; };
} }
function createRenderer(options, newlineAfter) { function createRenderer(options, newlineAfter) {
return (token) => katex.renderToString(token.text, { ...options, displayMode: token.displayMode }) + (newlineAfter ? '\n' : ''); return (token) =>
katex.renderToString(token.text, { ...options, displayMode: token.displayMode }) +
(newlineAfter ? '\n' : '');
} }
function inlineKatex(options, renderer) { function inlineKatex(options, renderer) {
const nonStandard = options && options.nonStandard; const nonStandard = options && options.nonStandard;
const ruleReg = nonStandard ? inlineRuleNonStandard : inlineRule; const ruleReg = nonStandard ? inlineRuleNonStandard : inlineRule;
return { return {
name: 'inlineKatex', name: 'inlineKatex',
level: 'inline', level: 'inline',
start(src) { start(src) {
let index; let index;
let indexSrc = src; let indexSrc = src;
while (indexSrc) { while (indexSrc) {
index = indexSrc.indexOf('$'); index = indexSrc.indexOf('$');
if (index === -1) { if (index === -1) {
return; return;
} }
const f = nonStandard ? index > -1 : index === 0 || indexSrc.charAt(index - 1) === ' '; const f = nonStandard ? index > -1 : index === 0 || indexSrc.charAt(index - 1) === ' ';
if (f) { if (f) {
const possibleKatex = indexSrc.substring(index); const possibleKatex = indexSrc.substring(index);
if (possibleKatex.match(ruleReg)) { if (possibleKatex.match(ruleReg)) {
return index; return index;
} }
} }
indexSrc = indexSrc.substring(index + 1).replace(/^\$+/, ''); indexSrc = indexSrc.substring(index + 1).replace(/^\$+/, '');
} }
}, },
tokenizer(src, tokens) { tokenizer(src, tokens) {
const match = src.match(ruleReg); const match = src.match(ruleReg);
if (match) { if (match) {
return { return {
type: 'inlineKatex', type: 'inlineKatex',
raw: match[0], raw: match[0],
text: match[2].trim(), text: match[2].trim(),
displayMode: match[1].length === 2, displayMode: match[1].length === 2
}; };
} }
}, },
renderer, renderer
}; };
} }
function blockKatex(options, renderer) { function blockKatex(options, renderer) {
return { return {
name: 'blockKatex', name: 'blockKatex',
level: 'block', level: 'block',
tokenizer(src, tokens) { tokenizer(src, tokens) {
const match = src.match(blockRule); const match = src.match(blockRule);
if (match) { if (match) {
return { return {
type: 'blockKatex', type: 'blockKatex',
raw: match[0], raw: match[0],
text: match[2].trim(), text: match[2].trim(),
displayMode: match[1].length === 2, displayMode: match[1].length === 2
}; };
} }
}, },
renderer, renderer
}; };
} }

View File

@ -143,7 +143,7 @@
: { : {
id: model.id, id: model.id,
name: model.name name: model.name
} }
) )
) )
}; };
@ -154,9 +154,9 @@
params = { ...params, ...model?.info?.params }; params = { ...params, ...model?.info?.params };
params.stop = params?.stop params.stop = params?.stop
? (typeof params.stop === 'string' ? params.stop.split(',') : params?.stop ?? []).join( ? (typeof params.stop === 'string' ? params.stop.split(',') : (params?.stop ?? [])).join(
',' ','
) )
: null; : null;
if (model?.info?.meta?.knowledge) { if (model?.info?.meta?.knowledge) {

View File

@ -352,8 +352,23 @@
<style> <style>
.font-mona { .font-mona {
font-family: 'Mona Sans', -apple-system, 'Inter', ui-sans-serif, system-ui, 'Segoe UI', Roboto, font-family:
Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Mona Sans',
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; -apple-system,
'Inter',
ui-sans-serif,
system-ui,
'Segoe UI',
Roboto,
Ubuntu,
Cantarell,
'Noto Sans',
sans-serif,
'Helvetica Neue',
Arial,
'Apple Color Emoji',
'Segoe UI Emoji',
'Segoe UI Symbol',
'Noto Color Emoji';
} }
</style> </style>