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
a250c2cb
Commit
a250c2cb
authored
Jul 26, 2024
by
Michael Yang
Browse files
display messages
parent
15af5584
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
23 deletions
+20
-23
cmd/cmd.go
cmd/cmd.go
+16
-0
cmd/interactive.go
cmd/interactive.go
+4
-23
No files found.
cmd/cmd.go
View file @
a250c2cb
...
...
@@ -364,6 +364,22 @@ func RunHandler(cmd *cobra.Command, args []string) error {
opts
.
ParentModel
=
info
.
Details
.
ParentModel
if
interactive
{
if
err
:=
loadModel
(
cmd
,
&
opts
);
err
!=
nil
{
return
err
}
for
_
,
msg
:=
range
info
.
Messages
{
switch
msg
.
Role
{
case
"user"
:
fmt
.
Printf
(
">>> %s
\n
"
,
msg
.
Content
)
case
"assistant"
:
state
:=
&
displayResponseState
{}
displayResponse
(
msg
.
Content
,
opts
.
WordWrap
,
state
)
fmt
.
Println
()
fmt
.
Println
()
}
}
return
generateInteractive
(
cmd
,
opts
)
}
return
generate
(
cmd
,
opts
)
...
...
cmd/interactive.go
View file @
a250c2cb
...
...
@@ -46,29 +46,10 @@ func loadModel(cmd *cobra.Command, opts *runOptions) error {
KeepAlive
:
opts
.
KeepAlive
,
}
return
client
.
Chat
(
cmd
.
Context
(),
chatReq
,
func
(
resp
api
.
ChatResponse
)
error
{
p
.
StopAndClear
()
for
_
,
msg
:=
range
opts
.
Messages
{
switch
msg
.
Role
{
case
"user"
:
fmt
.
Printf
(
">>> %s
\n
"
,
msg
.
Content
)
case
"assistant"
:
state
:=
&
displayResponseState
{}
displayResponse
(
msg
.
Content
,
opts
.
WordWrap
,
state
)
fmt
.
Println
()
fmt
.
Println
()
}
}
return
nil
})
return
client
.
Chat
(
cmd
.
Context
(),
chatReq
,
func
(
api
.
ChatResponse
)
error
{
return
nil
})
}
func
generateInteractive
(
cmd
*
cobra
.
Command
,
opts
runOptions
)
error
{
err
:=
loadModel
(
cmd
,
&
opts
)
if
err
!=
nil
{
return
err
}
usage
:=
func
()
{
fmt
.
Fprintln
(
os
.
Stderr
,
"Available Commands:"
)
fmt
.
Fprintln
(
os
.
Stderr
,
" /set Set session variables"
)
...
...
@@ -375,9 +356,9 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
return
err
}
req
:=
&
api
.
ShowRequest
{
Name
:
opts
.
Model
,
System
:
opts
.
System
,
Options
:
opts
.
Options
,
Name
:
opts
.
Model
,
System
:
opts
.
System
,
Options
:
opts
.
Options
,
}
resp
,
err
:=
client
.
Show
(
cmd
.
Context
(),
req
)
if
err
!=
nil
{
...
...
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