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
OpenDAS
ollama
Commits
1c8fd627
Commit
1c8fd627
authored
Aug 30, 2023
by
Michael Yang
Browse files
windows: fix create modelfile
parent
ae950b00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
16 deletions
+5
-16
server/images.go
server/images.go
+5
-16
No files found.
server/images.go
View file @
1c8fd627
...
@@ -235,8 +235,8 @@ func GetModel(name string) (*Model, error) {
...
@@ -235,8 +235,8 @@ func GetModel(name string) (*Model, error) {
func
filenameWithPath
(
path
,
f
string
)
(
string
,
error
)
{
func
filenameWithPath
(
path
,
f
string
)
(
string
,
error
)
{
// if filePath starts with ~/, replace it with the user's home directory.
// if filePath starts with ~/, replace it with the user's home directory.
if
strings
.
HasPrefix
(
f
,
"~/"
)
{
if
strings
.
HasPrefix
(
f
,
fmt
.
Sprintf
(
"~%s"
,
string
(
os
.
PathSeparator
))
)
{
parts
:=
strings
.
Split
(
f
,
"/"
)
parts
:=
strings
.
Split
(
f
,
string
(
os
.
PathSeparator
)
)
home
,
err
:=
os
.
UserHomeDir
()
home
,
err
:=
os
.
UserHomeDir
()
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"failed to open file: %v"
,
err
)
return
""
,
fmt
.
Errorf
(
"failed to open file: %v"
,
err
)
...
@@ -374,20 +374,9 @@ func CreateModel(ctx context.Context, name string, path string, fn func(resp api
...
@@ -374,20 +374,9 @@ func CreateModel(ctx context.Context, name string, path string, fn func(resp api
case
"adapter"
:
case
"adapter"
:
fn
(
api
.
ProgressResponse
{
Status
:
fmt
.
Sprintf
(
"creating model %s layer"
,
c
.
Name
)})
fn
(
api
.
ProgressResponse
{
Status
:
fmt
.
Sprintf
(
"creating model %s layer"
,
c
.
Name
)})
fp
:=
c
.
Args
fp
,
err
:=
filenameWithPath
(
path
,
c
.
Args
)
if
strings
.
HasPrefix
(
fp
,
"~/"
)
{
if
err
!=
nil
{
parts
:=
strings
.
Split
(
fp
,
"/"
)
return
err
home
,
err
:=
os
.
UserHomeDir
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to open file: %v"
,
err
)
}
fp
=
filepath
.
Join
(
home
,
filepath
.
Join
(
parts
[
1
:
]
...
))
}
// If filePath is not an absolute path, make it relative to the modelfile path
if
!
filepath
.
IsAbs
(
fp
)
{
fp
=
filepath
.
Join
(
filepath
.
Dir
(
path
),
fp
)
}
}
// create a model from this specified file
// create a model from this specified file
...
...
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