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
0c441b58
Commit
0c441b58
authored
Apr 14, 2024
by
Timothy J. Baek
Browse files
refac: naming convention
parent
a938ffb5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
7 deletions
+8
-7
src/lib/apis/ollama/index.ts
src/lib/apis/ollama/index.ts
+2
-2
src/lib/apis/openai/index.ts
src/lib/apis/openai/index.ts
+2
-2
src/lib/utils/index.ts
src/lib/utils/index.ts
+4
-3
No files found.
src/lib/apis/ollama/index.ts
View file @
0c441b58
import
{
OLLAMA_API_BASE_URL
}
from
'
$lib/constants
'
;
import
{
t
emplate
Prompt
}
from
'
$lib/utils
'
;
import
{
promptT
emplate
}
from
'
$lib/utils
'
;
export
const
getOllamaUrls
=
async
(
token
:
string
=
''
)
=>
{
let
error
=
null
;
...
...
@@ -145,7 +145,7 @@ export const generateTitle = async (
)
=>
{
let
error
=
null
;
template
=
t
emplate
Prompt
(
template
,
prompt
);
template
=
promptT
emplate
(
template
,
prompt
);
console
.
log
(
template
);
...
...
src/lib/apis/openai/index.ts
View file @
0c441b58
import
{
OPENAI_API_BASE_URL
}
from
'
$lib/constants
'
;
import
{
t
emplate
Prompt
}
from
'
$lib/utils
'
;
import
{
promptT
emplate
}
from
'
$lib/utils
'
;
export
const
getOpenAIUrls
=
async
(
token
:
string
=
''
)
=>
{
let
error
=
null
;
...
...
@@ -274,7 +274,7 @@ export const generateTitle = async (
)
=>
{
let
error
=
null
;
template
=
t
emplate
Prompt
(
template
,
prompt
);
template
=
promptT
emplate
(
template
,
prompt
);
console
.
log
(
template
);
...
...
src/lib/utils/index.ts
View file @
0c441b58
...
...
@@ -468,12 +468,12 @@ export const blobToFile = (blob, fileName) => {
return
file
;
};
//
t
emplate
Prompt
replaces any occurrences of the following in the template with the prompt
//
promptT
emplate replaces any occurrences of the following in the template with the prompt
// {{prompt}} will be replaced with the prompt
// {{prompt:start:<length>}} will be replaced with the first <length> characters of the prompt
// {{prompt:end:<length>}} will be replaced with the last <length> characters of the prompt
// Character length is used as we don't have the ability to tokenize the prompt
export
const
t
emplate
Prompt
=
(
template
:
string
,
prompt
:
string
)
=>
{
export
const
promptT
emplate
=
(
template
:
string
,
prompt
:
string
)
=>
{
template
=
template
.
replace
(
/{{prompt}}/g
,
prompt
);
// Replace all instances of {{prompt:start:<length>}} with the first <length> characters of the prompt
...
...
@@ -493,7 +493,8 @@ export const templatePrompt = (template: string, prompt: string) => {
}
return
template
;
};
export
const
approximateToHumanReadable
=
(
nanoseconds
:
number
)
=>
{
const
seconds
=
Math
.
floor
((
nanoseconds
/
1
e9
)
%
60
);
const
minutes
=
Math
.
floor
((
nanoseconds
/
6
e10
)
%
60
);
...
...
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