app.tsx 3.67 KB
Newer Older
Jeffrey Morgan's avatar
Jeffrey Morgan committed
1
import { useState } from 'react'
2
3
import copy from 'copy-to-clipboard'
import { DocumentDuplicateIcon } from '@heroicons/react/24/outline'
4
5
import Store from 'electron-store'
import { getCurrentWindow } from '@electron/remote'
Jeffrey Morgan's avatar
Jeffrey Morgan committed
6

7
8
import { install } from './install'
import OllamaIcon from './ollama.svg'
Jeffrey Morgan's avatar
Jeffrey Morgan committed
9

10
const store = new Store()
Jeffrey Morgan's avatar
Jeffrey Morgan committed
11

Jeffrey Morgan's avatar
Jeffrey Morgan committed
12
13
14
15
16
17
enum Step {
  WELCOME = 0,
  CLI,
  FINISH,
}

Jeffrey Morgan's avatar
Jeffrey Morgan committed
18
export default function () {
Jeffrey Morgan's avatar
Jeffrey Morgan committed
19
  const [step, setStep] = useState<Step>(Step.WELCOME)
20
21

  const command = 'ollama run orca'
Jeffrey Morgan's avatar
Jeffrey Morgan committed
22

Jeffrey Morgan's avatar
Jeffrey Morgan committed
23
  return (
24
    <div className='mx-auto flex min-h-screen w-full flex-col justify-between bg-white px-4 pt-16'>
Jeffrey Morgan's avatar
Jeffrey Morgan committed
25
      {step === Step.WELCOME && (
26
        <>
Jeffrey Morgan's avatar
Jeffrey Morgan committed
27
28
29
30
          <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.
31
32
            </p>
            <button
33
              onClick={() => setStep(Step.CLI)}
Jeffrey Morgan's avatar
Jeffrey Morgan committed
34
              className='rounded-dm mx-auto my-8 w-[40%] rounded-md bg-black px-4 py-2 text-sm text-white hover:brightness-110'
35
36
            >
              Next
Jeffrey Morgan's avatar
Jeffrey Morgan committed
37
            </button>
38
          </div>
Jeffrey Morgan's avatar
Jeffrey Morgan committed
39
          <div className='mx-auto'>
40
41
42
43
            <OllamaIcon />
          </div>
        </>
      )}
Jeffrey Morgan's avatar
Jeffrey Morgan committed
44
      {step === Step.CLI && (
45
        <>
Jeffrey Morgan's avatar
Jeffrey Morgan committed
46
47
48
49
          <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'>&gt; ollama</pre>
            <div className='mx-auto'>
50
              <button
51
                onClick={async () => {
52
53
54
55
                  await install()
                  getCurrentWindow().show()
                  getCurrentWindow().focus()
                  setStep(Step.FINISH)
56
                }}
Jeffrey Morgan's avatar
Jeffrey Morgan committed
57
                className='rounded-dm mx-auto w-[60%] rounded-md bg-black px-4 py-2 text-sm text-white hover:brightness-110'
58
59
60
              >
                Install
              </button>
Jeffrey Morgan's avatar
Jeffrey Morgan committed
61
              <p className='mx-auto my-4 w-[70%] text-xs text-gray-400'>
62
63
64
65
66
67
                You will be prompted for administrator access
              </p>
            </div>
          </div>
        </>
      )}
Jeffrey Morgan's avatar
Jeffrey Morgan committed
68
      {step === Step.FINISH && (
69
        <>
Jeffrey Morgan's avatar
Jeffrey Morgan committed
70
71
72
73
74
          <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'>
75
76
77
78
79
80
81
82
                  {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)
                  }}
                >
Jeffrey Morgan's avatar
Jeffrey Morgan committed
83
                  <DocumentDuplicateIcon className='h-4 w-4 text-gray-500' />
84
                </button>
Jeffrey Morgan's avatar
Jeffrey Morgan committed
85
              </div>
Jeffrey Morgan's avatar
Jeffrey Morgan committed
86
              <p className='mx-auto my-4 w-[70%] text-xs text-gray-400'>Run this command in your favorite terminal.</p>
Jeffrey Morgan's avatar
Jeffrey Morgan committed
87
            </div>
88
89
            <button
              onClick={() => {
90
                store.set('first-time-run', true)
91
92
                window.close()
              }}
Jeffrey Morgan's avatar
Jeffrey Morgan committed
93
              className='rounded-dm mx-auto w-[60%] rounded-md bg-black px-4 py-2 text-sm text-white hover:brightness-110'
94
95
96
97
98
            >
              Finish
            </button>
          </div>
        </>
Jeffrey Morgan's avatar
Jeffrey Morgan committed
99
      )}
Jeffrey Morgan's avatar
Jeffrey Morgan committed
100
101
    </div>
  )
Jeffrey Morgan's avatar
Jeffrey Morgan committed
102
}