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
8acb2336
Commit
8acb2336
authored
May 01, 2024
by
Michael Yang
Browse files
use strings.Builder
parent
119589fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
types/model/file.go
types/model/file.go
+6
-10
No files found.
types/model/file.go
View file @
8acb2336
...
@@ -29,24 +29,20 @@ type Command struct {
...
@@ -29,24 +29,20 @@ type Command struct {
}
}
func
(
c
Command
)
String
()
string
{
func
(
c
Command
)
String
()
string
{
name
:=
c
.
Name
var
sb
strings
.
Builder
args
:=
c
.
Args
switch
c
.
Name
{
switch
c
.
Name
{
case
"model"
:
case
"model"
:
name
=
"from"
fmt
.
Fprintf
(
&
sb
,
"FROM %s"
,
c
.
Args
)
args
=
c
.
Args
case
"license"
,
"template"
,
"system"
,
"adapter"
:
case
"license"
,
"template"
,
"system"
,
"adapter"
:
args
=
quote
(
a
rgs
)
fmt
.
Fprintf
(
&
sb
,
"%s %s"
,
strings
.
ToUpper
(
c
.
Name
),
quote
(
c
.
A
rgs
)
)
case
"message"
:
case
"message"
:
role
,
message
,
_
:=
strings
.
Cut
(
c
.
Args
,
": "
)
role
,
message
,
_
:=
strings
.
Cut
(
c
.
Args
,
": "
)
args
=
role
+
" "
+
quote
(
message
)
fmt
.
Fprintf
(
&
sb
,
"MESSAGE %s %s"
,
role
,
quote
(
message
)
)
default
:
default
:
name
=
"parameter"
fmt
.
Fprintf
(
&
sb
,
"PARAMETER %s %s"
,
c
.
Name
,
quote
(
c
.
Args
))
args
=
c
.
Name
+
" "
+
quote
(
c
.
Args
)
}
}
return
fmt
.
Sprintf
(
"%s %s"
,
strings
.
ToUpper
(
name
),
args
)
return
sb
.
String
(
)
}
}
type
state
int
type
state
int
...
...
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