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
105186aa
Unverified
Commit
105186aa
authored
May 18, 2024
by
Patrick Devine
Committed by
GitHub
May 18, 2024
Browse files
add OLLAMA_NOHISTORY to turn off history in interactive mode (#4508)
parent
ba04afc9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
5 deletions
+30
-5
cmd/cmd.go
cmd/cmd.go
+26
-5
cmd/interactive.go
cmd/interactive.go
+4
-0
No files found.
cmd/cmd.go
View file @
105186aa
...
...
@@ -1078,12 +1078,24 @@ func versionHandler(cmd *cobra.Command, _ []string) {
}
}
func
appendHostEnvDocs
(
cmd
*
cobra
.
Command
)
{
const
hostEnvDocs
=
`
type
EnvironmentVar
struct
{
Name
string
Description
string
}
func
appendEnvDocs
(
cmd
*
cobra
.
Command
,
envs
[]
EnvironmentVar
)
{
if
len
(
envs
)
==
0
{
return
}
envUsage
:=
`
Environment Variables:
OLLAMA_HOST The host:port or base URL of the Ollama server (e.g. http://localhost:11434)
`
cmd
.
SetUsageTemplate
(
cmd
.
UsageTemplate
()
+
hostEnvDocs
)
for
_
,
e
:=
range
envs
{
envUsage
+=
fmt
.
Sprintf
(
" %-16s %s
\n
"
,
e
.
Name
,
e
.
Description
)
}
cmd
.
SetUsageTemplate
(
cmd
.
UsageTemplate
()
+
envUsage
)
}
func
NewCLI
()
*
cobra
.
Command
{
...
...
@@ -1220,6 +1232,10 @@ Environment Variables:
RunE
:
DeleteHandler
,
}
ollamaHostEnv
:=
EnvironmentVar
{
"OLLAMA_HOST"
,
"The host:port or base URL of the Ollama server (e.g. http://localhost:11434)"
}
ollamaNoHistoryEnv
:=
EnvironmentVar
{
"OLLAMA_NOHISTORY"
,
"Disable readline history"
}
envs
:=
[]
EnvironmentVar
{
ollamaHostEnv
}
for
_
,
cmd
:=
range
[]
*
cobra
.
Command
{
createCmd
,
showCmd
,
...
...
@@ -1231,7 +1247,12 @@ Environment Variables:
copyCmd
,
deleteCmd
,
}
{
appendHostEnvDocs
(
cmd
)
switch
cmd
{
case
runCmd
:
appendEnvDocs
(
cmd
,
[]
EnvironmentVar
{
ollamaHostEnv
,
ollamaNoHistoryEnv
})
default
:
appendEnvDocs
(
cmd
,
envs
)
}
}
rootCmd
.
AddCommand
(
...
...
cmd/interactive.go
View file @
105186aa
...
...
@@ -182,6 +182,10 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
return
err
}
if
os
.
Getenv
(
"OLLAMA_NOHISTORY"
)
!=
""
{
scanner
.
HistoryDisable
()
}
fmt
.
Print
(
readline
.
StartBracketedPaste
)
defer
fmt
.
Printf
(
readline
.
EndBracketedPaste
)
...
...
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