2023-07-17 01:29:11 +00:00
|
|
|
import { useState } from 'react'
|
2023-07-14 23:34:24 +00:00
|
|
|
import copy from 'copy-to-clipboard'
|
2023-07-17 01:38:37 +00:00
|
|
|
import { exec as cbExec } from 'child_process'
|
2023-07-14 23:34:24 +00:00
|
|
|
import * as path from 'path'
|
|
|
|
import * as fs from 'fs'
|
|
|
|
import { DocumentDuplicateIcon } from '@heroicons/react/24/outline'
|
|
|
|
import { app } from '@electron/remote'
|
|
|
|
import OllamaIcon from './ollama.svg'
|
2023-07-17 01:38:37 +00:00
|
|
|
import { promisify } from 'util'
|
2023-07-14 23:34:24 +00:00
|
|
|
|
2023-07-17 01:29:11 +00:00
|
|
|
const ollama = app.isPackaged ? path.join(process.resourcesPath, 'ollama') : path.resolve(process.cwd(), '..', 'ollama')
|
2023-07-17 01:38:37 +00:00
|
|
|
const exec = promisify(cbExec)
|
2023-07-14 23:34:24 +00:00
|
|
|
|
2023-07-17 01:38:37 +00:00
|
|
|
async function installCLI() {
|
2023-07-14 23:34:24 +00:00
|
|
|
const symlinkPath = '/usr/local/bin/ollama'
|
|
|
|
|
|
|
|
if (fs.existsSync(symlinkPath) && fs.readlinkSync(symlinkPath) === ollama) {
|
2023-06-23 18:04:39 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-07-17 01:38:37 +00:00
|
|
|
const command = `do shell script "ln -F -s ${ollama} /usr/local/bin/ollama" with administrator privileges`
|
2023-07-17 01:29:11 +00:00
|
|
|
|
2023-07-17 01:38:37 +00:00
|
|
|
try {
|
|
|
|
await exec(`osascript -e '${command}'`)
|
|
|
|
} catch (error) {
|
|
|
|
console.error(`cli: failed to install cli: ${error.message}`)
|
|
|
|
return
|
|
|
|
}
|
2023-06-23 18:04:39 +00:00
|
|
|
}
|
2023-06-22 16:45:31 +00:00
|
|
|
|
2023-06-23 19:04:38 +00:00
|
|
|
export default function () {
|
2023-07-14 23:34:24 +00:00
|
|
|
const [step, setStep] = useState(0)
|
|
|
|
|
|
|
|
const command = 'ollama run orca'
|
2023-06-23 18:04:39 +00:00
|
|
|
|
2023-06-22 16:45:31 +00:00
|
|
|
return (
|
2023-07-17 01:29:11 +00:00
|
|
|
<div className='mx-auto flex min-h-screen w-full flex-col justify-between bg-white px-4 pt-16'>
|
2023-07-14 23:34:24 +00:00
|
|
|
{step === 0 && (
|
|
|
|
<>
|
2023-07-17 01:29:11 +00:00
|
|
|
<div className='mx-auto text-center'>
|
|
|
|
<h1 className='mb-6 mt-4 text-2xl tracking-tight text-gray-900'>Welcome to Ollama</h1>
|
|
|
|
<p className='mx-auto w-[65%] text-sm text-gray-400'>
|
|
|
|
Let's get you up and running with your own large language models.
|
2023-07-14 23:34:24 +00:00
|
|
|
</p>
|
|
|
|
<button
|
|
|
|
onClick={() => {
|
|
|
|
setStep(1)
|
|
|
|
}}
|
2023-07-17 01:29:11 +00:00
|
|
|
className='rounded-dm mx-auto my-8 w-[40%] rounded-md bg-black px-4 py-2 text-sm text-white hover:brightness-110'
|
2023-07-14 23:34:24 +00:00
|
|
|
>
|
|
|
|
Next
|
2023-07-17 01:29:11 +00:00
|
|
|
</button>
|
2023-07-14 23:34:24 +00:00
|
|
|
</div>
|
2023-07-17 01:29:11 +00:00
|
|
|
<div className='mx-auto'>
|
2023-07-14 23:34:24 +00:00
|
|
|
<OllamaIcon />
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{step === 1 && (
|
|
|
|
<>
|
2023-07-17 01:29:11 +00:00
|
|
|
<div className='mx-auto flex flex-col space-y-28 text-center'>
|
|
|
|
<h1 className='mt-4 text-2xl tracking-tight text-gray-900'>Install the command line</h1>
|
|
|
|
<pre className='mx-auto text-4xl text-gray-400'>> ollama</pre>
|
|
|
|
<div className='mx-auto'>
|
2023-07-14 23:34:24 +00:00
|
|
|
<button
|
2023-07-17 01:38:37 +00:00
|
|
|
onClick={async () => {
|
|
|
|
await installCLI()
|
|
|
|
window.focus()
|
|
|
|
setStep(2)
|
2023-07-14 23:34:24 +00:00
|
|
|
}}
|
2023-07-17 01:29:11 +00:00
|
|
|
className='rounded-dm mx-auto w-[60%] rounded-md bg-black px-4 py-2 text-sm text-white hover:brightness-110'
|
2023-07-14 23:34:24 +00:00
|
|
|
>
|
|
|
|
Install
|
|
|
|
</button>
|
2023-07-17 01:29:11 +00:00
|
|
|
<p className='mx-auto my-4 w-[70%] text-xs text-gray-400'>
|
2023-07-14 23:34:24 +00:00
|
|
|
You will be prompted for administrator access
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{step === 2 && (
|
|
|
|
<>
|
2023-07-17 01:29:11 +00:00
|
|
|
<div className='mx-auto flex flex-col space-y-20 text-center'>
|
|
|
|
<h1 className='mt-4 text-2xl tracking-tight text-gray-900'>Run your first model</h1>
|
|
|
|
<div className='flex flex-col'>
|
|
|
|
<div className='group relative flex items-center'>
|
|
|
|
<pre className='language-none text-2xs w-full rounded-md bg-gray-100 px-4 py-3 text-start leading-normal'>
|
2023-07-14 23:34:24 +00:00
|
|
|
{command}
|
|
|
|
</pre>
|
|
|
|
<button
|
|
|
|
className='absolute right-[5px] rounded-md border bg-white/90 px-2 py-2 text-gray-400 opacity-0 backdrop-blur-xl hover:text-gray-600 group-hover:opacity-100'
|
|
|
|
onClick={() => {
|
|
|
|
copy(command)
|
|
|
|
}}
|
|
|
|
>
|
2023-07-17 01:29:11 +00:00
|
|
|
<DocumentDuplicateIcon className='h-4 w-4 text-gray-500' />
|
2023-07-14 23:34:24 +00:00
|
|
|
</button>
|
2023-06-27 16:35:51 +00:00
|
|
|
</div>
|
2023-07-17 01:29:11 +00:00
|
|
|
<p className='mx-auto my-4 w-[70%] text-xs text-gray-400'>Run this command in your favorite terminal.</p>
|
2023-06-23 18:04:39 +00:00
|
|
|
</div>
|
2023-07-14 23:34:24 +00:00
|
|
|
<button
|
|
|
|
onClick={() => {
|
|
|
|
window.close()
|
|
|
|
}}
|
2023-07-17 01:29:11 +00:00
|
|
|
className='rounded-dm mx-auto w-[60%] rounded-md bg-black px-4 py-2 text-sm text-white hover:brightness-110'
|
2023-07-14 23:34:24 +00:00
|
|
|
>
|
|
|
|
Finish
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</>
|
2023-06-27 16:35:51 +00:00
|
|
|
)}
|
2023-06-22 16:45:31 +00:00
|
|
|
</div>
|
|
|
|
)
|
2023-07-17 01:29:11 +00:00
|
|
|
}
|