Skip to content

Commit 261cb5b

Browse files
committed
nerf ollama for now
1 parent 0175511 commit 261cb5b

14 files changed

Lines changed: 323 additions & 123 deletions

File tree

.pnp.cjs

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

executables/ollama-darwin

Lines changed: 0 additions & 3 deletions
This file was deleted.

executables/ollama-linux

Lines changed: 0 additions & 3 deletions
This file was deleted.

executables/ollama.exe

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/keepkey-desktop-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@
193193
"https-browserify": "^1.0.0",
194194
"js-file-download": "^0.4.12",
195195
"keccak256": "^1.0.6",
196+
"keepkey-ollama": "^0.0.1",
196197
"lit-html": "^2.2.5",
197198
"localforage": "^1.10.0",
198199
"lodash": "^4.17.21",
53.3 KB
Loading

packages/keepkey-desktop-app/src/assets/translations/en/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@
111111
"switchWallet": "Switch Wallet Provider",
112112
"disconnect": "Disconnect",
113113
"disconnected": "(Disconnected)",
114-
"openDev": "Open API developer documentation"
114+
"openDev": "Open API developer documentation",
115+
"openOllama": "Check Api Status"
115116
}
116117
},
117118
"navBar": {
Lines changed: 86 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,109 @@
1-
import { Divider, HStack, Stack } from '@chakra-ui/layout';
1+
import React, { FC, useEffect, useState } from 'react';
2+
import { Stack, Divider, Box, Avatar, Link, Text } from '@chakra-ui/react';
23
import { ExternalLinkIcon } from '@chakra-ui/icons';
3-
import { Avatar, Link, Button, Icon, Text } from '@chakra-ui/react';
4-
import { useModal } from 'hooks/useModal/useModal';
5-
import { useEffect, useState } from 'react';
6-
import { FaTrash } from 'react-icons/fa';
7-
import { HiRefresh } from 'react-icons/hi';
8-
import { IoFileTray } from 'react-icons/io5';
9-
import { TbRefreshAlert } from 'react-icons/tb';
10-
import { MdPlayArrow, MdStop, MdViewList } from 'react-icons/md';
11-
import { FC } from 'react';
12-
import axios from 'axios';
13-
4+
import bex from 'assets/ollama.png';
145
import { SettingsListItem } from './SettingsListItem';
6+
import OllamaStatus from './ollama/OllamaStatus';
7+
import ModelSelector from './ollama/ModelSelector';
8+
import ModelInstaller from './ollama/ModelInstaller';
9+
import Logs from './ollama/Logs';
10+
// @ts-ignore
11+
import { Ollama } from 'keepkey-ollama/browser';
1512

16-
interface OllamaSettingsProps {
17-
shouldAutoUpdate: boolean;
18-
shouldMinimizeToTray: boolean;
19-
allowPreRelease: boolean;
20-
autoScanQr: boolean;
13+
interface KnownModel {
14+
name: string;
15+
sizes: string[];
2116
}
2217

2318
export const OllamaSettings: FC = () => {
24-
const { settings, onboardingSteps } = useModal();
25-
const [appSettings, setAppSettings] = useState<OllamaSettingsProps>({
26-
shouldAutoUpdate: true,
27-
shouldMinimizeToTray: true,
28-
allowPreRelease: false,
29-
autoScanQr: false,
30-
});
31-
32-
const [prevAppSettings, setPrevAppSettings] = useState<OllamaSettingsProps>(appSettings);
33-
const [isOllamaRunning, setIsOllamaRunning] = useState(false);
34-
35-
const handleTestConnection = async () => {
19+
const [installedModels, setInstalledModels] = useState<string[]>([]);
20+
const [selectedModel, setSelectedModel] = useState('');
21+
const [needToInstall, setNeedToInstall] = useState(false);
22+
const [logs, setLogs] = useState<string[]>([]);
23+
const [showLogs, setShowLogs] = useState(false);
24+
25+
const knownModels: KnownModel[] = [
26+
{ name: 'llama-3.2', sizes: ['small', 'medium', 'large'] },
27+
{ name: 'gemma-2', sizes: ['small', 'medium'] },
28+
{ name: 'dolphin-mixtral', sizes: ['medium', 'large'] },
29+
];
30+
31+
const listInstalledModels = async () => {
3632
try {
37-
const response = await axios.get('http://127.0.0.1:11434/');
38-
console.log('Ollama is healthy:', response.data);
39-
setIsOllamaRunning(true);
33+
const response = await Ollama.list();
34+
setInstalledModels(response.models);
4035
} catch (error) {
41-
console.error('Ollama is not responding:', error);
42-
setIsOllamaRunning(false);
36+
console.error('Error listing models:', error);
37+
setLogs((prevLogs) => [...prevLogs, `Error listing models: ${error}`]);
4338
}
4439
};
4540

46-
useEffect(() => {
47-
handleTestConnection();
48-
}, []);
41+
const handleModelSelect = (modelName: string) => {
42+
setSelectedModel(modelName);
43+
setNeedToInstall(!installedModels.includes(modelName));
44+
};
45+
46+
const handleInstallComplete = () => {
47+
// After installation, refresh the installed models list
48+
listInstalledModels();
49+
setNeedToInstall(false);
50+
};
4951

5052
useEffect(() => {
51-
if (
52-
prevAppSettings &&
53-
appSettings.shouldAutoUpdate === prevAppSettings.shouldAutoUpdate &&
54-
appSettings.shouldMinimizeToTray === prevAppSettings.shouldMinimizeToTray &&
55-
appSettings.allowPreRelease === prevAppSettings.allowPreRelease &&
56-
appSettings.autoScanQr === prevAppSettings.autoScanQr
57-
) return;
58-
59-
setPrevAppSettings(appSettings);
60-
console.log('APP SETTINGS SAVED', appSettings);
61-
}, [appSettings, prevAppSettings]);
53+
listInstalledModels();
54+
}, []);
6255

6356
return (
64-
<Stack width='full' p={0}>
57+
<Stack width="full" p={0}>
6558
<Divider my={1} />
66-
<Link href='http://127.0.0.1:11434/' isExternal>
59+
<Box maxW={{ base: '100%', md: '45%' }} mb={{ base: 4, md: 0 }} mx="auto">
60+
<Avatar src={bex} size="lg" />
61+
</Box>
62+
63+
<Link href="http://127.0.0.1:11434/" isExternal>
6764
<SettingsListItem
68-
icon={<Icon as={ExternalLinkIcon} color='gray.500' />}
69-
label='connectWallet.menu.openDev'
65+
icon={<ExternalLinkIcon color="gray.500" />}
66+
label="Open Ollama"
7067
/>
7168
</Link>
69+
7270
<Divider my={1} />
73-
<HStack>
74-
<SettingsListItem
75-
label={'Test Connection'}
76-
onClick={handleTestConnection}
77-
icon={<Icon as={HiRefresh} color='gray.500' />}
78-
>
79-
<Button variant={'ghost'} onClick={handleTestConnection}>
80-
Test
81-
</Button>
82-
</SettingsListItem>
83-
<Text color={isOllamaRunning ? 'green.500' : 'red.500'}>
84-
{isOllamaRunning ? 'Online' : 'Offline'}
85-
</Text>
86-
</HStack>
71+
72+
{/* Model Selector */}
73+
<ModelSelector
74+
installedModels={installedModels}
75+
knownModels={knownModels}
76+
onModelSelect={handleModelSelect}
77+
/>
78+
79+
<Divider my={1} />
80+
81+
{/* Install Model if needed */}
82+
{needToInstall && selectedModel && (
83+
<>
84+
<ModelInstaller
85+
modelName={selectedModel}
86+
onInstallComplete={handleInstallComplete}
87+
setLogs={setLogs}
88+
/>
89+
<Divider my={1} />
90+
</>
91+
)}
92+
93+
{/* Link to find more models */}
94+
<Link href="https://ollama.com/library" isExternal>
95+
Find more models
96+
</Link>
97+
98+
<Divider my={1} />
99+
100+
{/* Ollama Status */}
101+
<OllamaStatus />
102+
103+
<Divider my={1} />
104+
105+
{/* Logs Section */}
106+
<Logs logs={logs} showLogs={showLogs} setShowLogs={setShowLogs} />
87107
</Stack>
88108
);
89109
};

packages/keepkey-desktop-app/src/components/Modals/Settings/SettingsList.tsx

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -49,52 +49,52 @@ export const SettingsList = ({ appHistory, ...routeProps }: SettingsListProps) =
4949
const { isConnected, walletInfo, type } = state
5050

5151
return (
52-
<SlideTransition>
53-
<ModalHeader textAlign='center' userSelect='none' onClick={handleHeaderClick}>
54-
{translate('modals.settings.settings')}
55-
</ModalHeader>
56-
<ModalCloseButton />
57-
<ModalBody alignItems='center' justifyContent='center' textAlign='center' pt={0} px={0}>
58-
<Tabs>
59-
<TabList>
60-
<Tab>
61-
<Text translation='modals.settings.tabs.general' />
62-
</Tab>
63-
<Tab>
64-
<Text translation='modals.settings.tabs.app' />
65-
</Tab>
66-
<Tab>
67-
<Text translation='modals.settings.tabs.keepkey' />
68-
</Tab>
69-
<Tab>
70-
<Text translation='modals.settings.tabs.ollama' />
71-
</Tab>
72-
</TabList>
73-
<TabPanels>
74-
<TabPanel>
75-
<GeneralSettings appHistory={appHistory} {...routeProps} />
76-
</TabPanel>
77-
<TabPanel>
78-
<AppSettings />
79-
</TabPanel>
80-
<TabPanel>
81-
<Menu>
82-
<WalletConnected
83-
isConnected={isConnected}
84-
walletInfo={walletInfo}
85-
onDisconnect={disconnect}
86-
type={type}
87-
/>
88-
</Menu>
89-
</TabPanel>
90-
<TabPanel>
91-
<Menu>
92-
<OllamaSettings></OllamaSettings>
93-
</Menu>
94-
</TabPanel>
95-
</TabPanels>
96-
</Tabs>
97-
</ModalBody>
98-
</SlideTransition>
52+
<SlideTransition>
53+
<ModalHeader textAlign='center' userSelect='none' onClick={handleHeaderClick}>
54+
{translate('modals.settings.settings')}
55+
</ModalHeader>
56+
<ModalCloseButton />
57+
<ModalBody alignItems='center' justifyContent='center' textAlign='center' pt={0} px={0}>
58+
<Tabs>
59+
<TabList justifyContent="center">
60+
<Tab>
61+
<Text translation='modals.settings.tabs.general' />
62+
</Tab>
63+
<Tab>
64+
<Text translation='modals.settings.tabs.app' />
65+
</Tab>
66+
<Tab>
67+
<Text translation='modals.settings.tabs.keepkey' />
68+
</Tab>
69+
{/*<Tab>*/}
70+
{/* <Text translation='modals.settings.tabs.ollama' />*/}
71+
{/*</Tab>*/}
72+
</TabList>
73+
<TabPanels>
74+
<TabPanel>
75+
<GeneralSettings appHistory={appHistory} {...routeProps} />
76+
</TabPanel>
77+
<TabPanel>
78+
<AppSettings />
79+
</TabPanel>
80+
<TabPanel>
81+
<Menu>
82+
<WalletConnected
83+
isConnected={isConnected}
84+
walletInfo={walletInfo}
85+
onDisconnect={disconnect}
86+
type={type}
87+
/>
88+
</Menu>
89+
</TabPanel>
90+
<TabPanel>
91+
<Menu>
92+
<OllamaSettings></OllamaSettings>
93+
</Menu>
94+
</TabPanel>
95+
</TabPanels>
96+
</Tabs>
97+
</ModalBody>
98+
</SlideTransition>
9999
)
100100
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React, { FC } from 'react';
2+
import { Box, Button, Text, Icon } from '@chakra-ui/react';
3+
import { MdViewList } from 'react-icons/md';
4+
5+
interface LogsProps {
6+
logs: string[];
7+
showLogs: boolean;
8+
setShowLogs: React.Dispatch<React.SetStateAction<boolean>>;
9+
}
10+
11+
const Logs: FC<LogsProps> = ({ logs, showLogs, setShowLogs }) => {
12+
return (
13+
<Box>
14+
<Button variant="ghost" onClick={() => setShowLogs((prev) => !prev)}>
15+
{showLogs ? 'Hide Logs' : 'Show Logs'}
16+
<Icon as={MdViewList} ml={2} />
17+
</Button>
18+
{showLogs && (
19+
<Box p={2} maxH="200px" overflowY="auto" border="1px solid gray">
20+
{logs.map((log, index) => (
21+
<Text key={index} fontSize="sm">
22+
{log}
23+
</Text>
24+
))}
25+
</Box>
26+
)}
27+
</Box>
28+
);
29+
};
30+
31+
export default Logs;

0 commit comments

Comments
 (0)