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
057d3186
"git@developer.sourcefind.cn:OpenDAS/torch-cluster.git" did not exist on "dfe188ab6e9105ecb26d04f09e94be92a0ce4f66"
Unverified
Commit
057d3186
authored
Jul 13, 2024
by
Patrick Devine
Committed by
GitHub
Jul 13, 2024
Browse files
remove template (#5655)
parent
f7ee0123
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
50 deletions
+16
-50
api/types.go
api/types.go
+2
-0
cmd/cmd.go
cmd/cmd.go
+0
-2
cmd/interactive.go
cmd/interactive.go
+14
-38
cmd/interactive_test.go
cmd/interactive_test.go
+0
-3
server/routes.go
server/routes.go
+0
-7
No files found.
api/types.go
View file @
057d3186
...
@@ -221,6 +221,8 @@ type DeleteRequest struct {
...
@@ -221,6 +221,8 @@ type DeleteRequest struct {
type
ShowRequest
struct
{
type
ShowRequest
struct
{
Model
string
`json:"model"`
Model
string
`json:"model"`
System
string
`json:"system"`
System
string
`json:"system"`
// Template is deprecated
Template
string
`json:"template"`
Template
string
`json:"template"`
Verbose
bool
`json:"verbose"`
Verbose
bool
`json:"verbose"`
...
...
cmd/cmd.go
View file @
057d3186
...
@@ -843,7 +843,6 @@ type runOptions struct {
...
@@ -843,7 +843,6 @@ type runOptions struct {
WordWrap
bool
WordWrap
bool
Format
string
Format
string
System
string
System
string
Template
string
Images
[]
api
.
ImageData
Images
[]
api
.
ImageData
Options
map
[
string
]
interface
{}
Options
map
[
string
]
interface
{}
MultiModal
bool
MultiModal
bool
...
@@ -1037,7 +1036,6 @@ func generate(cmd *cobra.Command, opts runOptions) error {
...
@@ -1037,7 +1036,6 @@ func generate(cmd *cobra.Command, opts runOptions) error {
Images
:
opts
.
Images
,
Images
:
opts
.
Images
,
Format
:
opts
.
Format
,
Format
:
opts
.
Format
,
System
:
opts
.
System
,
System
:
opts
.
System
,
Template
:
opts
.
Template
,
Options
:
opts
.
Options
,
Options
:
opts
.
Options
,
KeepAlive
:
opts
.
KeepAlive
,
KeepAlive
:
opts
.
KeepAlive
,
}
}
...
...
cmd/interactive.go
View file @
057d3186
...
@@ -27,7 +27,6 @@ const (
...
@@ -27,7 +27,6 @@ const (
MultilineNone
MultilineState
=
iota
MultilineNone
MultilineState
=
iota
MultilinePrompt
MultilinePrompt
MultilineSystem
MultilineSystem
MultilineTemplate
)
)
func
loadModel
(
cmd
*
cobra
.
Command
,
opts
*
runOptions
)
error
{
func
loadModel
(
cmd
*
cobra
.
Command
,
opts
*
runOptions
)
error
{
...
@@ -94,7 +93,6 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
...
@@ -94,7 +93,6 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
fmt
.
Fprintln
(
os
.
Stderr
,
"Available Commands:"
)
fmt
.
Fprintln
(
os
.
Stderr
,
"Available Commands:"
)
fmt
.
Fprintln
(
os
.
Stderr
,
" /set parameter ... Set a parameter"
)
fmt
.
Fprintln
(
os
.
Stderr
,
" /set parameter ... Set a parameter"
)
fmt
.
Fprintln
(
os
.
Stderr
,
" /set system <string> Set system message"
)
fmt
.
Fprintln
(
os
.
Stderr
,
" /set system <string> Set system message"
)
fmt
.
Fprintln
(
os
.
Stderr
,
" /set template <string> Set prompt template"
)
fmt
.
Fprintln
(
os
.
Stderr
,
" /set history Enable history"
)
fmt
.
Fprintln
(
os
.
Stderr
,
" /set history Enable history"
)
fmt
.
Fprintln
(
os
.
Stderr
,
" /set nohistory Disable history"
)
fmt
.
Fprintln
(
os
.
Stderr
,
" /set nohistory Disable history"
)
fmt
.
Fprintln
(
os
.
Stderr
,
" /set wordwrap Enable wordwrap"
)
fmt
.
Fprintln
(
os
.
Stderr
,
" /set wordwrap Enable wordwrap"
)
...
@@ -204,10 +202,6 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
...
@@ -204,10 +202,6 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
opts
.
Messages
=
append
(
opts
.
Messages
,
api
.
Message
{
Role
:
"system"
,
Content
:
opts
.
System
})
opts
.
Messages
=
append
(
opts
.
Messages
,
api
.
Message
{
Role
:
"system"
,
Content
:
opts
.
System
})
fmt
.
Println
(
"Set system message."
)
fmt
.
Println
(
"Set system message."
)
sb
.
Reset
()
sb
.
Reset
()
case
MultilineTemplate
:
opts
.
Template
=
sb
.
String
()
fmt
.
Println
(
"Set prompt template."
)
sb
.
Reset
()
}
}
multiline
=
MultilineNone
multiline
=
MultilineNone
...
@@ -326,17 +320,13 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
...
@@ -326,17 +320,13 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
}
}
fmt
.
Printf
(
"Set parameter '%s' to '%s'
\n
"
,
args
[
2
],
strings
.
Join
(
params
,
", "
))
fmt
.
Printf
(
"Set parameter '%s' to '%s'
\n
"
,
args
[
2
],
strings
.
Join
(
params
,
", "
))
opts
.
Options
[
args
[
2
]]
=
fp
[
args
[
2
]]
opts
.
Options
[
args
[
2
]]
=
fp
[
args
[
2
]]
case
"system"
,
"template"
:
case
"system"
:
if
len
(
args
)
<
3
{
if
len
(
args
)
<
3
{
usageSet
()
usageSet
()
continue
continue
}
}
if
args
[
1
]
==
"system"
{
multiline
=
MultilineSystem
multiline
=
MultilineSystem
}
else
if
args
[
1
]
==
"template"
{
multiline
=
MultilineTemplate
}
line
:=
strings
.
Join
(
args
[
2
:
],
" "
)
line
:=
strings
.
Join
(
args
[
2
:
],
" "
)
line
,
ok
:=
strings
.
CutPrefix
(
line
,
`"""`
)
line
,
ok
:=
strings
.
CutPrefix
(
line
,
`"""`
)
...
@@ -356,23 +346,17 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
...
@@ -356,23 +346,17 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
continue
continue
}
}
if
args
[
1
]
==
"system"
{
opts
.
System
=
sb
.
String
()
// for display in modelfile
opts
.
System
=
sb
.
String
()
// for display in modelfile
newMessage
:=
api
.
Message
{
Role
:
"system"
,
Content
:
sb
.
String
()}
newMessage
:=
api
.
Message
{
Role
:
"system"
,
Content
:
sb
.
String
()}
// Check if the slice is not empty and the last message is from 'system'
// Check if the slice is not empty and the last message is from 'system'
if
len
(
opts
.
Messages
)
>
0
&&
opts
.
Messages
[
len
(
opts
.
Messages
)
-
1
]
.
Role
==
"system"
{
if
len
(
opts
.
Messages
)
>
0
&&
opts
.
Messages
[
len
(
opts
.
Messages
)
-
1
]
.
Role
==
"system"
{
// Replace the last message
// Replace the last message
opts
.
Messages
[
len
(
opts
.
Messages
)
-
1
]
=
newMessage
opts
.
Messages
[
len
(
opts
.
Messages
)
-
1
]
=
newMessage
}
else
{
}
else
{
opts
.
Messages
=
append
(
opts
.
Messages
,
newMessage
)
opts
.
Messages
=
append
(
opts
.
Messages
,
newMessage
)
}
fmt
.
Println
(
"Set system message."
)
sb
.
Reset
()
}
else
if
args
[
1
]
==
"template"
{
opts
.
Template
=
sb
.
String
()
fmt
.
Println
(
"Set prompt template."
)
sb
.
Reset
()
}
}
fmt
.
Println
(
"Set system message."
)
sb
.
Reset
()
sb
.
Reset
()
sb
.
Reset
()
continue
continue
...
@@ -393,7 +377,6 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
...
@@ -393,7 +377,6 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
req
:=
&
api
.
ShowRequest
{
req
:=
&
api
.
ShowRequest
{
Name
:
opts
.
Model
,
Name
:
opts
.
Model
,
System
:
opts
.
System
,
System
:
opts
.
System
,
Template
:
opts
.
Template
,
Options
:
opts
.
Options
,
Options
:
opts
.
Options
,
}
}
resp
,
err
:=
client
.
Show
(
cmd
.
Context
(),
req
)
resp
,
err
:=
client
.
Show
(
cmd
.
Context
(),
req
)
...
@@ -437,12 +420,9 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
...
@@ -437,12 +420,9 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
fmt
.
Println
(
"No system message was specified for this model."
)
fmt
.
Println
(
"No system message was specified for this model."
)
}
}
case
"template"
:
case
"template"
:
switch
{
if
resp
.
Template
!=
""
{
case
opts
.
Template
!=
""
:
fmt
.
Println
(
opts
.
Template
+
"
\n
"
)
case
resp
.
Template
!=
""
:
fmt
.
Println
(
resp
.
Template
)
fmt
.
Println
(
resp
.
Template
)
default
:
}
else
{
fmt
.
Println
(
"No prompt template was specified for this model."
)
fmt
.
Println
(
"No prompt template was specified for this model."
)
}
}
default
:
default
:
...
@@ -536,10 +516,6 @@ func buildModelfile(opts runOptions) string {
...
@@ -536,10 +516,6 @@ func buildModelfile(opts runOptions) string {
fmt
.
Fprintf
(
&
mf
,
"SYSTEM
\"\"\"
%s
\"\"\"\n
"
,
opts
.
System
)
fmt
.
Fprintf
(
&
mf
,
"SYSTEM
\"\"\"
%s
\"\"\"\n
"
,
opts
.
System
)
}
}
if
opts
.
Template
!=
""
{
fmt
.
Fprintf
(
&
mf
,
"TEMPLATE
\"\"\"
%s
\"\"\"\n
"
,
opts
.
Template
)
}
keys
:=
make
([]
string
,
0
)
keys
:=
make
([]
string
,
0
)
for
k
:=
range
opts
.
Options
{
for
k
:=
range
opts
.
Options
{
keys
=
append
(
keys
,
k
)
keys
=
append
(
keys
,
k
)
...
...
cmd/interactive_test.go
View file @
057d3186
...
@@ -59,7 +59,6 @@ func TestModelfileBuilder(t *testing.T) {
...
@@ -59,7 +59,6 @@ func TestModelfileBuilder(t *testing.T) {
opts
:=
runOptions
{
opts
:=
runOptions
{
Model
:
"hork"
,
Model
:
"hork"
,
System
:
"You are part horse and part shark, but all hork. Do horklike things"
,
System
:
"You are part horse and part shark, but all hork. Do horklike things"
,
Template
:
"This is a template."
,
Messages
:
[]
api
.
Message
{
Messages
:
[]
api
.
Message
{
{
Role
:
"user"
,
Content
:
"Hey there hork!"
},
{
Role
:
"user"
,
Content
:
"Hey there hork!"
},
{
Role
:
"assistant"
,
Content
:
"Yes it is true, I am half horse, half shark."
},
{
Role
:
"assistant"
,
Content
:
"Yes it is true, I am half horse, half shark."
},
...
@@ -75,7 +74,6 @@ func TestModelfileBuilder(t *testing.T) {
...
@@ -75,7 +74,6 @@ func TestModelfileBuilder(t *testing.T) {
mf
:=
buildModelfile
(
opts
)
mf
:=
buildModelfile
(
opts
)
expectedModelfile
:=
`FROM {{.Model}}
expectedModelfile
:=
`FROM {{.Model}}
SYSTEM """{{.System}}"""
SYSTEM """{{.System}}"""
TEMPLATE """{{.Template}}"""
PARAMETER penalize_newline false
PARAMETER penalize_newline false
PARAMETER seed 42
PARAMETER seed 42
PARAMETER stop [hi there]
PARAMETER stop [hi there]
...
@@ -97,7 +95,6 @@ MESSAGE assistant """Yes it is true, I am half horse, half shark."""
...
@@ -97,7 +95,6 @@ MESSAGE assistant """Yes it is true, I am half horse, half shark."""
mf
=
buildModelfile
(
opts
)
mf
=
buildModelfile
(
opts
)
expectedModelfile
=
`FROM {{.ParentModel}}
expectedModelfile
=
`FROM {{.ParentModel}}
SYSTEM """{{.System}}"""
SYSTEM """{{.System}}"""
TEMPLATE """{{.Template}}"""
PARAMETER penalize_newline false
PARAMETER penalize_newline false
PARAMETER seed 42
PARAMETER seed 42
PARAMETER stop [hi there]
PARAMETER stop [hi there]
...
...
server/routes.go
View file @
057d3186
...
@@ -574,13 +574,6 @@ func GetModelInfo(req api.ShowRequest) (*api.ShowResponse, error) {
...
@@ -574,13 +574,6 @@ func GetModelInfo(req api.ShowRequest) (*api.ShowResponse, error) {
m
.
System
=
req
.
System
m
.
System
=
req
.
System
}
}
if
req
.
Template
!=
""
{
m
.
Template
,
err
=
template
.
Parse
(
req
.
Template
)
if
err
!=
nil
{
return
nil
,
err
}
}
msgs
:=
make
([]
api
.
Message
,
len
(
m
.
Messages
))
msgs
:=
make
([]
api
.
Message
,
len
(
m
.
Messages
))
for
i
,
msg
:=
range
m
.
Messages
{
for
i
,
msg
:=
range
m
.
Messages
{
msgs
[
i
]
=
api
.
Message
{
Role
:
msg
.
Role
,
Content
:
msg
.
Content
}
msgs
[
i
]
=
api
.
Message
{
Role
:
msg
.
Role
,
Content
:
msg
.
Content
}
...
...
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