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
82f7b6c3
Commit
82f7b6c3
authored
Jun 03, 2024
by
Timothy J. Baek
Browse files
refac: modelfiles migration
parent
36a66fcf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
5 deletions
+27
-5
backend/utils/misc.py
backend/utils/misc.py
+27
-5
No files found.
backend/utils/misc.py
View file @
82f7b6c3
...
...
@@ -123,11 +123,25 @@ def parse_ollama_modelfile(model_text):
"repeat_penalty"
:
float
,
"temperature"
:
float
,
"seed"
:
int
,
"stop"
:
str
,
"tfs_z"
:
float
,
"num_predict"
:
int
,
"top_k"
:
int
,
"top_p"
:
float
,
"num_keep"
:
int
,
"typical_p"
:
float
,
"presence_penalty"
:
float
,
"frequency_penalty"
:
float
,
"penalize_newline"
:
bool
,
"numa"
:
bool
,
"num_batch"
:
int
,
"num_gpu"
:
int
,
"main_gpu"
:
int
,
"low_vram"
:
bool
,
"f16_kv"
:
bool
,
"vocab_only"
:
bool
,
"use_mmap"
:
bool
,
"use_mlock"
:
bool
,
"num_thread"
:
int
,
}
data
=
{
"base_model_id"
:
None
,
"params"
:
{}}
...
...
@@ -156,10 +170,18 @@ def parse_ollama_modelfile(model_text):
param_match
=
re
.
search
(
rf
"PARAMETER
{
param
}
(.+)"
,
model_text
,
re
.
IGNORECASE
)
if
param_match
:
value
=
param_match
.
group
(
1
)
try
:
if
param_type
==
int
:
value
=
int
(
value
)
elif
param_type
==
float
:
value
=
float
(
value
)
elif
param_type
==
bool
:
value
=
value
.
lower
()
==
"true"
except
Exception
as
e
:
print
(
e
)
continue
data
[
"params"
][
param
]
=
value
# Parse adapter
...
...
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