Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
7ef5aa52
Commit
7ef5aa52
authored
Aug 13, 2024
by
Timothy J. Baek
Browse files
chore: format
parent
70f580ec
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
70 deletions
+88
-70
src/lib/utils/index.ts
src/lib/utils/index.ts
+2
-2
src/lib/utils/katex-extension.ts
src/lib/utils/katex-extension.ts
+65
-62
src/routes/(app)/workspace/models/edit/+page.svelte
src/routes/(app)/workspace/models/edit/+page.svelte
+3
-3
src/routes/auth/+page.svelte
src/routes/auth/+page.svelte
+18
-3
No files found.
src/lib/utils/index.ts
View file @
7ef5aa52
...
...
@@ -227,7 +227,7 @@ export const generateInitialsImage = (name) => {
const
initials
=
sanitizedName
.
length
>
0
?
sanitizedName
[
0
]
+
(
sanitizedName
.
split
(
'
'
).
length
>
1
(
sanitizedName
.
split
(
'
'
).
length
>
1
?
sanitizedName
[
sanitizedName
.
lastIndexOf
(
'
'
)
+
1
]
:
''
)
:
''
;
...
...
@@ -286,7 +286,7 @@ export const compareVersion = (latest, current) => {
numeric
:
true
,
sensitivity
:
'
case
'
,
caseFirst
:
'
upper
'
})
<
0
;
})
<
0
;
};
export
const
findWordIndices
=
(
text
)
=>
{
...
...
src/lib/utils/katex-extension.ts
View file @
7ef5aa52
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
blockRule
=
/^
(\${1,2})\n((?:\\[^]
|
[^\\])
+
?)\n\1(?:\n
|$
)
/
;
export
default
function
(
options
=
{})
{
return
{
extensions
:
[
inlineKatex
(
options
,
createRenderer
(
options
,
false
)),
blockKatex
(
options
,
createRenderer
(
options
,
true
))
,
],
};
export
default
function
(
options
=
{})
{
return
{
extensions
:
[
inlineKatex
(
options
,
createRenderer
(
options
,
false
)),
blockKatex
(
options
,
createRenderer
(
options
,
true
))
]
};
}
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
)
{
const
nonStandard
=
options
&&
options
.
nonStandard
;
const
ruleReg
=
nonStandard
?
inlineRuleNonStandard
:
inlineRule
;
return
{
name
:
'
inlineKatex
'
,
level
:
'
inline
'
,
start
(
src
)
{
let
index
;
let
indexSrc
=
src
;
const
nonStandard
=
options
&&
options
.
nonStandard
;
const
ruleReg
=
nonStandard
?
inlineRuleNonStandard
:
inlineRule
;
return
{
name
:
'
inlineKatex
'
,
level
:
'
inline
'
,
start
(
src
)
{
let
index
;
let
indexSrc
=
src
;
while
(
indexSrc
)
{
index
=
indexSrc
.
indexOf
(
'
$
'
);
if
(
index
===
-
1
)
{
return
;
}
const
f
=
nonStandard
?
index
>
-
1
:
index
===
0
||
indexSrc
.
charAt
(
index
-
1
)
===
'
'
;
if
(
f
)
{
const
possibleKatex
=
indexSrc
.
substring
(
index
);
while
(
indexSrc
)
{
index
=
indexSrc
.
indexOf
(
'
$
'
);
if
(
index
===
-
1
)
{
return
;
}
const
f
=
nonStandard
?
index
>
-
1
:
index
===
0
||
indexSrc
.
charAt
(
index
-
1
)
===
'
'
;
if
(
f
)
{
const
possibleKatex
=
indexSrc
.
substring
(
index
);
if
(
possibleKatex
.
match
(
ruleReg
))
{
return
index
;
}
}
if
(
possibleKatex
.
match
(
ruleReg
))
{
return
index
;
}
}
indexSrc
=
indexSrc
.
substring
(
index
+
1
).
replace
(
/^
\$
+/
,
''
);
}
},
tokenizer
(
src
,
tokens
)
{
const
match
=
src
.
match
(
ruleReg
);
if
(
match
)
{
return
{
type
:
'
inlineKatex
'
,
raw
:
match
[
0
],
text
:
match
[
2
].
trim
(),
displayMode
:
match
[
1
].
length
===
2
,
};
}
},
renderer
,
};
indexSrc
=
indexSrc
.
substring
(
index
+
1
).
replace
(
/^
\$
+/
,
''
);
}
},
tokenizer
(
src
,
tokens
)
{
const
match
=
src
.
match
(
ruleReg
);
if
(
match
)
{
return
{
type
:
'
inlineKatex
'
,
raw
:
match
[
0
],
text
:
match
[
2
].
trim
(),
displayMode
:
match
[
1
].
length
===
2
};
}
},
renderer
};
}
function
blockKatex
(
options
,
renderer
)
{
return
{
name
:
'
blockKatex
'
,
level
:
'
block
'
,
tokenizer
(
src
,
tokens
)
{
const
match
=
src
.
match
(
blockRule
);
if
(
match
)
{
return
{
type
:
'
blockKatex
'
,
raw
:
match
[
0
],
text
:
match
[
2
].
trim
(),
displayMode
:
match
[
1
].
length
===
2
,
};
}
},
renderer
,
};
}
\ No newline at end of file
return
{
name
:
'
blockKatex
'
,
level
:
'
block
'
,
tokenizer
(
src
,
tokens
)
{
const
match
=
src
.
match
(
blockRule
);
if
(
match
)
{
return
{
type
:
'
blockKatex
'
,
raw
:
match
[
0
],
text
:
match
[
2
].
trim
(),
displayMode
:
match
[
1
].
length
===
2
};
}
},
renderer
};
}
src/routes/(app)/workspace/models/edit/+page.svelte
View file @
7ef5aa52
...
...
@@ -143,7 +143,7 @@
:
{
id
:
model
.
id
,
name
:
model
.
name
}
}
)
)
};
...
...
@@ -154,9 +154,9 @@
params
=
{
...
params
,
...
model
?.
info
?.
params
};
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
;
if
(
model
?.
info
?.
meta
?.
knowledge
)
{
...
...
src/routes/auth/+page.svelte
View file @
7ef5aa52
...
...
@@ -352,8 +352,23 @@
<style>
.font-mona {
font-family: 'Mona Sans', -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';
font-family:
'Mona Sans',
-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>
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment