-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df42f09
commit fed6930
Showing
23 changed files
with
1,683 additions
and
65 deletions.
There are no files selected for viewing
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
packages/keepkey-desktop-app/src/components/Modals/Settings/OllamaSettings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { Divider, HStack, Stack } from '@chakra-ui/layout'; | ||
import { Avatar, Button, Icon, IconButton, Switch, Text } from '@chakra-ui/react'; | ||
import { useModal } from 'hooks/useModal/useModal'; | ||
import { useEffect, useState } from 'react'; | ||
import { FaTrash } from 'react-icons/fa'; | ||
import { HiRefresh } from 'react-icons/hi'; | ||
import { IoFileTray } from 'react-icons/io5'; | ||
import { TbRefreshAlert } from 'react-icons/tb'; | ||
import { MdPlayArrow, MdStop, MdViewList } from 'react-icons/md'; | ||
|
||
import { SettingsListItem } from './SettingsListItem'; | ||
|
||
interface OllamaSettingsProps { | ||
shouldAutoUpdate: boolean; | ||
shouldMinimizeToTray: boolean; | ||
allowPreRelease: boolean; | ||
autoScanQr: boolean; | ||
} | ||
|
||
export const OllamaSettings: FC = () => { | ||
const { settings, onboardingSteps } = useModal(); | ||
const [appSettings, setAppSettings] = useState<OllamaSettingsProps>({ | ||
shouldAutoUpdate: true, | ||
shouldMinimizeToTray: true, | ||
allowPreRelease: false, | ||
autoScanQr: false, | ||
}); | ||
|
||
const [prevAppSettings, setPrevAppSettings] = useState<OllamaSettingsProps>(appSettings); | ||
|
||
const handleViewModels = () => { | ||
console.log('Viewing models...'); | ||
// Mock action: Display a message or simulate viewing models | ||
}; | ||
|
||
const handleStartOllama = () => { | ||
console.log('Starting Ollama...'); | ||
// Mock action: Display a message or simulate starting Ollama | ||
}; | ||
|
||
const handleStopOllama = () => { | ||
console.log('Stopping Ollama...'); | ||
// Mock action: Display a message or simulate stopping Ollama | ||
}; | ||
|
||
useEffect(() => { | ||
(async () => { | ||
if ( | ||
prevAppSettings && | ||
appSettings.shouldAutoUpdate === prevAppSettings.shouldAutoUpdate && | ||
appSettings.shouldMinimizeToTray === prevAppSettings.shouldMinimizeToTray && | ||
appSettings.allowPreRelease === prevAppSettings.allowPreRelease && | ||
appSettings.autoScanQr === prevAppSettings.autoScanQr | ||
) | ||
return; | ||
setPrevAppSettings(appSettings); | ||
// Save settings | ||
console.log('APP SETTINGS SAVED', appSettings); | ||
})().catch(e => console.error(e)); | ||
}, [appSettings, prevAppSettings]); | ||
|
||
return ( | ||
<Stack width='full' p={0}> | ||
<Divider my={1} /> | ||
<SettingsListItem | ||
label={'View Models'} | ||
onClick={handleViewModels} | ||
icon={<Icon as={MdViewList} color='gray.500' />} | ||
> | ||
<Button variant={'ghost'} onClick={handleViewModels}> | ||
View Models | ||
</Button> | ||
</SettingsListItem> | ||
<Divider my={1} /> | ||
<SettingsListItem | ||
label={'Start Ollama'} | ||
onClick={handleStartOllama} | ||
icon={<Icon as={MdPlayArrow} color='gray.500' />} | ||
> | ||
<Button variant={'ghost'} onClick={handleStartOllama}> | ||
Start | ||
</Button> | ||
</SettingsListItem> | ||
<Divider my={1} /> | ||
<SettingsListItem | ||
label={'Stop Ollama'} | ||
onClick={handleStopOllama} | ||
icon={<Icon as={MdStop} color='gray.500' />} | ||
> | ||
<Button variant={'ghost'} onClick={handleStopOllama}> | ||
Stop | ||
</Button> | ||
</SettingsListItem> | ||
</Stack> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "keepkey-desktop", | ||
"version": "3.0.26", | ||
"version": "3.1.0", | ||
"author": { | ||
"name": "KeepKey", | ||
"email": "[email protected]" | ||
|
@@ -30,7 +30,8 @@ | |
"generateUpdatesFilesForAllChannels": true, | ||
"publish": "github", | ||
"files": [ | ||
"build/**/*" | ||
"build/**/*", | ||
"executables/*" | ||
], | ||
"protocols": [ | ||
{ | ||
|
@@ -103,6 +104,7 @@ | |
"bs58check": "^3.0.1", | ||
"bufferutil": "^4.0.7", | ||
"builder-util": "^25.0.0-alpha.6", | ||
"check-disk-space": "^3.4.0", | ||
"comlink": "^4.3.1", | ||
"comlink-electron-endpoint": "^1.0.3", | ||
"common-utils": "workspace:*", | ||
|
@@ -111,6 +113,7 @@ | |
"dotenv": "^16.0.3", | ||
"electron-is-dev": "^2.0.0", | ||
"electron-log": "^4.4.8", | ||
"electron-store": "^10.0.0", | ||
"electron-unhandled": "^4.0.1", | ||
"electron-updater": "^6.1.8", | ||
"esbuild": "^0.15.14", | ||
|
@@ -130,19 +133,22 @@ | |
"nedb-promises": "^6.2.1", | ||
"node-fetch": "^3.3.0", | ||
"node-hid": "^2.1.2", | ||
"ollama": "^0.5.6", | ||
"promise.any": "^2.0.5", | ||
"protobufjs": "^7.2.6", | ||
"secp256k1": "^4.0.3", | ||
"semver": "^7.3.8", | ||
"source-map-support": "^0.5.21", | ||
"sudo-prompt": "^9.2.1", | ||
"swagger-ui-dist": "^4.15.5", | ||
"swagger-ui-express": "^4.6.0", | ||
"tiny-secp256k1": "^1.1.6", | ||
"usb": "^2.5.2", | ||
"utf-8-validate": "^5.0.10", | ||
"uuid": "^9.0.0", | ||
"wait-promise": "^0.4.1", | ||
"web3": "^4.0.1" | ||
"web3": "^4.0.1", | ||
"winston": "^3.13.1" | ||
}, | ||
"devDependencies": { | ||
"@keepkey/common-esbuild-bits": "workspace:*", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export const models = { | ||
mistral: { | ||
tags: ['text', '7b', '7b-instruct', '7b-text'], | ||
}, | ||
llama2: { | ||
tags: ['chat', '7b', 'text'], | ||
}, | ||
orcaMini: { | ||
tags: ['latest', '3b'], | ||
}, | ||
nousHermes: { | ||
tags: ['latest', '7b'], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export enum IpcChannel { | ||
AppInit = 'app:init', | ||
GetModelsPath = 'app:getfolder', | ||
SetFolderPath = 'app:setfolder', | ||
Close = 'app:close', | ||
Minimize = 'app:minimize', | ||
} | ||
|
||
export enum OllamaChannel { | ||
OllamaInit = 'ollama:init', | ||
OllamaStatusUpdate = 'ollama:status', | ||
OllamaGetAllModels = 'ollama:getallmodels', | ||
OllamaQuestion = 'ollama:question', | ||
OllamaAnswer = 'ollama:answer', | ||
OllamaGetModel = 'ollama:getmodel', | ||
} | ||
|
||
export enum IpcMainChannel { | ||
Error = 'main:error', | ||
CommandOuput = 'command:output', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { dialog } from 'electron'; | ||
|
||
import { IpcChannel } from './events'; | ||
import { | ||
loadOllama, | ||
stopOllama, | ||
getAllLocalModels, | ||
askOllama, | ||
getOrPullModel, | ||
} from './ollama'; | ||
import { OllamaQuestion } from './types'; | ||
import { saveModelPathToStorage, getModelPathFromStorage } from './storage'; | ||
|
||
export const initOllama = async () => { | ||
try { | ||
const ollamaLoaded = await loadOllama(); | ||
|
||
return ollamaLoaded; | ||
} catch (err) { | ||
handleError(err); | ||
|
||
return false; | ||
} | ||
}; | ||
|
||
export const stopOllamaServe = async () => { | ||
await stopOllama(); | ||
}; | ||
|
||
export const getAllModels = async () => { | ||
try { | ||
const models = await getAllLocalModels(); | ||
|
||
return models; | ||
// event.reply(OllamaChannel.OllamaGetAllModels, models); | ||
} catch (err) { | ||
handleError(err); | ||
} | ||
}; | ||
|
||
export const getModel = async ( model: string) => { | ||
try { | ||
const response = await getOrPullModel(model); | ||
|
||
return response; | ||
} catch (err) { | ||
handleError(err); | ||
} | ||
}; | ||
|
||
export const askOlama = async ( { model, query }: OllamaQuestion) => { | ||
try { | ||
const response = await askOllama(model, query); | ||
|
||
return response; | ||
} catch (err) { | ||
handleError(err); | ||
} | ||
}; | ||
|
||
export const getModelsFolderPath = async () => { | ||
return getModelPathFromStorage(); | ||
}; | ||
|
||
export const setModelFolderPath = async () => { | ||
const result = await dialog.showOpenDialog({ | ||
properties: ['openDirectory', 'createDirectory'], | ||
}); | ||
|
||
if (result.filePaths) { | ||
saveModelPathToStorage(result.filePaths[0]); | ||
} | ||
|
||
return true; | ||
}; | ||
|
||
const handleError = (err: Error) => { | ||
console.error(err); | ||
|
||
// log with winston here | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import winston from 'winston'; | ||
import path from 'path'; | ||
import { isDev } from '../main'; | ||
import { app } from 'electron'; | ||
|
||
const logFilePath = isDev ? '.' : app.getPath('userData'); | ||
|
||
export const logger = winston.createLogger({ | ||
format: winston.format.simple(), | ||
transports: [ | ||
new winston.transports.Console(), | ||
new winston.transports.File({ | ||
filename: path.join(logFilePath, 'error.log'), | ||
maxFiles: 1, | ||
level: 'error', | ||
}), | ||
new winston.transports.File({ | ||
filename: path.join(logFilePath, 'app.log'), | ||
maxFiles: 1, | ||
level: 'info', | ||
}), | ||
], | ||
exceptionHandlers: [ | ||
new winston.transports.File({ | ||
filename: path.join(logFilePath, 'exceptions.log'), | ||
}), | ||
], | ||
exitOnError: false, | ||
}); |
Oops, something went wrong.