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
01d155c9
Unverified
Commit
01d155c9
authored
Jul 27, 2023
by
Patrick Devine
Committed by
GitHub
Jul 27, 2023
Browse files
show system/template/license layers from cmd prompt (#223)
parent
5685c16d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
cmd/cmd.go
cmd/cmd.go
+64
-0
No files found.
cmd/cmd.go
View file @
01d155c9
...
@@ -302,6 +302,16 @@ func generate(cmd *cobra.Command, model, prompt string) error {
...
@@ -302,6 +302,16 @@ func generate(cmd *cobra.Command, model, prompt string) error {
return
nil
return
nil
}
}
func
showLayer
(
l
*
server
.
Layer
)
{
filename
,
err
:=
server
.
GetBlobsPath
(
l
.
Digest
)
bts
,
err
:=
os
.
ReadFile
(
filename
)
if
err
!=
nil
{
fmt
.
Printf
(
"Couldn't read layer"
)
return
}
fmt
.
Printf
(
string
(
bts
)
+
"
\n
"
)
}
func
generateInteractive
(
cmd
*
cobra
.
Command
,
model
string
)
error
{
func
generateInteractive
(
cmd
*
cobra
.
Command
,
model
string
)
error
{
home
,
err
:=
os
.
UserHomeDir
()
home
,
err
:=
os
.
UserHomeDir
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -322,6 +332,11 @@ func generateInteractive(cmd *cobra.Command, model string) error {
...
@@ -322,6 +332,11 @@ func generateInteractive(cmd *cobra.Command, model string) error {
readline
.
PcItem
(
"default"
),
readline
.
PcItem
(
"default"
),
),
),
),
),
readline
.
PcItem
(
"/show"
,
readline
.
PcItem
(
"license"
),
readline
.
PcItem
(
"system"
),
readline
.
PcItem
(
"template"
),
),
readline
.
PcItem
(
"/exit"
),
readline
.
PcItem
(
"/exit"
),
readline
.
PcItem
(
"/bye"
),
readline
.
PcItem
(
"/bye"
),
)
)
...
@@ -393,9 +408,58 @@ func generateInteractive(cmd *cobra.Command, model string) error {
...
@@ -393,9 +408,58 @@ func generateInteractive(cmd *cobra.Command, model string) error {
case
"emacs"
,
"default"
:
case
"emacs"
,
"default"
:
scanner
.
SetVimMode
(
false
)
scanner
.
SetVimMode
(
false
)
continue
continue
default
:
usage
()
continue
}
}
else
{
usage
()
continue
}
}
}
else
{
usage
()
continue
}
case
strings
.
HasPrefix
(
line
,
"/show"
)
:
args
:=
strings
.
Fields
(
line
)
if
len
(
args
)
>
1
{
mp
:=
server
.
ParseModelPath
(
model
)
manifest
,
err
:=
server
.
GetManifest
(
mp
)
if
err
!=
nil
{
fmt
.
Printf
(
"error: couldn't get a manifestfor this model"
)
continue
}
switch
args
[
1
]
{
case
"license"
:
for
_
,
l
:=
range
manifest
.
Layers
{
if
l
.
MediaType
==
"application/vnd.ollama.image.license"
{
showLayer
(
l
)
}
}
continue
case
"system"
:
for
_
,
l
:=
range
manifest
.
Layers
{
if
l
.
MediaType
==
"application/vnd.ollama.image.system"
{
showLayer
(
l
)
}
}
continue
case
"template"
:
for
_
,
l
:=
range
manifest
.
Layers
{
if
l
.
MediaType
==
"application/vnd.ollama.image.template"
{
showLayer
(
l
)
}
}
}
}
continue
default
:
usage
()
continue
}
}
}
else
{
usage
()
continue
}
}
case
line
==
"/help"
,
line
==
"/?"
:
case
line
==
"/help"
,
line
==
"/?"
:
usage
()
usage
()
...
...
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