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
4f3cfea6
Commit
4f3cfea6
authored
Jul 06, 2023
by
Jeffrey Morgan
Browse files
prompt to install the `ollama` cli on macOS
parent
926ffa7f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
7 deletions
+39
-7
app/src/index.ts
app/src/index.ts
+39
-7
No files found.
app/src/index.ts
View file @
4f3cfea6
import
{
app
,
BrowserWindow
,
autoUpdater
,
dialog
}
from
'
electron
'
import
{
app
,
BrowserWindow
,
autoUpdater
,
dialog
}
from
'
electron
'
import
{
spawn
}
from
'
child_process
'
import
{
spawn
,
exec
}
from
'
child_process
'
import
*
as
path
from
'
path
'
import
*
as
path
from
'
path
'
require
(
'
@electron/remote/main
'
).
initialize
()
require
(
'
@electron/remote/main
'
).
initialize
()
...
@@ -39,13 +39,11 @@ const createWindow = (): void => {
...
@@ -39,13 +39,11 @@ const createWindow = (): void => {
// if the app is packaged then run the server
// if the app is packaged then run the server
if
(
app
.
isPackaged
)
{
if
(
app
.
isPackaged
)
{
const
resources
=
process
.
resourcesPath
const
ollama
=
path
.
join
(
process
.
resourcesPath
,
'
ollama
'
)
console
.
log
(
resources
)
// Start the executable
// Start the executable
const
exec
=
path
.
join
(
resources
,
'
ollama
'
)
console
.
log
(
`Starting server`
)
console
.
log
(
`Starting
${
exec
}
`
)
const
proc
=
spawn
(
ollama
,
[
'
serve
'
])
const
proc
=
spawn
(
exec
,
[
'
serve
'
])
proc
.
stdout
.
on
(
'
data
'
,
data
=>
{
proc
.
stdout
.
on
(
'
data
'
,
data
=>
{
console
.
log
(
`server:
${
data
}
`
)
console
.
log
(
`server:
${
data
}
`
)
})
})
...
@@ -58,10 +56,40 @@ if (app.isPackaged) {
...
@@ -58,10 +56,40 @@ if (app.isPackaged) {
})
})
}
}
function
installCLI
()
{
dialog
.
showMessageBox
({
type
:
'
info
'
,
title
:
'
Ollama CLI installation
'
,
message
:
'
To install the ollama CLI, we need your permission. You will be prompted to confirm.
'
,
buttons
:
[
'
OK
'
],
})
.
then
(
result
=>
{
if
(
result
.
response
===
0
)
{
let
resourcePath
=
path
.
join
(
process
.
resourcesPath
,
'
your_binary
'
)
let
command
=
`
do shell script "ln -F -s
${
resourcePath
}
/usr/local/bin/ollama" with administrator privileges
`
exec
(
`osascript -e '
${
command
}
'`
,
(
error
:
Error
|
null
,
stdout
:
string
,
stderr
:
string
)
=>
{
if
(
error
)
{
console
.
error
(
`exec error:
${
error
}
`
)
return
}
console
.
log
(
`stdout:
${
stdout
}
`
)
console
.
error
(
`stderr:
${
stderr
}
`
)
})
}
})
}
// This method will be called when Electron has finished
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
// Some APIs can only be used after this event occurs.
app
.
on
(
'
ready
'
,
createWindow
)
app
.
on
(
'
ready
'
,
()
=>
{
createWindow
()
installCLI
()
})
// Quit when all windows are closed, except on macOS. There, it's common
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// for applications and their menu bar to stay active until the user quits
...
@@ -91,6 +119,10 @@ setInterval(() => {
...
@@ -91,6 +119,10 @@ setInterval(() => {
autoUpdater
.
checkForUpdates
()
autoUpdater
.
checkForUpdates
()
},
60000
)
},
60000
)
autoUpdater
.
on
(
'
error
'
,
e
=>
{
console
.
error
(
'
update check failed
'
,
e
)
})
autoUpdater
.
on
(
'
update-downloaded
'
,
(
event
,
releaseNotes
,
releaseName
)
=>
{
autoUpdater
.
on
(
'
update-downloaded
'
,
(
event
,
releaseNotes
,
releaseName
)
=>
{
dialog
dialog
.
showMessageBox
({
.
showMessageBox
({
...
...
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