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
8dac2a21
Commit
8dac2a21
authored
Jun 26, 2024
by
Timothy J. Baek
Browse files
refac
parent
aad23af3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
2 deletions
+48
-2
backend/config.py
backend/config.py
+5
-2
src/lib/utils/index.ts
src/lib/utils/index.ts
+43
-0
No files found.
backend/config.py
View file @
8dac2a21
...
@@ -569,12 +569,15 @@ OLLAMA_API_BASE_URL = os.environ.get(
...
@@ -569,12 +569,15 @@ OLLAMA_API_BASE_URL = os.environ.get(
)
)
OLLAMA_BASE_URL
=
os
.
environ
.
get
(
"OLLAMA_BASE_URL"
,
""
)
OLLAMA_BASE_URL
=
os
.
environ
.
get
(
"OLLAMA_BASE_URL"
,
""
)
AIOHTTP_CLIENT_TIMEOUT
=
os
.
environ
.
get
(
"AIOHTTP_CLIENT_TIMEOUT"
,
"
300
"
)
AIOHTTP_CLIENT_TIMEOUT
=
os
.
environ
.
get
(
"AIOHTTP_CLIENT_TIMEOUT"
,
""
)
if
AIOHTTP_CLIENT_TIMEOUT
==
""
:
if
AIOHTTP_CLIENT_TIMEOUT
==
""
:
AIOHTTP_CLIENT_TIMEOUT
=
None
AIOHTTP_CLIENT_TIMEOUT
=
None
else
:
else
:
try
:
AIOHTTP_CLIENT_TIMEOUT
=
int
(
AIOHTTP_CLIENT_TIMEOUT
)
AIOHTTP_CLIENT_TIMEOUT
=
int
(
AIOHTTP_CLIENT_TIMEOUT
)
except
:
AIOHTTP_CLIENT_TIMEOUT
=
300
K8S_FLAG
=
os
.
environ
.
get
(
"K8S_FLAG"
,
""
)
K8S_FLAG
=
os
.
environ
.
get
(
"K8S_FLAG"
,
""
)
...
...
src/lib/utils/index.ts
View file @
8dac2a21
...
@@ -703,3 +703,46 @@ export const getTimeRange = (timestamp) => {
...
@@ -703,3 +703,46 @@ export const getTimeRange = (timestamp) => {
return
date
.
getFullYear
().
toString
();
return
date
.
getFullYear
().
toString
();
}
}
};
};
/**
* Extract frontmatter as a dictionary from the specified content string.
* @param content {string} - The content string with potential frontmatter.
* @returns {Object} - The extracted frontmatter as a dictionary.
*/
export
const
extractFrontmatter
=
(
content
)
=>
{
const
frontmatter
=
{};
let
frontmatterStarted
=
false
;
let
frontmatterEnded
=
false
;
const
frontmatterPattern
=
/^
\s
*
([
a-z_
]
+
)
:
\s
*
(
.*
)\s
*$/i
;
// Split content into lines
const
lines
=
content
.
split
(
'
\n
'
);
// Check if the content starts with triple quotes
if
(
lines
[
0
].
trim
()
!==
'
"""
'
)
{
return
{};
}
frontmatterStarted
=
true
;
for
(
let
i
=
1
;
i
<
lines
.
length
;
i
++
)
{
const
line
=
lines
[
i
];
if
(
line
.
includes
(
'
"""
'
))
{
if
(
frontmatterStarted
)
{
frontmatterEnded
=
true
;
break
;
}
}
if
(
frontmatterStarted
&&
!
frontmatterEnded
)
{
const
match
=
frontmatterPattern
.
exec
(
line
);
if
(
match
)
{
const
[,
key
,
value
]
=
match
;
frontmatter
[
key
.
trim
()]
=
value
.
trim
();
}
}
}
return
frontmatter
;
};
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